From 5710165a292de8b74dc01620832449cda107780b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=BA=B8=E5=BF=98=E5=BF=A7?= Date: Thu, 10 Aug 2023 17:30:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E8=AF=AD?= =?UTF-8?q?=E8=A8=80=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/custom-header.vue | 4 +- src/locales/en-us.json | 96 ------------------------- src/locales/index.ts | 21 +++--- src/locales/zh-cn.json | 117 ------------------------------- src/main.ts | 8 +-- 5 files changed, 12 insertions(+), 234 deletions(-) delete mode 100644 src/locales/en-us.json delete mode 100644 src/locales/zh-cn.json diff --git a/src/components/custom-header.vue b/src/components/custom-header.vue index 42b50ba2..8933ec84 100644 --- a/src/components/custom-header.vue +++ b/src/components/custom-header.vue @@ -54,12 +54,12 @@ const themeChange = val => (appStore.theme = val) const languagesItems = computed(() => [ { - lable: t('main.languages.zh-cn'), + lable: t('main.languages.zhCn'), value: 'zh-cn', icon: 'i-flag:cn-4x3', }, { - lable: t('main.languages.en-us'), + lable: t('main.languages.en'), value: 'en-us', icon: 'i-flag:us-4x3', }, diff --git a/src/locales/en-us.json b/src/locales/en-us.json deleted file mode 100644 index 6d03a70e..00000000 --- a/src/locales/en-us.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "app": { - "author": { - "name": "ikxin" - }, - "nav": { - "activate": "Activate", - "check": "Check", - "download": "Download", - "guide": "Guide", - "home": "Home", - "monitor": "Monitor" - }, - "theme": { - "auto": "Auto Mode", - "dark": "Dark Mode", - "light": "Light Mode" - }, - "languages": { - "en-us": "English", - "zh-cn": "Simplified Chinese" - } - }, - "activate": { - "windows": { - "form-item": { - "edition": { - "label": "Edition", - "placeholder": "Please select edition" - }, - "license": { - "label": "License Key" - }, - "service": { - "label": "KMS Server", - "placeholder": "Please select KMS server" - }, - "version": { - "label": "System Version", - "placeholder": "Please select system version" - } - }, - "table": { - "columns": { - "edition": "Edition", - "license": "License Key" - } - } - }, - "button": { - "create-script": "Create Script", - "download-script": "Download Script", - "copy-script": "Copy Script" - }, - "message": { - "error": "Copy Failed", - "success": "Copy Success" - }, - "sidebar": { - "system": "System", - "software": "Software" - }, - "office": { - "form-item": { - "is64bus": { - "label": "CPU Architecture", - "radio": { - "x64": "x64", - "x86": "x86" - } - }, - "license": { - "label": "License Key" - }, - "product": { - "label": "Software Version", - "placeholder": "Please select software version" - }, - "service": { - "label": "KMS Server", - "placeholder": "Please select KMS server" - }, - "version": { - "label": "Office Version", - "placeholder": "Please select office version" - } - }, - "table": { - "columns": { - "license": "License Key", - "product": "Software Version" - } - } - } - } -} diff --git a/src/locales/index.ts b/src/locales/index.ts index b1b18479..b1351898 100644 --- a/src/locales/index.ts +++ b/src/locales/index.ts @@ -1,19 +1,14 @@ -const en = import.meta.glob('./en/*.ts', { +const locales = import.meta.glob('./en/*.ts', { import: 'default', - eager: true + eager: true, }) -const message = {} +const languages = {} -for (const key in en) { - const [language, fileName] = key.split('/').slice(1) - const value = en[key] - - if (!message[language]) { - message[language] = {} - } - - message[language][fileName.split('.')[0]] = value +for (const locale in locales) { + const [language, fileName] = locale.split('/').slice(1) + if (!languages[language]) languages[language] = {} + languages[language][fileName.split('.')[0]] = locales[locale] } -export default message +export default languages diff --git a/src/locales/zh-cn.json b/src/locales/zh-cn.json deleted file mode 100644 index c9714bcf..00000000 --- a/src/locales/zh-cn.json +++ /dev/null @@ -1,117 +0,0 @@ -{ - "app": { - "author": { - "name": "一纸忘忧" - }, - "nav": { - "activate": "激活", - "check": "检测", - "download": "下载", - "guide": "指南", - "home": "首页", - "monitor": "监控" - }, - "theme": { - "auto": "自动模式", - "dark": "深色模式", - "light": "浅色模式" - }, - "languages": { - "en-us": "英语", - "zh-cn": "简体中文" - } - }, - "activate": { - "windows": { - "form-item": { - "version": { - "placeholder": "请选择系统版本", - "label": "系统版本" - }, - "edition": { - "label": "发行版本", - "placeholder": "请选择发行版本" - }, - "service": { - "label": "KMS 服务器", - "placeholder": "请选择 KMS 服务器" - }, - "license": { - "label": "许可证密钥" - } - }, - "table": { - "columns": { - "edition": "发行版本", - "license": "许可证密钥" - } - } - }, - "button": { - "create-script": "创建脚本", - "download-script": "下载脚本", - "copy-script": "复制脚本" - }, - "message": { - "success": "复制成功", - "error": "复制失败" - }, - "sidebar": { - "system": "系统", - "software": "软件" - }, - "office": { - "form-item": { - "version": { - "placeholder": "请选择 Office 版本", - "label": "Office 版本" - }, - "product": { - "placeholder": "请选择软件版本", - "label": "软件版本" - }, - "service": { - "placeholder": "请选择 KMS 服务器", - "label": "KMS 服务器" - }, - "is64bus": { - "label": "CPU 架构", - "radio": { - "x86": "32 位", - "x64": "64 位" - } - }, - "license": { - "label": "许可证密钥" - } - }, - "table": { - "columns": { - "product": "软件版本", - "license": "许可证密钥" - } - } - } - }, - "check": { - "title": "KMS 服务器状态检测", - "form": { - "host": { - "label": "KMS 主机", - "placeholder": "请输入 KMS 主机" - }, - "port": { - "label": "KMS 端口", - "placeholder": "请输入 KMS 端口" - }, - "app": { - "label": "激活产品", - "placeholder": "请选择激活产品" - }, - "protocol": { - "label": "激活协议", - "placeholder": "请选择激活协议" - } - } - } -} diff --git a/src/main.ts b/src/main.ts index eff73d08..e2aefc1d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,11 +1,7 @@ import App from '@/App.vue' import { router } from '@/router' import { createI18n } from 'vue-i18n' -// import messages from '@intlify/unplugin-vue-i18n/messages' - -import locales from '@/locales' - -console.log(locales) +import messages from '@/locales' import '@/styles/custom.less' import 'virtual:uno.css' @@ -15,6 +11,6 @@ const app = createApp(App) const pinia = createPinia() -const i18n = createI18n({ locale: 'en', messages: locales }) +const i18n = createI18n({ locale: 'en', messages }) app.use(pinia).use(i18n).use(router).mount('#app')