diff --git a/.gitignore b/.gitignore index e55e716e..0f1147ad 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ node_modules app.ini dist *.exe +*.po~ diff --git a/frontend/frontend.go b/frontend/frontend.go index 4847e444..2f57f4ea 100644 --- a/frontend/frontend.go +++ b/frontend/frontend.go @@ -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() - } -} diff --git a/frontend/src/lib/translate/gettext.js b/frontend/src/lib/translate/gettext.js index 9ba57de2..3ae47009 100644 --- a/frontend/src/lib/translate/gettext.js +++ b/frontend/src/lib/translate/gettext.js @@ -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 diff --git a/frontend/src/locale/en/LC_MESSAGES/app.po b/frontend/src/locale/en/LC_MESSAGES/app.po index 4d6e42ab..d0a5a039 100644 --- a/frontend/src/locale/en/LC_MESSAGES/app.po +++ b/frontend/src/locale/en/LC_MESSAGES/app.po @@ -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 "" diff --git a/frontend/src/locale/zh_CN/LC_MESSAGES/app.po b/frontend/src/locale/zh_CN/LC_MESSAGES/app.po index 585f9218..5e872bb3 100644 --- a/frontend/src/locale/zh_CN/LC_MESSAGES/app.po +++ b/frontend/src/locale/zh_CN/LC_MESSAGES/app.po @@ -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 HTTPChallengePort (default: 9180) before getting " "the certificate." msgstr "" -"在获取签发证书前,请确保配置文件中已将 .well-known 目录反向代" -"理到HTTPChallengePort (默认: 9180)" +"在获取签发证书前,请确保配置文件中已将 .well-known 目录反向代理" +"到HTTPChallengePort (默认: 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个月,则将自动续签。" "
如果您之前没有证书,请先点击 \"从 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" diff --git a/frontend/src/locale/zh_TW/LC_MESSAGES/app.po b/frontend/src/locale/zh_TW/LC_MESSAGES/app.po index 68e1734c..140b9643 100644 --- a/frontend/src/locale/zh_TW/LC_MESSAGES/app.po +++ b/frontend/src/locale/zh_TW/LC_MESSAGES/app.po @@ -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 "" diff --git a/frontend/src/main.js b/frontend/src/main.js index 7db0bdea..00c6d376 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -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, diff --git a/frontend/src/translations.json b/frontend/src/translations.json new file mode 100644 index 00000000..f4e87263 --- /dev/null +++ b/frontend/src/translations.json @@ -0,0 +1 @@ +{"en":{},"zh_CN":{"404 Not Found":"404 未找到页面","About":"关于","Action":"操作","Add Site":"添加站点","Add site here first, then you can configure TLS on the domain edit page.":"在这里添加站点,完成后可进入编辑页面配置 TLS。","Auto-renewal disabled for %{name}":"成功关闭 %{name} 自动续签","Auto-renewal enabled for %{name}":"成功启用 %{name} 自动续签","Build with":"构建基于","Cancel":"取消","Certificate Auto-renewal":"证书自动续签","Certificate has expired":"此证书已过期","Certificate is valid":"此证书有效","Certificate Path (ssl_certificate)":"TLS 证书路径 (ssl_certificate)","Certificate Status":"证书状态","Configuration Name":"配置名称","Configurations":"配置","Created at":"创建时间","Dashboard":"仪表盘","Database (Optional, default: database)":"数据库 (可选,默认: database)","Detected version update, this page will refresh.":"检测到版本更新,页面将会刷新。","Development Mode":"开发模式","Disable auto-renewal failed for %{name}":"关闭 %{name} 自动续签失败","Disabled":"禁用","Disabled successfully":"禁用成功","Do you want to change the template to support the TLS?":"你想要改变模板以支持 TLS 吗?","Edit %{n}":"编辑 %{n}","Edit Configuration":"编辑配置","Edit Configuration File":"编辑配置文件","Edit Site":"编辑站点","Email (*)":"邮箱 (*)","Enable auto-renewal failed for %{name}":"启用 %{name} 自动续签失败","Enable failed":"启用失败","Enable TLS":"启用 TLS","Enabled":"启用","Enabled successfully":"启用成功","Expiration Date: %{date}":"过期时间: %{date}","Failed to disable %{msg}":"禁用失败 %{msg}","Failed to enable %{msg}":"启用失败 %{msg}","File Not Found":"未找到文件","Getting Certificate from Let's Encrypt":"从 Let's Encrypt 获取证书","Getting the certificate, please wait...":"正在获取证书,请稍等...","Home":"首页","HTTP Listen Port":"HTTP 监听端口","HTTPS Listen Port":"HTTPS 监听端口","Index (index)":"网站首页 (index)","Install":"安装","Intermediate Certification Authorities: %{issuer}":"中级证书颁发机构: %{issuer}","Invalid E-mail!":"无效的邮箱!","Leave blank for no change":"留空表示不修改","License":{"Project":"开源许可"},"Load Averages:":"系统负载:","Login":"登录","Login successful":"登录成功","Logout successful":"登出成功","Make sure you have configured a reverse proxy for .well-known directory to HTTPChallengePort (default: 9180) before getting the certificate.":"在获取签发证书前,请确保配置文件中已将 .well-known 目录反向代理到HTTPChallengePort (默认: 9180)","Manage Configs":"配置管理","Manage Sites":"网站管理","Manage Users":"用户管理","Memory":"内存","Name":"名称","Not Found":"找不到页面","Not Valid Before: %{date}":"此前无效: %{date}","Note: The server_name in the current configuration must be the domain name you need to get the certificate.":"注意:当前配置中的 server_name 必须为需要申请证书的域名。","OK":"确定","Password":"密码","Password (*)":"密码 (*)","Please input your E-mail!":"请输入您的邮箱!","Please input your password!":"请输入您的密码!","Please input your username!":"请输入您的用户名!","Private Key Path (ssl_certificate_key)":"私钥路径 (ssl_certificate_key)","Project Team":"项目团队","Root Directory (root)":"网站根目录 (root)","Save":"保存","Save error %{msg}":"保存错误 %{msg}","Saved successfully":"保存成功","Server error":"服务器错误","Server Names (server_name)":"网站域名 (server_name)","Server Status":"服务器状态","Sites List":"站点列表","Status":"状态","Storage":"存储","Subject Name: %{name}":"主体名称: %{name}","System message":"系统消息","The certificate for the domain will be checked every hour, and will be renewed if it has been more than 1 month since it was last issued.
If you do not have a certificate before, please click \"Getting Certificate from Let's Encrypt\" first.":"系统将会每小时检测一次该域名证书,若距离上次签发已超过1个月,则将自动续签。
如果您之前没有证书,请先点击 \"从 Let's Encrypt 获取证书\"。","The filename cannot contain the following characters: %{c}":"文件名不能包含以下字符: %{c}","The following values will only take effect if you have the corresponding fields in your configuration file. The configuration filename cannot be changed after it has been created.":"只有在您的配置文件中有相应字段时,下列的配置才能生效。配置文件名称创建后不可修改。","This operation will lose the custom configuration.":"该操作将会丢失自定义配置。","Updated at":"修改时间","Uptime":"运行时间","Used: %{u}, Cached: %{c}, Free: %{f}, Physical Memory: %{p}":"已使用: %{u}, 缓存: %{c}, 空闲: %{f}, 物理内存: %{p}","Used: %{used} / Total: %{total}":"已使用: %{used} / 总共: %{total}","Username":"用户名","Username (*)":"用户名 (*)"},"zh_TW":{}} \ No newline at end of file diff --git a/frontend/version.json b/frontend/version.json index 3b5d51be..c78554d6 100644 --- a/frontend/version.json +++ b/frontend/version.json @@ -1 +1 @@ -{"version":"1.1.0","build_id":22,"total_build":39} \ No newline at end of file +{"version":"1.1.0","build_id":23,"total_build":40} \ No newline at end of file diff --git a/main.go b/main.go index 3d40d4c7..9954b570 100644 --- a/main.go +++ b/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, diff --git a/server/api/translations.go b/server/api/translations.go deleted file mode 100644 index 0e044eda..00000000 --- a/server/api/translations.go +++ /dev/null @@ -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) -} diff --git a/server/router/routers.go b/server/router/routers.go index a9994da5..7f2885f3 100644 --- a/server/router/routers.go +++ b/server/router/routers.go @@ -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)