nezha/service/singleton/l10n.go

24 lines
545 B
Go
Raw Normal View History

2022-04-27 11:51:45 -04:00
package singleton
import (
"github.com/BurntSushi/toml"
"github.com/nicksnyder/go-i18n/v2/i18n"
"golang.org/x/text/language"
)
var Localizer *i18n.Localizer
func InitLocalizer() {
bundle := i18n.NewBundle(language.Chinese)
bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
2022-04-27 22:17:38 -04:00
_, 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)
2022-04-27 11:51:45 -04:00
}