Skip to content

Commit f687a32

Browse files
kdrmlhcndataeaseShu
authored andcommitted
feat: Add i18n support for supplier names and model types
- Add supplier name translations (Chinese, English, Korean) - Add model type translations - Update supplier.ts to include i18nKey for each supplier - Update Vue components to use i18n translations
1 parent 3fa2bae commit f687a32

File tree

10 files changed

+90
-9
lines changed

10 files changed

+90
-9
lines changed

frontend/src/entity/CommonEntity.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
export interface SelectOption {
22
label: string
33
value: string | number
4+
i18nKey?: string
45
}
56

67
export const modelTypeOptions: SelectOption[] = [
7-
{ label: '大语言模型', value: 0 },
8+
{ label: '大语言模型', value: 0, i18nKey: 'modelType.llm' },
89
/* { label: 'Anthropic', value: 1 },
910
{ label: 'Baidu', value: 2 },
1011
{ label: 'iFLYTEK', value: 3 },
@@ -17,5 +18,5 @@ export const modelTypeOptions: SelectOption[] = [
1718
export const getModelTypeName = (value: any) => {
1819
const tv = parseInt(value)
1920
const item = modelTypeOptions.find((item) => item.value === tv)
20-
return item?.label || ''
21+
return item?.i18nKey || item?.label || ''
2122
}

frontend/src/entity/supplier.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type ModelConfig = Record<
2626
export const supplierList: Array<{
2727
id: number
2828
name: string
29+
i18nKey: string
2930
icon: any
3031
type?: string
3132
is_private?: boolean
@@ -34,6 +35,7 @@ export const supplierList: Array<{
3435
{
3536
id: 1,
3637
name: '阿里云百炼',
38+
i18nKey: 'supplier.alibaba_cloud_bailian',
3739
icon: icon_alybl_colorful,
3840
model_config: {
3941
0: {
@@ -60,6 +62,7 @@ export const supplierList: Array<{
6062
{
6163
id: 2,
6264
name: '千帆大模型',
65+
i18nKey: 'supplier.qianfan_model',
6366
icon: icon_bdyzn_colorful,
6467
model_config: {
6568
0: {
@@ -71,6 +74,7 @@ export const supplierList: Array<{
7174
{
7275
id: 3,
7376
name: 'DeepSeek',
77+
i18nKey: 'supplier.deepseek',
7478
icon: icon_deepseek_colorful,
7579
model_config: {
7680
0: {
@@ -85,6 +89,7 @@ export const supplierList: Array<{
8589
{
8690
id: 4,
8791
name: '腾讯混元',
92+
i18nKey: 'supplier.tencent_hunyuan',
8893
icon: icon_txhy_colorful,
8994
model_config: {
9095
0: {
@@ -104,6 +109,7 @@ export const supplierList: Array<{
104109
{
105110
id: 5,
106111
name: '讯飞星火',
112+
i18nKey: 'supplier.iflytek_spark',
107113
icon: icon_xfhx_colorful,
108114
model_config: {
109115
0: {
@@ -156,6 +162,7 @@ export const supplierList: Array<{
156162
{
157163
id: 6,
158164
name: 'Gemini',
165+
i18nKey: 'supplier.gemini',
159166
icon: icon_gemini_colorful,
160167
model_config: {
161168
0: {
@@ -174,6 +181,7 @@ export const supplierList: Array<{
174181
{
175182
id: 7,
176183
name: 'OpenAI',
184+
i18nKey: 'supplier.openai',
177185
icon: icon_openai_colorful,
178186
model_config: {
179187
0: {
@@ -202,6 +210,7 @@ export const supplierList: Array<{
202210
{
203211
id: 8,
204212
name: 'Kimi',
213+
i18nKey: 'supplier.kimi',
205214
icon: icon_kimi_colorful,
206215
model_config: {
207216
0: {
@@ -232,6 +241,7 @@ export const supplierList: Array<{
232241
{
233242
id: 9,
234243
name: '腾讯云',
244+
i18nKey: 'supplier.tencent_cloud',
235245
icon: icon_txy_colorful,
236246
model_config: {
237247
0: {
@@ -249,6 +259,7 @@ export const supplierList: Array<{
249259
{
250260
id: 10,
251261
name: '火山引擎',
262+
i18nKey: 'supplier.volcano_engine',
252263
icon: icon_hsyq_colorful,
253264
model_config: {
254265
0: {
@@ -311,6 +322,7 @@ export const supplierList: Array<{
311322
{
312323
id: 15,
313324
name: '通用OpenAI',
325+
i18nKey: 'supplier.generic_openai',
314326
icon: icon_common_openai,
315327
is_private: true,
316328
model_config: {

frontend/src/i18n/en.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,5 +716,21 @@
716716
"platform_disable": "{0} settings are not enabled!",
717717
"input_account": "Please enter account",
718718
"redirect_2_auth": "Redirecting to {0} authentication, {1} seconds..."
719+
},
720+
"supplier": {
721+
"alibaba_cloud_bailian": "Alibaba Cloud Bailian",
722+
"qianfan_model": "Qianfan Model",
723+
"deepseek": "DeepSeek",
724+
"tencent_hunyuan": "Tencent Hunyuan",
725+
"iflytek_spark": "iFlytek Spark",
726+
"gemini": "Gemini",
727+
"openai": "OpenAI",
728+
"kimi": "Kimi",
729+
"tencent_cloud": "Tencent Cloud",
730+
"volcano_engine": "Volcano Engine",
731+
"generic_openai": "Generic OpenAI"
732+
},
733+
"modelType": {
734+
"llm": "Large Language Model"
719735
}
720736
}

frontend/src/i18n/ko-KR.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,5 +716,21 @@
716716
"platform_disable": "{0} 설정이 활성화되지 않았습니다!",
717717
"input_account": "계정을 입력해 주세요",
718718
"redirect_2_auth": "{0} 인증으로 리디렉션 중입니다, {1}초..."
719+
},
720+
"supplier": {
721+
"alibaba_cloud_bailian": "알리바바 클라우드 바이리엔",
722+
"qianfan_model": "치엔판 모델",
723+
"deepseek": "DeepSeek",
724+
"tencent_hunyuan": "텐센트 훈위안",
725+
"iflytek_spark": "아이플라이텍 스파크",
726+
"gemini": "Gemini",
727+
"openai": "OpenAI",
728+
"kimi": "Kimi",
729+
"tencent_cloud": "텐센트 클라우드",
730+
"volcano_engine": "볼케이노 엔진",
731+
"generic_openai": "범용 OpenAI"
732+
},
733+
"modelType": {
734+
"llm": "대형 언어 모델"
719735
}
720736
}

frontend/src/i18n/zh-CN.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,5 +716,21 @@
716716
"platform_disable": "{0}设置未开启!",
717717
"input_account": "请输入账号",
718718
"redirect_2_auth": "正在跳转至 {0} 认证,{1} 秒..."
719+
},
720+
"supplier": {
721+
"alibaba_cloud_bailian": "阿里云百炼",
722+
"qianfan_model": "千帆大模型",
723+
"deepseek": "DeepSeek",
724+
"tencent_hunyuan": "腾讯混元",
725+
"iflytek_spark": "讯飞星火",
726+
"gemini": "Gemini",
727+
"openai": "OpenAI",
728+
"kimi": "Kimi",
729+
"tencent_cloud": "腾讯云",
730+
"volcano_engine": "火山引擎",
731+
"generic_openai": "通用OpenAI"
732+
},
733+
"modelType": {
734+
"llm": "大语言模型"
719735
}
720736
}

frontend/src/views/system/model/Card.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ defineExpose({ showErrorMask })
6969
</div>
7070
<div class="type-value">
7171
<span class="type">{{ $t('model.model_type') }}</span>
72-
<span class="value"> {{ modelType }}</span>
72+
<span class="value"> {{ modelType.startsWith('modelType.') ? $t(modelType) : modelType }}</span>
7373
</div>
7474
<div class="type-value">
7575
<span class="type">{{ $t('model.basic_model') }}</span>

frontend/src/views/system/model/Model.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const searchLoading = ref(false)
3333
const editModel = ref(false)
3434
const activeStep = ref(0)
3535
const activeName = ref('')
36+
const activeNameI18nKey = ref('')
3637
const activeType = ref('')
3738
const modelFormRef = ref()
3839
const cardRefs = ref<any[]>([])
@@ -185,6 +186,7 @@ const handleEditModel = (row: any) => {
185186
editModel.value = true
186187
activeType.value = row.supplier
187188
activeName.value = row.supplier_item.name
189+
activeNameI18nKey.value = row.supplier_item.i18nKey
188190
modelApi.query(row.id).then((res: any) => {
189191
modelConfigvVisible.value = true
190192
nextTick(() => {
@@ -256,6 +258,7 @@ const clickModel = (ele: any) => {
256258
257259
const supplierChang = (ele: any) => {
258260
activeName.value = ele.name
261+
activeNameI18nKey.value = ele.i18nKey
259262
nextTick(() => {
260263
modelFormRef.value.supplierChang({ ...ele })
261264
})
@@ -425,7 +428,7 @@ const submit = (item: any) => {
425428
>
426429
<template #header="{ close }">
427430
<span style="white-space: nowrap">{{
428-
editModel ? $t('dashboard.edit') + $t('common.empty') + activeName : t('model.add_model')
431+
editModel ? $t('dashboard.edit') + $t('common.empty') + $t(activeNameI18nKey) : t('model.add_model')
429432
}}</span>
430433
<div v-if="!editModel" class="flex-center" style="width: 100%">
431434
<el-steps custom style="max-width: 500px; flex: 1" :active="activeStep" align-center>

frontend/src/views/system/model/ModelForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ defineExpose({
308308
<el-option
309309
v-for="item in modelTypeOptions"
310310
:key="item.value"
311-
:label="item.label"
311+
:label="item.i18nKey ? $t(item.i18nKey) : item.label"
312312
:value="item.value"
313313
/>
314314
</el-select>

frontend/src/views/system/model/ModelList.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
<script lang="ts" setup>
22
import { ref, computed } from 'vue'
3+
import { useI18n } from 'vue-i18n'
34
import icon_searchOutline_outlined from '@/assets/svg/icon_search-outline_outlined.svg'
45
import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue'
56
import { supplierList } from '@/entity/supplier'
67
8+
const { t } = useI18n()
79
const keywords = ref('')
810
911
const modelListWithSearch = computed(() => {
1012
if (!keywords.value) return supplierList
11-
return supplierList.filter((ele) => ele.name.toLowerCase().includes(keywords.value.toLowerCase()))
13+
return supplierList.filter((ele) => {
14+
if (!ele.i18nKey) {
15+
return ele.name.toLowerCase().includes(keywords.value.toLowerCase())
16+
}
17+
const translatedName = t(ele.i18nKey).toLowerCase()
18+
const originalName = ele.name.toLowerCase()
19+
const searchTerm = keywords.value.toLowerCase()
20+
return translatedName.includes(searchTerm) || originalName.includes(searchTerm)
21+
})
1222
})
1323
const emits = defineEmits(['clickModel'])
1424
const handleModelClick = (item: any) => {
@@ -39,7 +49,7 @@ const handleModelClick = (item: any) => {
3949
@click="handleModelClick(ele)"
4050
>
4151
<img width="32px" height="32px" :src="ele.icon" />
42-
<span class="name">{{ ele.name }}</span>
52+
<span class="name">{{ ele.i18nKey ? $t(ele.i18nKey) : ele.name }}</span>
4353
</div>
4454
<EmptyBackground
4555
v-if="!!keywords && !modelListWithSearch.length"

frontend/src/views/system/model/ModelListSide.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<script lang="ts" setup>
22
import { ref, computed } from 'vue'
3+
import { useI18n } from 'vue-i18n'
34
import icon_searchOutline_outlined from '@/assets/svg/icon_search-outline_outlined.svg'
45
import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue'
56
import { supplierList } from '@/entity/supplier'
67
8+
const { t } = useI18n()
79
withDefaults(
810
defineProps<{
911
activeName: string
@@ -16,7 +18,12 @@ const keywords = ref('')
1618
1719
const modelListWithSearch = computed(() => {
1820
if (!keywords.value) return supplierList
19-
return supplierList.filter((ele) => ele.name.toLowerCase().includes(keywords.value.toLowerCase()))
21+
return supplierList.filter((ele) => {
22+
const translatedName = t(ele.i18nKey).toLowerCase()
23+
const originalName = ele.name.toLowerCase()
24+
const searchTerm = keywords.value.toLowerCase()
25+
return translatedName.includes(searchTerm) || originalName.includes(searchTerm)
26+
})
2027
})
2128
const emits = defineEmits(['clickModel'])
2229
const handleModelClick = (item: any) => {
@@ -47,7 +54,7 @@ const handleModelClick = (item: any) => {
4754
@click="handleModelClick(ele)"
4855
>
4956
<img width="18px" height="18px" :src="ele.icon" />
50-
<span class="name">{{ ele.name }}</span>
57+
<span class="name">{{ $t(ele.i18nKey) }}</span>
5158
</div>
5259
<EmptyBackground
5360
v-if="!!keywords && !modelListWithSearch.length"

0 commit comments

Comments
 (0)