carbon icon indicating copy to clipboard operation
carbon copied to clipboard

Unable to read language.json file

Open lixh00 opened this issue 3 years ago • 2 comments

Hello,

I encountered an issue with the following code:

lange := carbon.NewLanguage()
lange.SetLocale("zh-CN")
car := carbon.SetLanguage(lange)
if car.Error != nil {
	log.Printf("Error Info %v\n", car.Error)
	return
}

offDutyTime := car.Now().StartOfDay().AddHours(18)
now := car.Now()
diff:= now.DiffInString(offDutyTime)
log.Printf("Diff: %v", diff)

golang version: such as 1.16 1.18.1

carbon version: such as 1.5.0 v2.1.8

time zone: such as Japan China

I expected to get:

`Diff: 9小时`

But I actually get:

invalid locale file "lang\\zh-CN.json", please make sure the json file exists and is valid

Pic: image image

Thanks!

lixh00 avatar Jun 14 '22 00:06 lixh00

Sorry, I haven't tested it on the window platform, I will try to find a window platform device to test.

kuafuRace avatar Jun 15 '22 02:06 kuafuRace

I had the same problem, windows10, go.1.18.3, carbon: v2.1.8 image

=== RUN TestWeek a_test.go:15: invalid locale file "lang\zh-CN.json", please make sure the json file exists and is valid

--- FAIL: TestWeek (0.00s)

FAIL

chanyipiaomiao avatar Jun 18 '22 14:06 chanyipiaomiao

It has been fixed in v1.7.1 or v2.2.1

kuafuRace avatar Oct 31 '22 02:10 kuafuRace