🌐 localization [skip ci]

This commit is contained in:
naiba
2022-04-27 23:51:45 +08:00
parent 0a6658fcb4
commit 7bd67b2233
15 changed files with 92 additions and 34 deletions

16
service/singleton/l10n.go Normal file
View File

@@ -0,0 +1,16 @@
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)
bundle.LoadMessageFile("resource/l10n/zh-CN.toml")
Localizer = i18n.NewLocalizer(bundle, "zh-CN")
}