From c53f5f9c49ef8a2b9fa7de4f1c172af6a18c6af9 Mon Sep 17 00:00:00 2001 From: umbor <14857490+umbors@users.noreply.github.com> Date: Sat, 10 Jun 2023 23:16:51 +0800 Subject: [PATCH 1/7] Add i18n basic components Add i18n basic components --- webui/package.json | 2 + webui/src/locales/index.ts | 13 +++ webui/src/locales/lang/en.yaml | 127 ++++++++++++++++++++++++++++++ webui/src/locales/lang/zh-CN.yaml | 126 +++++++++++++++++++++++++++++ webui/src/main.ts | 2 + webui/vite.config.ts | 5 ++ 6 files changed, 275 insertions(+) create mode 100644 webui/src/locales/index.ts create mode 100644 webui/src/locales/lang/en.yaml create mode 100644 webui/src/locales/lang/zh-CN.yaml diff --git a/webui/package.json b/webui/package.json index b2b1258a..b49ccc44 100644 --- a/webui/package.json +++ b/webui/package.json @@ -23,11 +23,13 @@ "naive-ui": "^2.34.4", "pinia": "^2.1.3", "vue": "^3.3.4", + "vue-i18n": "^9.3.0-beta.19", "vue-router": "^4.2.1" }, "devDependencies": { "@antfu/eslint-config": "^0.38.6", "@icon-park/vue-next": "^1.4.2", + "@intlify/unplugin-vue-i18n": "^0.11.0", "@storybook/addon-essentials": "^7.0.12", "@storybook/addon-interactions": "^7.0.12", "@storybook/addon-links": "^7.0.12", diff --git a/webui/src/locales/index.ts b/webui/src/locales/index.ts new file mode 100644 index 00000000..cb6d0b77 --- /dev/null +++ b/webui/src/locales/index.ts @@ -0,0 +1,13 @@ +import { createI18n } from 'vue-i18n'; +import messages from '@intlify/unplugin-vue-i18n/messages' + +const i18n = createI18n({ + legacy: false, + locale: 'zh-CN', + globalInjection: true, + silentTranslationWarn: true, + globalInstall: true, + messages + }) + +export default i18n; \ No newline at end of file diff --git a/webui/src/locales/lang/en.yaml b/webui/src/locales/lang/en.yaml new file mode 100644 index 00000000..e23fcf00 --- /dev/null +++ b/webui/src/locales/lang/en.yaml @@ -0,0 +1,127 @@ +login: + title: 'Login' + username: 'Username' + password: 'Password' + loginbtn: 'Login' + default: 'Default' + +sidebar: + title: 'Menu' + homepage: 'HomePage' + player: 'Player' + log: 'Log' + config: 'Config' + logout: 'Logout' + +topbar: + start: 'Start' + pause: 'Pause' + restart: 'Restart' + shutdown: 'Shutdown' + resetrule: 'Reset Rule' + + profile: + title: 'Profile' + poptitle: 'Change Account' + username: 'Username' + password: 'Password' + updatebtn: 'Update' + + add: + title: 'Add Bangumi' + rsslink: 'RSS Link' + placeholder: 'Please enter the RSS link' + analyse: 'Analyse' + +homepage: + title: 'Bangumi List' + rule: + officaltitle: 'Official Title' + year: 'Year' + season: 'Season' + offset: 'Offset' + exclude: 'Exclude' + enable: 'Enable' + disable: 'Disable' + delete: 'Delete' + apply: 'Apply' + yesbtn: 'Yes' + nobtn: 'No' + enablehit: 'Do you want to enable this rule?' + deletehit: 'Delete Local File?' + enablerule: 'Enable Rule' + editrule: 'Edit Rule' + +player: + title: 'Player' + hit: 'Please set up the media player' + +log: + title: 'Log' + reset: 'Reset' + copy: 'Copy' + contactinfo: 'Contact Infomation' + go: 'Go' + join: 'Join' + bugrepo: 'Bug Report' + +config: + title: 'Config' + normalset: + title: 'Normal Setting' + rssintvl: 'Interval Time of Rss' + renameintvl: 'Interval Time of Rename' + webport: 'WebUI Port' + debug: 'Debug' + + parserset: + title: 'Parser Setting' + enable: 'Enable' + source: 'Source' + token: 'Token' + url: 'Custom Url' + language: 'Language' + type: 'Parser Type' + exclude: 'Exclude' + + downloaderset: + title: 'Downloader Setting' + type: 'Downloader Type' + host: 'Host' + username: 'Username' + password: 'Password' + path: 'Download Path' + ssl: 'SSL' + + manageset: + title: 'Manage SEtting' + enable: 'Enable' + method: 'Rename Method' + eps: 'EPS complete' + grouptag: 'Add Group Tag' + deletebadtorr: 'Delete Bad Torrent' + + notificationset: + title: 'Notification Setting' + enable: 'Enable' + type: 'Type' + token: 'Token' + chatid: 'Chat ID' + + proxyset: + title: 'Proxy Setting' + enable: 'Enable' + type: 'Proxy Type' + host: 'Host' + port: 'Port' + username: 'Username' + password: 'Password' + + mediaplayerset: + title: 'Media Player Setting' + type: 'type' + url: 'url' + + cancel: 'Cancel' + apply: 'Apply' + \ No newline at end of file diff --git a/webui/src/locales/lang/zh-CN.yaml b/webui/src/locales/lang/zh-CN.yaml new file mode 100644 index 00000000..2a45e847 --- /dev/null +++ b/webui/src/locales/lang/zh-CN.yaml @@ -0,0 +1,126 @@ +login: + title: '登录' + username: '用户名' + password: '密码' + loginbtn: '登录' + default: '默认账号密码 ' + +sidebar: + title: '菜单' + homepage: '主页' + player: '播放器' + log: '日志' + config: '设置' + logout: '退出' + +topbar: + start: '启动' + pause: '暂停' + restart: '重启' + shutdown: '关闭' + resetrule: '重置规则' + + profile: + title: '账户资料' + poptitle: '修改账户信息' + username: '用户名' + password: '密码' + updatebtn: '更新' + + add: + title: '添加番剧' + rsslink: 'RSS链接' + placeholder: '请输入RSS链接' + analyse: '分析' + +homepage: + title: '番剧列表' + rule: + officaltitle: '官方名称' + year: '年份' + season: '季度' + offset: '偏移' + exclude: '排除' + enable: '启用' + disable: '禁用' + delete: '删除' + apply: '应用' + yesbtn: '是' + nobtn: '否' + enablehit: '确定要让规则生效吗?' + deletehit: '删除本地文件?' + enablerule: '启用规则' + editrule: '编辑规则' + +player: + title: '播放器' + hit: '请设置播放器地址' + +log: + title: '日志' + reset: '重置' + copy: '复制' + contactinfo: '联系方式' + go: '访问' + join: '加入' + bugrepo: 'Bug反馈' + +config: + title: '系统设置' + normalset: + title: '一般设置' + rssintvl: 'RSS间隔' + renameintvl: '重命名间隔' + webport: '网页端口' + debug: '调试' + + parserset: + title: '解析设置' + enable: '启用' + source: '数据源' + token: 'Token' + url: '自定义网址' + language: '语言' + type: '解析类型' + exclude: '排除' + + downloaderset: + title: '下载设置' + type: '下载器类型' + host: '下载器地址' + username: '用户名' + password: '密码' + path: '下载地址' + ssl: 'SSL' + + manageset: + title: '番剧管理设置' + enable: '启用' + method: '重命名方式' + eps: 'EPS完成' + grouptag: '添加组标签' + deletebadtorr: '删除坏种' + + notificationset: + title: '推送设置' + enable: '启用' + type: '类型' + token: 'Token' + chatid: 'Chat ID' + + proxyset: + title: '代理设置' + enable: '启用' + type: '类型' + host: '地址' + port: '端口' + username: '用户名' + password: '密码' + + mediaplayerset: + title: '播放器设置' + type: '类型' + url: '播放器地址' + + cancel: '取消' + apply: '应用' diff --git a/webui/src/main.ts b/webui/src/main.ts index 7dd15cc8..f0d24b1b 100644 --- a/webui/src/main.ts +++ b/webui/src/main.ts @@ -1,6 +1,7 @@ import { createApp } from 'vue'; import { createPinia } from 'pinia'; import { router } from './router'; +import i18n from './locales'; import App from './App.vue'; import '@unocss/reset/tailwind-compat.css'; @@ -11,4 +12,5 @@ const pinia = createPinia(); const app = createApp(App); app.use(router); app.use(pinia); +app.use(i18n); app.mount('#app'); diff --git a/webui/vite.config.ts b/webui/vite.config.ts index 267af685..eccc5e32 100644 --- a/webui/vite.config.ts +++ b/webui/vite.config.ts @@ -6,6 +6,8 @@ import AutoImport from 'unplugin-auto-import/vite'; import Components from 'unplugin-vue-components/vite'; import VueRouter from 'unplugin-vue-router/vite'; import { VueRouterAutoImports } from 'unplugin-vue-router'; +import vueI18n from '@intlify/unplugin-vue-i18n/vite'; +import path from 'path' // https://vitejs.dev/config/ export default defineConfig({ @@ -34,6 +36,9 @@ export default defineConfig({ 'src/components/setting', ], }), + vueI18n({ + include: path.resolve(__dirname, './src/locales/lang/**') + }), ], css: { preprocessorOptions: { From 513f81798c70d56ee78a8d10ded8c1c26bc6f98d Mon Sep 17 00:00:00 2001 From: umbor <14857490+umbors@users.noreply.github.com> Date: Sat, 10 Jun 2023 23:17:48 +0800 Subject: [PATCH 2/7] Change Vue page to use i18n plugin --- webui/src/components/ab-add-bangumi.vue | 8 +++--- webui/src/components/ab-change-account.vue | 12 ++++----- webui/src/components/ab-edit-rule.vue | 24 +++++++++-------- webui/src/components/ab-rule.vue | 12 +++++---- webui/src/components/ab-status-bar.vue | 13 ++++++++-- webui/src/components/layout/ab-sidebar.vue | 19 +++++++------- webui/src/components/layout/ab-topbar.vue | 26 +++++++++++++------ .../components/setting/config-download.vue | 16 +++++++----- .../src/components/setting/config-manage.vue | 14 +++++----- .../src/components/setting/config-normal.vue | 12 +++++---- .../setting/config-notification.vue | 12 +++++---- .../src/components/setting/config-parser.vue | 18 +++++++------ .../src/components/setting/config-player.vue | 6 ++--- webui/src/components/setting/config-proxy.vue | 16 +++++++----- webui/src/pages/login.vue | 10 +++---- 15 files changed, 127 insertions(+), 91 deletions(-) diff --git a/webui/src/components/ab-add-bangumi.vue b/webui/src/components/ab-add-bangumi.vue index 4b630e69..0bfa0bc5 100644 --- a/webui/src/components/ab-add-bangumi.vue +++ b/webui/src/components/ab-add-bangumi.vue @@ -111,21 +111,21 @@ async function subscribe() {