🌐 i18n config file [skip ci]

This commit is contained in:
naiba
2022-04-28 10:17:38 +08:00
parent 3e5c3c64d0
commit 3d2d116100
10 changed files with 19 additions and 11 deletions

View File

@@ -11,6 +11,13 @@ var Localizer *i18n.Localizer
func InitLocalizer() {
bundle := i18n.NewBundle(language.Chinese)
bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
bundle.LoadMessageFile("resource/l10n/zh-CN.toml")
Localizer = i18n.NewLocalizer(bundle, "zh-CN")
_, err := bundle.LoadMessageFile("resource/l10n/" + Conf.Language + ".toml")
if err != nil {
panic(err)
}
_, err = bundle.LoadMessageFile("resource/l10n/zh-CN.toml")
if err != nil {
panic(err)
}
Localizer = i18n.NewLocalizer(bundle, Conf.Language)
}

View File

@@ -30,7 +30,6 @@ func Init() {
panic(err)
}
Conf = &model.Config{}
Cache = cache.New(5*time.Minute, 10*time.Minute)
}
@@ -43,6 +42,7 @@ func LoadSingleton() {
// InitConfigFromPath 从给出的文件路径中加载配置
func InitConfigFromPath(path string) {
Conf = &model.Config{}
err := Conf.Read(path)
if err != nil {
panic(err)