Update command.go

load i18n langs config
This commit is contained in:
Ben Stone
2021-03-29 18:00:24 +08:00
committed by GitHub
parent 0694b4554b
commit 53310d4289

View File

@@ -23,6 +23,7 @@ import (
_ "github.com/astaxie/beego/cache/redis"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
"github.com/beego/i18n"
"github.com/howeyc/fsnotify"
"github.com/lifei6671/gocaptcha"
"github.com/mindoc-org/mindoc/cache"
@@ -277,6 +278,19 @@ func RegisterFunction() {
beego.Error("注册函数 date_format 出错 ->", err)
os.Exit(-1)
}
err = beego.AddFuncMap("i18n", i18n.Tr)
if err != nil {
beego.Error("注册函数 i18n 出错 ->", err)
os.Exit(-1)
}
langs := strings.Split("en-us|zh-cn", "|")
for _, lang := range langs {
if err := i18n.SetMessage(lang, "conf/lang/" + lang + ".ini"); err != nil {
beego.Error("Fail to set message file: " + err.Error())
return
}
}
}
//解析命令