Skip to content

Commit

Permalink
fix(plugin-locale): 修复默认语言取值问题
Browse files Browse the repository at this point in the history
  • Loading branch information
wanchun committed Oct 23, 2024
1 parent 66a8572 commit 47b32a2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
18 changes: 11 additions & 7 deletions packages/fes-plugin-locale/src/runtime/core.js.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
};

Expand Down
2 changes: 1 addition & 1 deletion packages/fes-template/src/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export default {
externalLink: 'externalLink',
mock: 'mock',
test: {
b: 1,
test: 'test',
},
};
2 changes: 1 addition & 1 deletion packages/fes-template/src/locales/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export default {
externalLink: '外部链接',
mock: '代理',
test: {
b: 1,
test: '测试',
},
};
2 changes: 1 addition & 1 deletion packages/fes-template/src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { FButton } from '@fesjs/fes-design';
defineRouteMeta({
name: 'index',
title: '$home',
title: '$test.test',
});
console.log('123123'.replaceAll('123', '234'));
Expand Down

0 comments on commit 47b32a2

Please sign in to comment.