mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-12 10:55:51 +02:00
make translations in frontend
This commit is contained in:
parent
584cbd745c
commit
f097acb3e9
12 changed files with 53 additions and 95 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue