Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to read language.json file #139

Closed
lixh00 opened this issue Jun 14, 2022 · 3 comments
Closed

Unable to read language.json file #139

lixh00 opened this issue Jun 14, 2022 · 3 comments
Labels
Bug Report a reproducible bug or regression

Comments

@lixh00
Copy link

lixh00 commented Jun 14, 2022

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 lixh00 added the Bug Report a reproducible bug or regression label Jun 14, 2022
@Issues-translate-bot Issues-translate-bot changed the title Unable to read language.json file | 无法读取language.json文件 Unable to read language.json file | Unable to read language.json file Jun 14, 2022
@lixh00 lixh00 changed the title Unable to read language.json file | Unable to read language.json file Unable to read language.json file Jun 14, 2022
@gouguoyin
Copy link
Collaborator

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

@chanyipiaomiao
Copy link

chanyipiaomiao commented Jun 18, 2022

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

@gouguoyin
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report a reproducible bug or regression
Projects
None yet
Development

No branches or pull requests

3 participants