Skip to content

Commit 1ac4901

Browse files
committed
embed locales and go version change
1 parent fc4038b commit 1ac4901

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module hidell
22

3-
go 1.23.1
3+
go 1.23
44

55
require (
66
github.com/fsnotify/fsnotify v1.7.0

internal/bootstrap/init.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
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
}

locales/locales.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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

0 commit comments

Comments
 (0)