mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
make translations in frontend
This commit is contained in:
parent
584cbd745c
commit
f097acb3e9
12 changed files with 53 additions and 95 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ node_modules
|
|||
app.ini
|
||||
dist
|
||||
*.exe
|
||||
*.po~
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {translate} from 'vue-gettext'
|
||||
import store from '@/lib/store'
|
||||
import {availableLanguages} from '@/lib/translate/index'
|
||||
import translations from '@/translations.json'
|
||||
|
||||
let lang = window.navigator.language.replace('-', '_')
|
||||
if(availableLanguages[lang] === undefined) {
|
||||
|
@ -23,6 +24,6 @@ export const {
|
|||
gettext: $gettext, gettextInterpolate: $interpolate
|
||||
} = translate
|
||||
|
||||
translate.initTranslations(store.state.settings.translations, config)
|
||||
translate.initTranslations(translations, config)
|
||||
|
||||
export default $gettext
|
||||
|
|
|
@ -77,10 +77,6 @@ msgstr ""
|
|||
msgid "Configurations"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/dashboard/DashBoard.vue:52
|
||||
msgid "CPU"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/user/User.vue:23
|
||||
msgid "Created at"
|
||||
msgstr ""
|
||||
|
@ -89,7 +85,7 @@ msgstr ""
|
|||
msgid "Dashboard"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:104
|
||||
#: src/views/other/Install.vue:105
|
||||
msgid "Database (Optional, default: database)"
|
||||
msgstr ""
|
||||
|
||||
|
@ -134,7 +130,7 @@ msgstr ""
|
|||
msgid "Edit Site"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:30
|
||||
#: src/views/other/Install.vue:31
|
||||
msgid "Email (*)"
|
||||
msgstr ""
|
||||
|
||||
|
@ -207,7 +203,7 @@ msgstr ""
|
|||
msgid "Intermediate Certification Authorities: %{issuer}"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:45
|
||||
#: src/views/other/Install.vue:46
|
||||
msgid "Invalid E-mail!"
|
||||
msgstr ""
|
||||
|
||||
|
@ -228,7 +224,7 @@ msgstr ""
|
|||
msgid "Login"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Login.vue:28
|
||||
#: src/views/other/Login.vue:30
|
||||
msgid "Login successful"
|
||||
msgstr ""
|
||||
|
||||
|
@ -281,23 +277,23 @@ msgstr ""
|
|||
msgid "OK"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Login.vue:55 src/views/user/User.vue:13
|
||||
#: src/views/other/Login.vue:56 src/views/user/User.vue:13
|
||||
msgid "Password"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:82
|
||||
#: src/views/other/Install.vue:83
|
||||
msgid "Password (*)"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:49
|
||||
#: src/views/other/Install.vue:50
|
||||
msgid "Please input your E-mail!"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:95 src/views/other/Login.vue:68
|
||||
#: src/views/other/Install.vue:96 src/views/other/Login.vue:69
|
||||
msgid "Please input your password!"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:72 src/views/other/Login.vue:45
|
||||
#: src/views/other/Install.vue:73 src/views/other/Login.vue:46
|
||||
msgid "Please input your username!"
|
||||
msgstr ""
|
||||
|
||||
|
@ -329,7 +325,7 @@ msgid "Saved successfully"
|
|||
msgstr ""
|
||||
|
||||
#: src/views/config/ConfigEdit.vue:35 src/views/domain/DomainEdit.vue:71
|
||||
#: src/views/other/Login.vue:33
|
||||
#: src/views/other/Login.vue:35
|
||||
msgid "Server error"
|
||||
msgstr ""
|
||||
|
||||
|
@ -369,7 +365,7 @@ msgid ""
|
|||
"from Let's Encrypt\" first."
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:119
|
||||
#: src/views/other/Install.vue:120
|
||||
msgid "The filename cannot contain the following characters: %{c}"
|
||||
msgstr ""
|
||||
|
||||
|
@ -401,10 +397,10 @@ msgstr ""
|
|||
msgid "Used: %{used} / Total: %{total}"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Login.vue:32 src/views/user/User.vue:5
|
||||
#: src/views/other/Login.vue:33 src/views/user/User.vue:5
|
||||
msgid "Username"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:59
|
||||
#: src/views/other/Install.vue:60
|
||||
msgid "Username (*)"
|
||||
msgstr ""
|
||||
|
|
|
@ -79,10 +79,6 @@ msgstr "配置名称"
|
|||
msgid "Configurations"
|
||||
msgstr "配置"
|
||||
|
||||
#: src/views/dashboard/DashBoard.vue:52
|
||||
msgid "CPU"
|
||||
msgstr "CPU"
|
||||
|
||||
#: src/views/user/User.vue:23
|
||||
msgid "Created at"
|
||||
msgstr "创建时间"
|
||||
|
@ -91,7 +87,7 @@ msgstr "创建时间"
|
|||
msgid "Dashboard"
|
||||
msgstr "仪表盘"
|
||||
|
||||
#: src/views/other/Install.vue:104
|
||||
#: src/views/other/Install.vue:105
|
||||
msgid "Database (Optional, default: database)"
|
||||
msgstr "数据库 (可选,默认: database)"
|
||||
|
||||
|
@ -136,7 +132,7 @@ msgstr "编辑配置文件"
|
|||
msgid "Edit Site"
|
||||
msgstr "编辑站点"
|
||||
|
||||
#: src/views/other/Install.vue:30
|
||||
#: src/views/other/Install.vue:31
|
||||
msgid "Email (*)"
|
||||
msgstr "邮箱 (*)"
|
||||
|
||||
|
@ -209,7 +205,7 @@ msgstr "安装"
|
|||
msgid "Intermediate Certification Authorities: %{issuer}"
|
||||
msgstr "中级证书颁发机构: %{issuer}"
|
||||
|
||||
#: src/views/other/Install.vue:45
|
||||
#: src/views/other/Install.vue:46
|
||||
msgid "Invalid E-mail!"
|
||||
msgstr "无效的邮箱!"
|
||||
|
||||
|
@ -230,7 +226,7 @@ msgstr "系统负载:"
|
|||
msgid "Login"
|
||||
msgstr "登录"
|
||||
|
||||
#: src/views/other/Login.vue:28
|
||||
#: src/views/other/Login.vue:30
|
||||
msgid "Login successful"
|
||||
msgstr "登录成功"
|
||||
|
||||
|
@ -244,8 +240,8 @@ msgid ""
|
|||
"directory to <code>HTTPChallengePort</code> (default: 9180) before getting "
|
||||
"the certificate."
|
||||
msgstr ""
|
||||
"在获取签发证书前,请确保配置文件中已将 <code>.well-known</code> 目录反向代"
|
||||
"理到<code>HTTPChallengePort</code> (默认: 9180)"
|
||||
"在获取签发证书前,请确保配置文件中已将 <code>.well-known</code> 目录反向代理"
|
||||
"到<code>HTTPChallengePort</code> (默认: 9180)"
|
||||
|
||||
#: src/router/index.js:60
|
||||
msgid "Manage Configs"
|
||||
|
@ -285,23 +281,23 @@ msgstr "注意:当前配置中的 server_name 必须为需要申请证书的
|
|||
msgid "OK"
|
||||
msgstr "确定"
|
||||
|
||||
#: src/views/other/Login.vue:55 src/views/user/User.vue:13
|
||||
#: src/views/other/Login.vue:56 src/views/user/User.vue:13
|
||||
msgid "Password"
|
||||
msgstr "密码"
|
||||
|
||||
#: src/views/other/Install.vue:82
|
||||
#: src/views/other/Install.vue:83
|
||||
msgid "Password (*)"
|
||||
msgstr "密码 (*)"
|
||||
|
||||
#: src/views/other/Install.vue:49
|
||||
#: src/views/other/Install.vue:50
|
||||
msgid "Please input your E-mail!"
|
||||
msgstr "请输入您的邮箱!"
|
||||
|
||||
#: src/views/other/Install.vue:95 src/views/other/Login.vue:68
|
||||
#: src/views/other/Install.vue:96 src/views/other/Login.vue:69
|
||||
msgid "Please input your password!"
|
||||
msgstr "请输入您的密码!"
|
||||
|
||||
#: src/views/other/Install.vue:72 src/views/other/Login.vue:45
|
||||
#: src/views/other/Install.vue:73 src/views/other/Login.vue:46
|
||||
msgid "Please input your username!"
|
||||
msgstr "请输入您的用户名!"
|
||||
|
||||
|
@ -333,7 +329,7 @@ msgid "Saved successfully"
|
|||
msgstr "保存成功"
|
||||
|
||||
#: src/views/config/ConfigEdit.vue:35 src/views/domain/DomainEdit.vue:71
|
||||
#: src/views/other/Login.vue:33
|
||||
#: src/views/other/Login.vue:35
|
||||
msgid "Server error"
|
||||
msgstr "服务器错误"
|
||||
|
||||
|
@ -375,7 +371,7 @@ msgstr ""
|
|||
"系统将会每小时检测一次该域名证书,若距离上次签发已超过1个月,则将自动续签。"
|
||||
"<br/>如果您之前没有证书,请先点击 \"从 Let's Encrypt 获取证书\"。"
|
||||
|
||||
#: src/views/other/Install.vue:119
|
||||
#: src/views/other/Install.vue:120
|
||||
msgid "The filename cannot contain the following characters: %{c}"
|
||||
msgstr "文件名不能包含以下字符: %{c}"
|
||||
|
||||
|
@ -385,8 +381,8 @@ msgid ""
|
|||
"fields in your configuration file. The configuration filename cannot be "
|
||||
"changed after it has been created."
|
||||
msgstr ""
|
||||
"只有在您的配置文件中有相应字段时,下列的配置才能生效。配置文件名称创建后不"
|
||||
"可修改。"
|
||||
"只有在您的配置文件中有相应字段时,下列的配置才能生效。配置文件名称创建后不可"
|
||||
"修改。"
|
||||
|
||||
#: src/views/domain/DomainEdit.vue:134
|
||||
msgid "This operation will lose the custom configuration."
|
||||
|
@ -409,10 +405,13 @@ msgstr "已使用: %{u}, 缓存: %{c}, 空闲: %{f}, 物理内存: %{p}"
|
|||
msgid "Used: %{used} / Total: %{total}"
|
||||
msgstr "已使用: %{used} / 总共: %{total}"
|
||||
|
||||
#: src/views/other/Login.vue:32 src/views/user/User.vue:5
|
||||
#: src/views/other/Login.vue:33 src/views/user/User.vue:5
|
||||
msgid "Username"
|
||||
msgstr "用户名"
|
||||
|
||||
#: src/views/other/Install.vue:59
|
||||
#: src/views/other/Install.vue:60
|
||||
msgid "Username (*)"
|
||||
msgstr "用户名 (*)"
|
||||
|
||||
#~ msgid "CPU"
|
||||
#~ msgstr "CPU"
|
||||
|
|
|
@ -76,10 +76,6 @@ msgstr ""
|
|||
msgid "Configurations"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/dashboard/DashBoard.vue:52
|
||||
msgid "CPU"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/user/User.vue:23
|
||||
msgid "Created at"
|
||||
msgstr ""
|
||||
|
@ -88,7 +84,7 @@ msgstr ""
|
|||
msgid "Dashboard"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:104
|
||||
#: src/views/other/Install.vue:105
|
||||
msgid "Database (Optional, default: database)"
|
||||
msgstr ""
|
||||
|
||||
|
@ -133,7 +129,7 @@ msgstr ""
|
|||
msgid "Edit Site"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:30
|
||||
#: src/views/other/Install.vue:31
|
||||
msgid "Email (*)"
|
||||
msgstr ""
|
||||
|
||||
|
@ -206,7 +202,7 @@ msgstr ""
|
|||
msgid "Intermediate Certification Authorities: %{issuer}"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:45
|
||||
#: src/views/other/Install.vue:46
|
||||
msgid "Invalid E-mail!"
|
||||
msgstr ""
|
||||
|
||||
|
@ -227,7 +223,7 @@ msgstr ""
|
|||
msgid "Login"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Login.vue:28
|
||||
#: src/views/other/Login.vue:30
|
||||
msgid "Login successful"
|
||||
msgstr ""
|
||||
|
||||
|
@ -280,23 +276,23 @@ msgstr ""
|
|||
msgid "OK"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Login.vue:55 src/views/user/User.vue:13
|
||||
#: src/views/other/Login.vue:56 src/views/user/User.vue:13
|
||||
msgid "Password"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:82
|
||||
#: src/views/other/Install.vue:83
|
||||
msgid "Password (*)"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:49
|
||||
#: src/views/other/Install.vue:50
|
||||
msgid "Please input your E-mail!"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:95 src/views/other/Login.vue:68
|
||||
#: src/views/other/Install.vue:96 src/views/other/Login.vue:69
|
||||
msgid "Please input your password!"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:72 src/views/other/Login.vue:45
|
||||
#: src/views/other/Install.vue:73 src/views/other/Login.vue:46
|
||||
msgid "Please input your username!"
|
||||
msgstr ""
|
||||
|
||||
|
@ -328,7 +324,7 @@ msgid "Saved successfully"
|
|||
msgstr ""
|
||||
|
||||
#: src/views/config/ConfigEdit.vue:35 src/views/domain/DomainEdit.vue:71
|
||||
#: src/views/other/Login.vue:33
|
||||
#: src/views/other/Login.vue:35
|
||||
msgid "Server error"
|
||||
msgstr ""
|
||||
|
||||
|
@ -368,7 +364,7 @@ msgid ""
|
|||
"from Let's Encrypt\" first."
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:119
|
||||
#: src/views/other/Install.vue:120
|
||||
msgid "The filename cannot contain the following characters: %{c}"
|
||||
msgstr ""
|
||||
|
||||
|
@ -400,10 +396,10 @@ msgstr ""
|
|||
msgid "Used: %{used} / Total: %{total}"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Login.vue:32 src/views/user/User.vue:5
|
||||
#: src/views/other/Login.vue:33 src/views/user/User.vue:5
|
||||
msgid "Username"
|
||||
msgstr ""
|
||||
|
||||
#: src/views/other/Install.vue:59
|
||||
#: src/views/other/Install.vue:60
|
||||
msgid "Username (*)"
|
||||
msgstr ""
|
||||
|
|
|
@ -11,7 +11,7 @@ import utils from '@/lib/utils'
|
|||
import api from '@/api'
|
||||
import GetTextPlugin from 'vue-gettext'
|
||||
import {availableLanguages} from '@/lib/translate'
|
||||
import http from '@/lib/http'
|
||||
import translations from '@/translations.json'
|
||||
|
||||
Vue.use(utils)
|
||||
|
||||
|
@ -23,14 +23,10 @@ Vue.prototype.$api = api
|
|||
Vue.use(GetTextPlugin, {
|
||||
availableLanguages,
|
||||
defaultLanguage: store.getters.current_language,
|
||||
translations: store.state.settings.translations,
|
||||
translations: translations,
|
||||
silent: true
|
||||
})
|
||||
|
||||
http.get('/translations.json').then(r => {
|
||||
if(r) store.commit('update_translations', r)
|
||||
})
|
||||
|
||||
NProgress.configure({
|
||||
easing: 'ease',
|
||||
speed: 500,
|
||||
|
|
1
frontend/src/translations.json
Normal file
1
frontend/src/translations.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
{"version":"1.1.0","build_id":22,"total_build":39}
|
||||
{"version":"1.1.0","build_id":23,"total_build":40}
|
2
main.go
2
main.go
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"github.com/0xJacky/Nginx-UI/frontend"
|
||||
"github.com/0xJacky/Nginx-UI/server/model"
|
||||
"github.com/0xJacky/Nginx-UI/server/router"
|
||||
"github.com/0xJacky/Nginx-UI/server/settings"
|
||||
|
@ -35,7 +34,6 @@ func main() {
|
|||
model.Init()
|
||||
go tool2.AutoCert()
|
||||
}
|
||||
frontend.InitTranslations()
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: ":" + settings.ServerSettings.HttpPort,
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/frontend"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetTranslations(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, frontend.Translations)
|
||||
}
|
|
@ -29,7 +29,6 @@ func InitRouter() *gin.Engine {
|
|||
|
||||
g := r.Group("/api")
|
||||
{
|
||||
g.GET("translations.json", api.GetTranslations)
|
||||
g.GET("install", api.InstallLockCheck)
|
||||
g.POST("install", api.InstallNginxUI)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue