From ecc2afd164094ca9b627389093f9ca2449dbc6dd Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Tue, 7 Mar 2023 18:44:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=B9=81=E4=BD=93?= =?UTF-8?q?=E4=B8=AD=E6=96=87=E7=BF=BB=E8=AF=91=20(#348)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Add Traditional Chinese language UI locale * chore: 添加新翻译 --------- Co-authored-by: ChenZhaoYu <790348264@qq.com> --- src/components/common/Setting/General.vue | 1 + src/hooks/useLanguage.ts | 5 ++- src/locales/index.ts | 10 +++--- src/locales/zh-TW.ts | 43 +++++++++++++++++++++++ src/store/modules/app/helper.ts | 2 +- 5 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 src/locales/zh-TW.ts diff --git a/src/components/common/Setting/General.vue b/src/components/common/Setting/General.vue index 4152b4a..2516cbb 100644 --- a/src/components/common/Setting/General.vue +++ b/src/components/common/Setting/General.vue @@ -52,6 +52,7 @@ const themeOptions: { label: string; key: Theme; icon: string }[] = [ const languageOptions: { label: string; key: Language; value: Language }[] = [ { label: '中文', key: 'zh-CN', value: 'zh-CN' }, + { label: '繁體中文', key: 'zh-TW', value: 'zh-TW' }, { label: 'English', key: 'en-US', value: 'en-US' }, ] diff --git a/src/hooks/useLanguage.ts b/src/hooks/useLanguage.ts index 13b8ce9..f015142 100644 --- a/src/hooks/useLanguage.ts +++ b/src/hooks/useLanguage.ts @@ -1,5 +1,5 @@ import { computed } from 'vue' -import { enUS, zhCN } from 'naive-ui' +import { enUS, zhCN, zhTW } from 'naive-ui' import { useAppStore } from '@/store' import { setLocale } from '@/locales' @@ -14,6 +14,9 @@ export function useLanguage() { case 'zh-CN': setLocale('zh-CN') return zhCN + case 'zh-TW': + setLocale('zh-TW') + return zhTW default: setLocale('zh-CN') return enUS diff --git a/src/locales/index.ts b/src/locales/index.ts index 17d3b56..49eb488 100644 --- a/src/locales/index.ts +++ b/src/locales/index.ts @@ -1,7 +1,8 @@ import type { App } from 'vue' import { createI18n } from 'vue-i18n' -import en from './en-US' -import cn from './zh-CN' +import enUS from './en-US' +import zhCN from './zh-CN' +import zhTW from './zh-TW' import { useAppStoreWithOut } from '@/store/modules/app' import type { Language } from '@/store/modules/app/helper' @@ -14,8 +15,9 @@ const i18n = createI18n({ fallbackLocale: 'en-US', allowComposition: true, messages: { - 'en-US': en, - 'zh-CN': cn, + 'en-US': enUS, + 'zh-CN': zhCN, + 'zh-TW': zhTW, }, }) diff --git a/src/locales/zh-TW.ts b/src/locales/zh-TW.ts new file mode 100644 index 0000000..1385d95 --- /dev/null +++ b/src/locales/zh-TW.ts @@ -0,0 +1,43 @@ +export default { + common: { + delete: '刪除', + save: '儲存', + reset: '重設', + export: '導出', + import: '導入', + clear: '清空', + yes: '是', + no: '否', + noData: '暫無資料', + wrong: '好像出錯了,請稍後再試。', + success: '操作成功', + failed: '操作失敗', + }, + chat: { + placeholder: '來講點什麼...(Shift + Enter = 換行)', + placeholderMobile: '來講點什麼...', + copy: '複製', + copied: '複製成功', + copyCode: '複製代碼', + clearChat: '清空對話', + clearChatConfirm: '是否清空對話?', + deleteMessage: '刪除訊息', + deleteMessageConfirm: '是否刪除此訊息?', + deleteHistoryConfirm: '確定刪除此紀錄?', + }, + setting: { + setting: '設定', + general: '總覽', + config: '設定', + avatarLink: '頭貼連結', + name: '名稱', + description: '描述', + resetUserInfo: '重設使用者資訊', + theme: '主題', + language: '語言', + api: 'API', + reverseProxy: '反向代理', + timeout: '逾時', + socks: 'Socks', + }, +} diff --git a/src/store/modules/app/helper.ts b/src/store/modules/app/helper.ts index f94b6f6..a15b07e 100644 --- a/src/store/modules/app/helper.ts +++ b/src/store/modules/app/helper.ts @@ -4,7 +4,7 @@ const LOCAL_NAME = 'appSetting' export type Theme = 'light' | 'dark' | 'auto' -export type Language = 'zh-CN' | 'en-US' +export type Language = 'zh-CN' | 'zh-TW' | 'en-US' export interface AppState { siderCollapsed: boolean