From ebbd788fbb2c0b45d4473798efc57eec8ba74a25 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期二, 18 六月 2024 14:51:16 +0800 Subject: [PATCH] 版本更新至2.11.5 --- src/locales/setupI18n.ts | 38 +++++--------------------------------- 1 files changed, 5 insertions(+), 33 deletions(-) diff --git a/src/locales/setupI18n.ts b/src/locales/setupI18n.ts index f2c90aa..80f9c6c 100644 --- a/src/locales/setupI18n.ts +++ b/src/locales/setupI18n.ts @@ -1,48 +1,20 @@ import type { App } from 'vue'; -import type { I18n, I18nOptions } from 'vue-i18n'; +import type { I18nOptions } from 'vue-i18n'; import { createI18n } from 'vue-i18n'; import { setHtmlPageLang, setLoadLocalePool } from './helper'; -import { localeSetting } from '/@/settings/localeSetting'; -import { useLocaleStoreWithOut } from '/@/store/modules/locale'; +import { localeSetting } from '@/settings/localeSetting'; +import { useLocaleStoreWithOut } from '@/store/modules/locale'; const { fallback, availableLocales } = localeSetting; export let i18n: ReturnType<typeof createI18n>; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getLangJson(enObj, cnObj) { - const json = {}; - if (typeof enObj === 'object') { - for (const key in enObj) { - if ( - Object.prototype.hasOwnProperty.call(enObj, key) && - Object.prototype.hasOwnProperty.call(cnObj, key) - ) { - const en = enObj[key]; - const cn = cnObj[key]; - if (typeof en === 'object') { - json[key] = getLangJson(en, cn); // 閫掑綊澶勭悊瀛愬璞� - } else { - json[key] = {}; - json[key].en = en; - json[key].cn = cn; - } - } - } - } - return json; -} - async function createI18nOptions(): Promise<I18nOptions> { const localeStore = useLocaleStoreWithOut(); const locale = localeStore.getLocale; const defaultLocal = await import(`./lang/${locale}.ts`); - const message = defaultLocal.default?.apiMessage ?? {}; - //鐢熸垚璇█鍖呮枃浠� - // const en = (await import(`./lang/${'en'}.ts`)).default?.message; - // const cn = defaultLocal.default?.message; - // let lang = getLangJson(en, cn); + const message = defaultLocal.default?.message ?? {}; setHtmlPageLang(locale); setLoadLocalePool((loadLocalePool) => { @@ -67,6 +39,6 @@ // setup i18n instance with glob export async function setupI18n(app: App) { const options = await createI18nOptions(); - i18n = createI18n(options) as I18n; + i18n = createI18n(options); app.use(i18n); } -- Gitblit v1.9.3