🌐 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() {
|
func main() {
|
||||||
|
singleton.InitConfigFromPath("data/config.yaml")
|
||||||
singleton.InitLocalizer()
|
singleton.InitLocalizer()
|
||||||
fmt.Println(singleton.Localizer.MustLocalize(&i18n.LocalizeConfig{
|
fmt.Println(singleton.Localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||||
MessageID: "nezhaMonitor",
|
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 inverted vertical footer segment">
|
||||||
<div class="ui center aligned is-size-7 container">
|
<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"
|
<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>
|
||||||
</div>
|
</div>
|
||||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.4.1/jquery.min.js"></script>
|
<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;">
|
<form id="settingForm" class="ui large form" onsubmit="return false;">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>站点标题</label>
|
<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>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>管理员列表</label>
|
<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">
|
<section class="nav-bar clearfix">
|
||||||
<figure class="logo">
|
<figure class="logo">
|
||||||
<a href="/">
|
<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>
|
||||||
<a href="/">{{.Conf.Site.Brand}}</a>
|
<a href="/">{{.Conf.Site.Brand}}</a>
|
||||||
</figure>
|
</figure>
|
||||||
@ -155,7 +155,7 @@
|
|||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<div class="footer-container">
|
<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">
|
<p>© <span id="copyright-date">
|
||||||
<script>document.getElementById('copyright-date').appendChild(document.createTextNode(new Date().getFullYear()))</script>
|
<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>
|
</span> · <a href="https://blog.jackiesung.com" target="_blank">Theme designed by Jackie Sung</a>
|
||||||
|
@ -118,7 +118,7 @@
|
|||||||
<footer>
|
<footer>
|
||||||
<div class="footer-container">
|
<div class="footer-container">
|
||||||
<div>
|
<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>
|
<p>
|
||||||
©
|
©
|
||||||
<span id="copyright-date"
|
<span id="copyright-date"
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
<footer>
|
<footer>
|
||||||
<div class="footer-container">
|
<div class="footer-container">
|
||||||
<div>
|
<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>
|
<p>
|
||||||
©<span id="copyright-date"
|
©<span id="copyright-date"
|
||||||
><script>
|
><script>
|
||||||
|
2
resource/template/theme-hotaru/home.html
vendored
2
resource/template/theme-hotaru/home.html
vendored
@ -140,7 +140,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<footer>
|
<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}}
|
{{.Version}}
|
||||||
<a href="/service">服务状态</a>
|
<a href="/service">服务状态</a>
|
||||||
<a href="/server">管理后台</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>
|
<center>
|
||||||
<p>
|
<p>
|
||||||
<a href="/"><at>{{.Title}}</at></a>
|
<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>
|
</p>
|
||||||
</center>
|
</center>
|
||||||
</div>
|
</div>
|
||||||
|
@ -11,6 +11,13 @@ var Localizer *i18n.Localizer
|
|||||||
func InitLocalizer() {
|
func InitLocalizer() {
|
||||||
bundle := i18n.NewBundle(language.Chinese)
|
bundle := i18n.NewBundle(language.Chinese)
|
||||||
bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
|
bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
|
||||||
bundle.LoadMessageFile("resource/l10n/zh-CN.toml")
|
_, err := bundle.LoadMessageFile("resource/l10n/" + Conf.Language + ".toml")
|
||||||
Localizer = i18n.NewLocalizer(bundle, "zh-CN")
|
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)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
Conf = &model.Config{}
|
|
||||||
Cache = cache.New(5*time.Minute, 10*time.Minute)
|
Cache = cache.New(5*time.Minute, 10*time.Minute)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +42,7 @@ func LoadSingleton() {
|
|||||||
|
|
||||||
// InitConfigFromPath 从给出的文件路径中加载配置
|
// InitConfigFromPath 从给出的文件路径中加载配置
|
||||||
func InitConfigFromPath(path string) {
|
func InitConfigFromPath(path string) {
|
||||||
|
Conf = &model.Config{}
|
||||||
err := Conf.Read(path)
|
err := Conf.Read(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user