提交 c54146eb 作者: 方治民

fix: 优化 i18n 切换刷新导致默认回退不起作用的问题

上级 97bd02d6
......@@ -17,4 +17,5 @@ export default {
light: 'Light',
dark: 'Dark',
comingSoon: 'Coming soon',
}
......@@ -17,4 +17,5 @@ export default {
light: '亮色主题',
dark: '黑暗主题',
comingSoon: '敬请期待',
}
......@@ -13,21 +13,22 @@ export let i18n: ReturnType<typeof createI18n>
async function createI18nOptions(): Promise<I18nOptions> {
const localeStore = useLocaleStoreWithOut()
const locale = localeStore.getLocale
const defaultLocal = await import(`./lang/${locale}.ts`)
const message = defaultLocal.default?.message ?? {}
setHtmlPageLang(locale)
setLoadLocalePool((loadLocalePool) => {
loadLocalePool.push(locale)
})
const messages = {}
for (const lang of localeSetting.showPicker ? availableLocales : [locale]) {
messages[lang] = (await import(`./lang/${lang}.ts`)).default?.message ?? {}
}
return {
legacy: false,
locale,
messages,
fallbackLocale: fallback,
messages: {
[locale]: message,
},
availableLocales: availableLocales,
sync: true, //If you don’t want to inherit locale from global scope, you need to set sync of i18n component option to false.
silentTranslationWarn: true, // true - warning off
......
......@@ -32,6 +32,7 @@ export function useLocale() {
const getShowLocalePicker = computed(() => localeStore.getShowPicker)
const getAntdLocale = computed((): any => {
// @ts-ignore
return i18n.global.getLocaleMessage(unref(getLocale))?.antdLocale ?? {}
})
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论