diff --git a/src/store/app.js b/src/store/app.js index fd97295..8aff291 100644 --- a/src/store/app.js +++ b/src/store/app.js @@ -6,6 +6,7 @@ import ko from 'element-plus/es/locale/lang/ko' import ru from 'element-plus/es/locale/lang/ru' import fr from 'element-plus/es/locale/lang/fr' import es from 'element-plus/es/locale/lang/es' +import zhTw from 'element-plus/es/locale/lang/zh-tw' import { admin, app } from '@/api/config' const langs = { @@ -15,6 +16,7 @@ const langs = { 'ko': { name: '한국어', value: ko, sideBarWidth: '230px' }, 'ru': { name: 'русский', value: ru, sideBarWidth: '250px' }, 'es': { name: 'español', value: es, sideBarWidth: '280px' }, + 'zh-TW': { name: '中文繁体', value: zhTw, sideBarWidth: '210px' }, } const defaultLang = localStorage.getItem('lang') || navigator.language || 'zh-CN' export const useAppStore = defineStore({ diff --git a/src/utils/i18n.js b/src/utils/i18n.js index 5a51675..5c6878b 100644 --- a/src/utils/i18n.js +++ b/src/utils/i18n.js @@ -4,19 +4,21 @@ import zhCN from '@/utils/i18n/zh_CN.json' import ko from '@/utils/i18n/ko.json' import ru from '@/utils/i18n/ru.json' import es from '@/utils/i18n/es.json' +import zhTW from '@/utils/i18n/zh_TW.json' import { useAppStore } from '@/store/app' +const trans = { + 'en': en, + 'fr': fr, + 'zh-CN': zhCN, + 'ko': ko, + 'ru': ru, + 'es': es, + 'zh-TW': zhTW, +} export function T (key, params, num = 0) { const appStore = useAppStore() const lang = appStore.setting.lang - const trans = { - 'en': en, - 'fr': fr, - 'zh-CN': zhCN, - 'ko': ko, - 'ru': ru, - 'es': es, - } const tran = trans[lang]?.[key] if (!tran) { return key