1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-03-01 03:24:14 +08:00

feat: Change frontend locale code from 'tw' to 'zh-Hant' (#8010)

This commit is contained in:
zhengkunwang 2025-02-26 16:18:53 +08:00 committed by GitHub
parent 1289e15776
commit a81d5645ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 25 additions and 49 deletions

View File

@ -25,7 +25,7 @@ const config = reactive({
const i18nLocale = computed(() => {
if (globalStore.language === 'zh') return zhCn;
if (globalStore.language === 'tw') return zhTw;
if (globalStore.language === 'zh-Hant') return zhTw;
if (globalStore.language === 'en') return en;
if (globalStore.language === 'ja') return ja;
if (globalStore.language === 'ms') return ms;

View File

@ -22,7 +22,7 @@ class RequestHttp {
this.service = axios.create(config);
this.service.interceptors.request.use(
(config: AxiosRequestConfig) => {
let language = globalStore.language === 'tw' ? 'zh-Hant' : globalStore.language;
let language = globalStore.language;
config.headers = {
'Accept-Language': language,
...config.headers,

View File

@ -1,6 +1,6 @@
import { createI18n } from 'vue-i18n';
import zh from './modules/zh';
import tw from './modules/tw';
import zhHnat from './modules/zh-Hant';
import en from './modules/en';
import ptBr from './modules/pt-br';
import ja from './modules/ja';
@ -15,7 +15,7 @@ const i18n = createI18n({
globalInjection: true,
messages: {
zh,
tw,
'zh-Hant': zhHnat,
en,
'pt-BR': ptBr,
ja,

View File

@ -625,6 +625,19 @@ export function getLanguage() {
return localStorage.getItem('lang') || 'zh';
}
export function getLabel(row: any) {
const language = localStorage.getItem('lang') || 'zh';
let lang = language == 'tw' ? 'zh-Hant' : language;
if (row.label && row.label[lang] != '') {
return row.label[lang];
}
if (language == 'zh' || language == 'tw') {
return row.labelZh;
} else {
return row.labelEn;
}
}
export function emptyLineFilter(str: string, spilt: string) {
let list = str.split(spilt);
let results = [];

View File

@ -113,7 +113,7 @@ import { getRandomStr } from '@/utils/util';
import { getAppService } from '@/api/modules/app';
import { Rules } from '@/global/form-rules';
import { App } from '@/api/interface/app';
import { getDBName } from '@/utils/util';
import { getDBName, getLabel } from '@/utils/util';
import { getPathByType } from '@/api/modules/files';
interface ParamObj extends App.FromField {
@ -258,19 +258,6 @@ const changeService = (value: string, services: App.AppService[]) => {
updateParam();
};
const getLabel = (row: ParamObj): string => {
const language = localStorage.getItem('lang') || 'zh';
let lang = language == 'tw' ? 'zh-Hant' : language;
if (row.label && row.label[lang] != '') {
return row.label[lang];
}
if (language == 'zh' || language == 'tw') {
return row.labelZh;
} else {
return row.labelEn;
}
};
const toPage = (key: string) => {
window.location.href = '/apps/all?install=' + key;
};

View File

@ -121,6 +121,7 @@ import { reactive, ref } from 'vue';
import { FormInstance } from 'element-plus';
import { Rules, checkNumberRange } from '@/global/form-rules';
import { MsgSuccess } from '@/utils/message';
import { getLabel } from '@/utils/util';
import i18n from '@/lang';
interface ParamProps {
@ -228,19 +229,6 @@ const get = async () => {
}
};
const getLabel = (row: EditForm): string => {
const language = localStorage.getItem('lang') || 'zh';
let lang = language == 'tw' ? 'zh-Hant' : language;
if (row.label && row.label[lang] != '') {
return row.label[lang];
}
if (language == 'zh' || language == 'tw') {
return row.labelZh;
} else {
return row.labelEn;
}
};
const submit = async (formEl: FormInstance) => {
if (!formEl) return;
await formEl.validate((valid) => {

View File

@ -46,7 +46,7 @@
</el-table-column>
<el-table-column :label="$t('commons.table.operate')" min-width="150px" prop="detailZH">
<template #default="{ row }">
<span v-if="globalStore.language === 'zh' || globalStore.language === 'tw'">
<span v-if="globalStore.language === 'zh' || globalStore.language === 'zh-Hant'">
{{ row.detailZH }}
</span>
<span v-if="globalStore.language === 'en'">{{ row.detailEN }}</span>
@ -110,7 +110,7 @@ const search = async () => {
.then((res) => {
loading.value = false;
data.value = res.data.items || [];
if (globalStore.language === 'zh' || globalStore.language === 'tw') {
if (globalStore.language === 'zh' || globalStore.language === 'zh-Hant') {
for (const item of data.value) {
item.detailZH = loadDetail(item.detailZH);
}

View File

@ -55,7 +55,7 @@
English
</el-dropdown-item>
<el-dropdown-item command="zh">中文(简体)</el-dropdown-item>
<el-dropdown-item command="tw">中文(繁體)</el-dropdown-item>
<el-dropdown-item command="zh-Hant">中文(繁體)</el-dropdown-item>
<el-dropdown-item v-if="!globalStore.isIntl" command="en">
English
</el-dropdown-item>
@ -274,7 +274,7 @@ function handleCommand(command: string) {
dropdownText.value = 'English';
} else if (command === 'pt-BR') {
dropdownText.value = 'Português (Brasil)';
} else if (command === 'tw') {
} else if (command === 'zh-Hant') {
dropdownText.value = '中文(繁體)';
} else if (command === 'ko') {
dropdownText.value = '한국어';

View File

@ -279,7 +279,7 @@ interface Node {
const languageOptions = ref([
{ value: 'zh', label: '中文(简体)' },
{ value: 'tw', label: '中文(繁體)' },
{ value: 'zh-Hant', label: '中文(繁體)' },
...(!globalStore.isIntl ? [{ value: 'en', label: 'English' }] : []),
{ value: 'ja', label: '日本語' },
{ value: 'pt-BR', label: 'Português (Brasil)' },

View File

@ -189,6 +189,7 @@ import { MsgSuccess } from '@/utils/message';
import { FormInstance } from 'element-plus';
import { reactive, ref } from 'vue';
import { GlobalStore } from '@/store';
import { getLabel } from '@/utils/util';
const globalStore = GlobalStore();
interface OperateRrops {
@ -284,19 +285,6 @@ const rules = ref<any>({
},
});
const getLabel = (row: App.FromField): string => {
const language = localStorage.getItem('lang') || 'zh';
let lang = language == 'tw' ? 'zh-Hant' : language;
if (row.label && row.label[lang] != '') {
return row.label[lang];
}
if (language == 'zh' || language == 'tw') {
return row.labelZh;
} else {
return row.labelEn;
}
};
const em = defineEmits(['close', 'submit']);
const handleClose = () => {