Skip to content

Commit a81d564

Browse files
feat: Change frontend locale code from 'tw' to 'zh-Hant' (#8010)
1 parent 1289e15 commit a81d564

File tree

11 files changed

+25
-49
lines changed

11 files changed

+25
-49
lines changed

frontend/src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const config = reactive({
2525
2626
const i18nLocale = computed(() => {
2727
if (globalStore.language === 'zh') return zhCn;
28-
if (globalStore.language === 'tw') return zhTw;
28+
if (globalStore.language === 'zh-Hant') return zhTw;
2929
if (globalStore.language === 'en') return en;
3030
if (globalStore.language === 'ja') return ja;
3131
if (globalStore.language === 'ms') return ms;

frontend/src/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class RequestHttp {
2222
this.service = axios.create(config);
2323
this.service.interceptors.request.use(
2424
(config: AxiosRequestConfig) => {
25-
let language = globalStore.language === 'tw' ? 'zh-Hant' : globalStore.language;
25+
let language = globalStore.language;
2626
config.headers = {
2727
'Accept-Language': language,
2828
...config.headers,

frontend/src/lang/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createI18n } from 'vue-i18n';
22
import zh from './modules/zh';
3-
import tw from './modules/tw';
3+
import zhHnat from './modules/zh-Hant';
44
import en from './modules/en';
55
import ptBr from './modules/pt-br';
66
import ja from './modules/ja';
@@ -15,7 +15,7 @@ const i18n = createI18n({
1515
globalInjection: true,
1616
messages: {
1717
zh,
18-
tw,
18+
'zh-Hant': zhHnat,
1919
en,
2020
'pt-BR': ptBr,
2121
ja,

frontend/src/utils/util.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,19 @@ export function getLanguage() {
625625
return localStorage.getItem('lang') || 'zh';
626626
}
627627

628+
export function getLabel(row: any) {
629+
const language = localStorage.getItem('lang') || 'zh';
630+
let lang = language == 'tw' ? 'zh-Hant' : language;
631+
if (row.label && row.label[lang] != '') {
632+
return row.label[lang];
633+
}
634+
if (language == 'zh' || language == 'tw') {
635+
return row.labelZh;
636+
} else {
637+
return row.labelEn;
638+
}
639+
}
640+
628641
export function emptyLineFilter(str: string, spilt: string) {
629642
let list = str.split(spilt);
630643
let results = [];

frontend/src/views/app-store/detail/params/index.vue

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ import { getRandomStr } from '@/utils/util';
113113
import { getAppService } from '@/api/modules/app';
114114
import { Rules } from '@/global/form-rules';
115115
import { App } from '@/api/interface/app';
116-
import { getDBName } from '@/utils/util';
116+
import { getDBName, getLabel } from '@/utils/util';
117117
import { getPathByType } from '@/api/modules/files';
118118
119119
interface ParamObj extends App.FromField {
@@ -258,19 +258,6 @@ const changeService = (value: string, services: App.AppService[]) => {
258258
updateParam();
259259
};
260260
261-
const getLabel = (row: ParamObj): string => {
262-
const language = localStorage.getItem('lang') || 'zh';
263-
let lang = language == 'tw' ? 'zh-Hant' : language;
264-
if (row.label && row.label[lang] != '') {
265-
return row.label[lang];
266-
}
267-
if (language == 'zh' || language == 'tw') {
268-
return row.labelZh;
269-
} else {
270-
return row.labelEn;
271-
}
272-
};
273-
274261
const toPage = (key: string) => {
275262
window.location.href = '/apps/all?install=' + key;
276263
};

frontend/src/views/app-store/installed/detail/index.vue

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ import { reactive, ref } from 'vue';
121121
import { FormInstance } from 'element-plus';
122122
import { Rules, checkNumberRange } from '@/global/form-rules';
123123
import { MsgSuccess } from '@/utils/message';
124+
import { getLabel } from '@/utils/util';
124125
import i18n from '@/lang';
125126
126127
interface ParamProps {
@@ -228,19 +229,6 @@ const get = async () => {
228229
}
229230
};
230231
231-
const getLabel = (row: EditForm): string => {
232-
const language = localStorage.getItem('lang') || 'zh';
233-
let lang = language == 'tw' ? 'zh-Hant' : language;
234-
if (row.label && row.label[lang] != '') {
235-
return row.label[lang];
236-
}
237-
if (language == 'zh' || language == 'tw') {
238-
return row.labelZh;
239-
} else {
240-
return row.labelEn;
241-
}
242-
};
243-
244232
const submit = async (formEl: FormInstance) => {
245233
if (!formEl) return;
246234
await formEl.validate((valid) => {

frontend/src/views/log/operation/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</el-table-column>
4747
<el-table-column :label="$t('commons.table.operate')" min-width="150px" prop="detailZH">
4848
<template #default="{ row }">
49-
<span v-if="globalStore.language === 'zh' || globalStore.language === 'tw'">
49+
<span v-if="globalStore.language === 'zh' || globalStore.language === 'zh-Hant'">
5050
{{ row.detailZH }}
5151
</span>
5252
<span v-if="globalStore.language === 'en'">{{ row.detailEN }}</span>
@@ -110,7 +110,7 @@ const search = async () => {
110110
.then((res) => {
111111
loading.value = false;
112112
data.value = res.data.items || [];
113-
if (globalStore.language === 'zh' || globalStore.language === 'tw') {
113+
if (globalStore.language === 'zh' || globalStore.language === 'zh-Hant') {
114114
for (const item of data.value) {
115115
item.detailZH = loadDetail(item.detailZH);
116116
}

frontend/src/views/login/components/login-form.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
English
5656
</el-dropdown-item>
5757
<el-dropdown-item command="zh">中文(简体)</el-dropdown-item>
58-
<el-dropdown-item command="tw">中文(繁體)</el-dropdown-item>
58+
<el-dropdown-item command="zh-Hant">中文(繁體)</el-dropdown-item>
5959
<el-dropdown-item v-if="!globalStore.isIntl" command="en">
6060
English
6161
</el-dropdown-item>
@@ -274,7 +274,7 @@ function handleCommand(command: string) {
274274
dropdownText.value = 'English';
275275
} else if (command === 'pt-BR') {
276276
dropdownText.value = 'Português (Brasil)';
277-
} else if (command === 'tw') {
277+
} else if (command === 'zh-Hant') {
278278
dropdownText.value = '中文(繁體)';
279279
} else if (command === 'ko') {
280280
dropdownText.value = '한국어';

frontend/src/views/setting/panel/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ interface Node {
279279
280280
const languageOptions = ref([
281281
{ value: 'zh', label: '中文(简体)' },
282-
{ value: 'tw', label: '中文(繁體)' },
282+
{ value: 'zh-Hant', label: '中文(繁體)' },
283283
...(!globalStore.isIntl ? [{ value: 'en', label: 'English' }] : []),
284284
{ value: 'ja', label: '日本語' },
285285
{ value: 'pt-BR', label: 'Português (Brasil)' },

0 commit comments

Comments
 (0)