diff --git a/packages/fes-plugin-locale/src/runtime/core.js.tpl b/packages/fes-plugin-locale/src/runtime/core.js.tpl index 5e662d9d..38dbf1ec 100644 --- a/packages/fes-plugin-locale/src/runtime/core.js.tpl +++ b/packages/fes-plugin-locale/src/runtime/core.js.tpl @@ -19,18 +19,22 @@ const getDefaultLocale = () => { if (fes_locale) { return { locale: fes_locale, - fallbackLocale: fes_locale, + fallbackLocale: defaultOptions.fallbackLocale, }; } if (BASE_NAVIGATOR) { - return { - locale: window.navigator.language, - fallbackLocale: window.navigator.language, - }; + const keys = locales.map(item=> item.locale); + const findKey = keys.find(item=> item.includes(window.navigator.language)) + if(findKey){ + return { + locale: findKey, + fallbackLocale: defaultOptions.fallbackLocale, + }; + } } return { - locale: 'zh-CN', - fallbackLocale: 'zh-CN', + locale: defaultOptions.locale, + fallbackLocale: defaultOptions.fallbackLocale, }; }; diff --git a/packages/fes-template/src/locales/en-US.js b/packages/fes-template/src/locales/en-US.js index 83d84697..a74ccafd 100644 --- a/packages/fes-template/src/locales/en-US.js +++ b/packages/fes-template/src/locales/en-US.js @@ -4,6 +4,6 @@ export default { externalLink: 'externalLink', mock: 'mock', test: { - b: 1, + test: 'test', }, }; diff --git a/packages/fes-template/src/locales/zh-CN.js b/packages/fes-template/src/locales/zh-CN.js index d119327f..66005531 100644 --- a/packages/fes-template/src/locales/zh-CN.js +++ b/packages/fes-template/src/locales/zh-CN.js @@ -4,6 +4,6 @@ export default { externalLink: '外部链接', mock: '代理', test: { - b: 1, + test: '测试', }, }; diff --git a/packages/fes-template/src/pages/index.vue b/packages/fes-template/src/pages/index.vue index 6a124862..4963e339 100644 --- a/packages/fes-template/src/pages/index.vue +++ b/packages/fes-template/src/pages/index.vue @@ -13,7 +13,7 @@ import { FButton } from '@fesjs/fes-design'; defineRouteMeta({ name: 'index', - title: '$home', + title: '$test.test', }); console.log('123123'.replaceAll('123', '234'));