File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 11module hidell
22
3- go 1.23.1
3+ go 1.23
44
55require (
66 github.com/fsnotify/fsnotify v1.7.0
Original file line number Diff line number Diff line change 55 "hidell/configs"
66 "hidell/internal/base"
77 "hidell/internal/global"
8+ "hidell/locales"
89 "os"
910 "path/filepath"
1011)
@@ -59,13 +60,14 @@ func i18n() {
5960
6061 languages := []string {"en" , "zh" }
6162 for _ , lang := range languages {
62- file , err := os .ReadFile ("locales/" + lang + ".json" )
63- if err != nil {
64- panic (err )
63+
64+ file := locales .En
65+ if lang == "zh" {
66+ file = locales .ZH
6567 }
6668
6769 var langTranslations map [string ]string
68- err = json .Unmarshal (file , & langTranslations )
70+ err : = json .Unmarshal (file , & langTranslations )
6971 if err != nil {
7072 panic (err )
7173 }
Original file line number Diff line number Diff line change 1+ package locales
2+
3+ import _ "embed"
4+
5+ //go:embed en.json
6+ var En []byte
7+
8+ //go:embed zh.json
9+ var ZH []byte
You can’t perform that action at this time.
0 commit comments