fix i18n error

This commit is contained in:
dragon 2024-03-27 15:34:29 +08:00
parent c20a70e3a6
commit bed595f055
4 changed files with 13 additions and 6 deletions

View File

@ -637,13 +637,13 @@ const LANGUAGES = {
flag: '🇩🇪', flag: '🇩🇪',
title: 'German', title: 'German',
}, },
zh_hans: { zh_cn: {
flag: '🇨🇳', flag: '🇨🇳',
title: '简体中文', title: '中文(中国)',
}, },
zh_hant: { zh_tw: {
flag: '🇹🇼', flag: '🇹🇼',
title: '繁體中文', title: '中文(台湾)',
}, },
fr: { fr: {
flag: '🇫🇷', flag: '🇫🇷',
@ -670,6 +670,11 @@ const LANGUAGES = {
function getLangInfo(locale) { function getLangInfo(locale) {
let res = LANGUAGES[locale]; let res = LANGUAGES[locale];
// failback short i18n
if (!res) {
res = LANGUAGES[locale.split('_')[0]];
}
if (!res) { if (!res) {
res = LANGUAGES.en; res = LANGUAGES.en;
} }
@ -678,7 +683,7 @@ function getLangInfo(locale) {
} }
function getSystemLang() { function getSystemLang() {
const locale = navigator.language.split('-')[0]; const locale = navigator.language.replace('-', '_').toLocaleLowerCase();
return getLangInfo(locale || 'en'); return getLangInfo(locale || 'en');
} }

View File

@ -137,6 +137,7 @@ export default {
duration: '说明', duration: '说明',
stop: '停止', stop: '停止',
forceStop: '强制删除', forceStop: '强制删除',
confirmTask: '确认',
deleteTeamMember: '删除团队成员', deleteTeamMember: '删除团队成员',
team2: '团队', team2: '团队',
newTeamMember: '新增团队成员', newTeamMember: '新增团队成员',

View File

@ -137,6 +137,7 @@ export default {
duration: '說明', duration: '說明',
stop: '停止', stop: '停止',
forceStop: '強制刪除', forceStop: '強制刪除',
confirmTask: '确认',
deleteTeamMember: '刪除團隊成員', deleteTeamMember: '刪除團隊成員',
team2: '團隊', team2: '團隊',
newTeamMember: '新增團隊成員', newTeamMember: '新增團隊成員',

View File

@ -7,7 +7,7 @@ Vue.use(VueI18n);
let locale = localStorage.getItem('lang'); let locale = localStorage.getItem('lang');
if (!locale) { if (!locale) {
locale = navigator.language.split('-')[0]; locale = navigator.language.replace('-', '_').toLocaleLowerCase();
} }
export default new VueI18n({ export default new VueI18n({