From bed595f0553925e496e0ece6d073b67329d72937 Mon Sep 17 00:00:00 2001 From: dragon Date: Wed, 27 Mar 2024 15:34:29 +0800 Subject: [PATCH 1/2] fix i18n error --- web/src/App.vue | 15 ++++++++++----- web/src/lang/{zh_hans.js => zh_cn.js} | 1 + web/src/lang/{zh_hant.js => zh_tw.js} | 1 + web/src/plugins/i18.js | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) rename web/src/lang/{zh_hans.js => zh_cn.js} (99%) rename web/src/lang/{zh_hant.js => zh_tw.js} (99%) diff --git a/web/src/App.vue b/web/src/App.vue index 8552c223..b425c101 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -637,13 +637,13 @@ const LANGUAGES = { flag: '🇩🇪', title: 'German', }, - zh_hans: { + zh_cn: { flag: '🇨🇳', - title: '简体中文', + title: '中文(中国)', }, - zh_hant: { + zh_tw: { flag: '🇹🇼', - title: '繁體中文', + title: '中文(台湾)', }, fr: { flag: '🇫🇷', @@ -670,6 +670,11 @@ const LANGUAGES = { function getLangInfo(locale) { let res = LANGUAGES[locale]; + // failback short i18n + if (!res) { + res = LANGUAGES[locale.split('_')[0]]; + } + if (!res) { res = LANGUAGES.en; } @@ -678,7 +683,7 @@ function getLangInfo(locale) { } function getSystemLang() { - const locale = navigator.language.split('-')[0]; + const locale = navigator.language.replace('-', '_').toLocaleLowerCase(); return getLangInfo(locale || 'en'); } diff --git a/web/src/lang/zh_hans.js b/web/src/lang/zh_cn.js similarity index 99% rename from web/src/lang/zh_hans.js rename to web/src/lang/zh_cn.js index 08d4fb57..fc5e33a0 100644 --- a/web/src/lang/zh_hans.js +++ b/web/src/lang/zh_cn.js @@ -137,6 +137,7 @@ export default { duration: '说明', stop: '停止', forceStop: '强制删除', + confirmTask: '确认', deleteTeamMember: '删除团队成员', team2: '团队', newTeamMember: '新增团队成员', diff --git a/web/src/lang/zh_hant.js b/web/src/lang/zh_tw.js similarity index 99% rename from web/src/lang/zh_hant.js rename to web/src/lang/zh_tw.js index 924d717f..d82fcc1b 100644 --- a/web/src/lang/zh_hant.js +++ b/web/src/lang/zh_tw.js @@ -137,6 +137,7 @@ export default { duration: '說明', stop: '停止', forceStop: '強制刪除', + confirmTask: '确认', deleteTeamMember: '刪除團隊成員', team2: '團隊', newTeamMember: '新增團隊成員', diff --git a/web/src/plugins/i18.js b/web/src/plugins/i18.js index 9dfa7b8e..f7960aab 100644 --- a/web/src/plugins/i18.js +++ b/web/src/plugins/i18.js @@ -7,7 +7,7 @@ Vue.use(VueI18n); let locale = localStorage.getItem('lang'); if (!locale) { - locale = navigator.language.split('-')[0]; + locale = navigator.language.replace('-', '_').toLocaleLowerCase(); } export default new VueI18n({ From 01dae33e24013b4f607955b2ab0d119275f29b22 Mon Sep 17 00:00:00 2001 From: dragon Date: Wed, 27 Mar 2024 15:46:45 +0800 Subject: [PATCH 2/2] fix i18n error --- web/src/App.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/src/App.vue b/web/src/App.vue index b425c101..36975b8a 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -639,11 +639,11 @@ const LANGUAGES = { }, zh_cn: { flag: '🇨🇳', - title: '中文(中国)', + title: '中文(大陆)', }, zh_tw: { flag: '🇹🇼', - title: '中文(台湾)', + title: '中文(台灣)', }, fr: { flag: '🇫🇷',