🌐 i18n config file [skip ci]
This commit is contained in:
parent
3e5c3c64d0
commit
3d2d116100
@ -17,6 +17,7 @@ func htmlTemplateTranslateFn(id string, data interface{}, count interface{}) str
|
||||
}
|
||||
|
||||
func main() {
|
||||
singleton.InitConfigFromPath("data/config.yaml")
|
||||
singleton.InitLocalizer()
|
||||
fmt.Println(singleton.Localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: "nezhaMonitor",
|
||||
|
2
resource/template/common/footer.html
vendored
2
resource/template/common/footer.html
vendored
@ -2,7 +2,7 @@
|
||||
<div class="ui inverted vertical footer segment">
|
||||
<div class="ui center aligned is-size-7 container">
|
||||
<b>© <a style="color: white;" href="/">{{.Conf.Site.Brand}}</a></b> | <small>Powered by <a href="https://github.com/naiba/nezha"
|
||||
style="color: white;" target="_blank">{{tr "nezhaMonitor" nil nil}}</a> {{.Version}}</small>
|
||||
style="color: white;" target="_blank">{{tr "nezhaMonitor"}}</a> {{.Version}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.4.1/jquery.min.js"></script>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<form id="settingForm" class="ui large form" onsubmit="return false;">
|
||||
<div class="field">
|
||||
<label>站点标题</label>
|
||||
<input type="text" name="Title" placeholder="{{tr "nezhaMonitor" nil nil}}" value="{{.Conf.Site.Brand}}">
|
||||
<input type="text" name="Title" placeholder="{{tr "nezhaMonitor"}}" value="{{.Conf.Site.Brand}}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>管理员列表</label>
|
||||
|
4
resource/template/theme-daynight/home.html
vendored
4
resource/template/theme-daynight/home.html
vendored
@ -23,7 +23,7 @@
|
||||
<section class="nav-bar clearfix">
|
||||
<figure class="logo">
|
||||
<a href="/">
|
||||
<img src="/static/logo.svg?v20210804" alt="{{tr "nezhaMonitor" nil nil}}" width="50" height="50">
|
||||
<img src="/static/logo.svg?v20210804" alt="{{tr "nezhaMonitor"}}" width="50" height="50">
|
||||
</a>
|
||||
<a href="/">{{.Conf.Site.Brand}}</a>
|
||||
</figure>
|
||||
@ -155,7 +155,7 @@
|
||||
|
||||
<footer>
|
||||
<div class="footer-container">
|
||||
<div><a href="https://github.com/naiba/nezha" target="_blank">Powered by {{tr "nezhaMonitor" nil nil}} · {{.Version}}</a>
|
||||
<div><a href="https://github.com/naiba/nezha" target="_blank">Powered by {{tr "nezhaMonitor"}} · {{.Version}}</a>
|
||||
<p>© <span id="copyright-date">
|
||||
<script>document.getElementById('copyright-date').appendChild(document.createTextNode(new Date().getFullYear()))</script>
|
||||
</span> · <a href="https://blog.jackiesung.com" target="_blank">Theme designed by Jackie Sung</a>
|
||||
|
@ -118,7 +118,7 @@
|
||||
<footer>
|
||||
<div class="footer-container">
|
||||
<div>
|
||||
<a href="https://github.com/naiba/nezha" target="_blank">Powered by {{tr "nezhaMonitor" nil nil}} · {{.Version}}</a>
|
||||
<a href="https://github.com/naiba/nezha" target="_blank">Powered by {{tr "nezhaMonitor"}} · {{.Version}}</a>
|
||||
<p>
|
||||
©
|
||||
<span id="copyright-date"
|
||||
|
@ -42,7 +42,7 @@
|
||||
<footer>
|
||||
<div class="footer-container">
|
||||
<div>
|
||||
<a href="https://github.com/naiba/nezha" target="_blank">Powered by {{tr "nezhaMonitor" nil nil}} · {{.Version}}</a>
|
||||
<a href="https://github.com/naiba/nezha" target="_blank">Powered by {{tr "nezhaMonitor"}} · {{.Version}}</a>
|
||||
<p>
|
||||
©<span id="copyright-date"
|
||||
><script>
|
||||
|
2
resource/template/theme-hotaru/home.html
vendored
2
resource/template/theme-hotaru/home.html
vendored
@ -140,7 +140,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
<footer>
|
||||
<p style="text-align:center;padding: 15px;">Powered by <a href="https://github.com/naiba/nezha">{{tr "nezhaMonitor" nil nil}}</a> build ·
|
||||
<p style="text-align:center;padding: 15px;">Powered by <a href="https://github.com/naiba/nezha">{{tr "nezhaMonitor"}}</a> build ·
|
||||
{{.Version}}
|
||||
<a href="/service">服务状态</a>
|
||||
<a href="/server">管理后台</a>
|
||||
|
2
resource/template/theme-mdui/footer.html
vendored
2
resource/template/theme-mdui/footer.html
vendored
@ -5,7 +5,7 @@
|
||||
<center>
|
||||
<p>
|
||||
<a href="/"><at>{{.Title}}</at></a>
|
||||
Powered by <a href="https://github.com/naiba/nezha"><st>{{tr "nezhaMonitor" nil nil}}<{{.Version}}></st></a> | Theme designed by Mikoy Chinese
|
||||
Powered by <a href="https://github.com/naiba/nezha"><st>{{tr "nezhaMonitor"}}<{{.Version}}></st></a> | Theme designed by Mikoy Chinese
|
||||
</p>
|
||||
</center>
|
||||
</div>
|
||||
|
@ -11,6 +11,13 @@ 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")
|
||||
_, 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)
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ func Init() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Conf = &model.Config{}
|
||||
Cache = cache.New(5*time.Minute, 10*time.Minute)
|
||||
}
|
||||
|
||||
@ -43,6 +42,7 @@ func LoadSingleton() {
|
||||
|
||||
// InitConfigFromPath 从给出的文件路径中加载配置
|
||||
func InitConfigFromPath(path string) {
|
||||
Conf = &model.Config{}
|
||||
err := Conf.Read(path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
Loading…
Reference in New Issue
Block a user