diff --git a/src/hooks/useI18n.ts b/src/hooks/useI18n.ts index fc76eba4..e15a044a 100644 --- a/src/hooks/useI18n.ts +++ b/src/hooks/useI18n.ts @@ -16,6 +16,7 @@ export default function useLocale() { const changeLocale = (value: string) => { i18n.locale.value = value; localSet(CACHE_LOCAL_I18N, value); + window.location.reload() }; return { diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index 154f150b..fb30e84c 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -121,6 +121,16 @@ export default { } }, + // 静态路由 + router: { + index: "Home", + account: { + index: "Personal Center", + profile: "Personal Info", + settings: "Personal Settings", + }, + }, + // 校验 valid: { userNameReg: 'The account cannot start with a number and can contain uppercase and lowercase letters, numbers, and no less than 5 digits.', diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index 3c26f03f..81943a7f 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -121,6 +121,16 @@ export default { } }, + // 静态路由 + router: { + index: "Home", + account: { + index: "个人中心", + profile: "个人信息", + settings: "个人设置", + }, + }, + // 校验 valid: { userNameReg: '账号不能以数字开头,可包含大写小写字母,数字,且不少于5位', diff --git a/src/layouts/BasicLayout.vue b/src/layouts/BasicLayout.vue index 8cefdb7a..5d1f22d5 100644 --- a/src/layouts/BasicLayout.vue +++ b/src/layouts/BasicLayout.vue @@ -85,7 +85,7 @@ const breadcrumb = computed(() => { .map(item => { return { path: item.path, - breadcrumbName: item.meta.title || '-', + breadcrumbName: fnLocale(item.meta.title || '-'), }; }); }); @@ -120,6 +120,16 @@ function fnComponentSetName(component: any, to: any) { // 清空导航栏标签 tabsStore.clear(); +/** + * 国际化翻译转换 + */ +function fnLocale(title: string) { + if (title.indexOf('router.') !== -1) { + title = t(title); + } + return title; +} + // onMounted(() => { // fnGetServerTime(); @@ -186,6 +196,7 @@ document.addEventListener('visibilitychange', function () { v-bind="proConfig" :iconfont-url="scriptUrl" :sider-width="208" + :locale="(fnLocale as any)" >