From dd91449818231343ab2b804d077a1c87786b1706 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Mar 2024 15:16:50 +0100 Subject: [PATCH] feat: refs #5186 use global locales --- src/components/common/VnBreadcrumbs.vue | 5 +++-- src/router/index.js | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/common/VnBreadcrumbs.vue b/src/components/common/VnBreadcrumbs.vue index 5002c5a9a..e711b8541 100644 --- a/src/components/common/VnBreadcrumbs.vue +++ b/src/components/common/VnBreadcrumbs.vue @@ -41,8 +41,9 @@ function getBreadcrumb(param) { breadcrumb.title = useCamelCase(param.meta.title); } - breadcrumb.locale = te(`${breadcrumb.root}.pageTitles.${breadcrumb.title}`) - ? t(`${breadcrumb.root}.pageTitles.${breadcrumb.title}`) + const moduleLocale = `${breadcrumb.root}.pageTitles.${breadcrumb.title}`; + breadcrumb.locale = te(moduleLocale) + ? t(moduleLocale) : t(`globals.pageTitles.${breadcrumb.title}`); return breadcrumb; diff --git a/src/router/index.js b/src/router/index.js index ca560e9c9..3e442f0e6 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -15,7 +15,7 @@ import { toLowerCamel } from 'src/filters'; const state = useState(); const session = useSession(); -const { t } = i18n.global; +const { t, te } = i18n.global; const createHistory = process.env.SERVER ? createMemoryHistory @@ -90,7 +90,10 @@ export default route(function (/* { store, ssrContext } */) { if (childPageTitle && matches.length > 2) { if (title != '') title += ': '; - const pageTitle = t(`${moduleName}.pageTitles.${childPageTitle}`); + const moduleLocale = `${moduleName}.pageTitles.${childPageTitle}`; + const pageTitle = te(moduleLocale) + ? t(moduleLocale) + : t(`globals.pageTitles.${childPageTitle}`); const idParam = to.params && to.params.id; const idPageTitle = `${idParam} - ${pageTitle}`; const builtTitle = idParam ? idPageTitle : pageTitle;