fix(plugin-locale): 修复默认语言取值问题

This commit is contained in:
harrywan 2024-10-23 11:25:00 +08:00
parent 66a8572ed6
commit 47b32a2767
4 changed files with 14 additions and 10 deletions

View File

@ -19,18 +19,22 @@ const getDefaultLocale = () => {
if (fes_locale) { if (fes_locale) {
return { return {
locale: fes_locale, locale: fes_locale,
fallbackLocale: fes_locale, fallbackLocale: defaultOptions.fallbackLocale,
}; };
} }
if (BASE_NAVIGATOR) { if (BASE_NAVIGATOR) {
return { const keys = locales.map(item=> item.locale);
locale: window.navigator.language, const findKey = keys.find(item=> item.includes(window.navigator.language))
fallbackLocale: window.navigator.language, if(findKey){
}; return {
locale: findKey,
fallbackLocale: defaultOptions.fallbackLocale,
};
}
} }
return { return {
locale: 'zh-CN', locale: defaultOptions.locale,
fallbackLocale: 'zh-CN', fallbackLocale: defaultOptions.fallbackLocale,
}; };
}; };

View File

@ -4,6 +4,6 @@ export default {
externalLink: 'externalLink', externalLink: 'externalLink',
mock: 'mock', mock: 'mock',
test: { test: {
b: 1, test: 'test',
}, },
}; };

View File

@ -4,6 +4,6 @@ export default {
externalLink: '外部链接', externalLink: '外部链接',
mock: '代理', mock: '代理',
test: { test: {
b: 1, test: '测试',
}, },
}; };

View File

@ -13,7 +13,7 @@ import { FButton } from '@fesjs/fes-design';
defineRouteMeta({ defineRouteMeta({
name: 'index', name: 'index',
title: '$home', title: '$test.test',
}); });
console.log('123123'.replaceAll('123', '234')); console.log('123123'.replaceAll('123', '234'));