make translations in frontend

This commit is contained in:
0xJacky 2022-02-21 00:32:56 +08:00
parent 584cbd745c
commit f097acb3e9
12 changed files with 53 additions and 95 deletions

View file

@ -2,25 +2,7 @@ package frontend
import (
"embed"
"github.com/0xJacky/pofile"
"log"
"path"
)
//go:embed dist
var DistFS embed.FS
var Translations pofile.Dict
func InitTranslations() {
lang := []string{"zh_CN", "zh_TW", "en"}
Translations = make(pofile.Dict)
for _, v := range lang {
p, err := pofile.Parse(path.Join("frontend", "src", "locale", v, "LC_MESSAGES", "app.po"))
if err != nil {
log.Fatalln(err)
}
Translations[p.Header.Language] = make(pofile.Dict)
Translations[p.Header.Language] = p.ToDict()
}
}