Skip to content

Commit 3c2c124

Browse files
committed
feat: Internationalization
1 parent ad6074d commit 3c2c124

File tree

13 files changed

+196
-104
lines changed

13 files changed

+196
-104
lines changed

frontend/src/i18n/en.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"AI Model Configuration": "AI Model Configuration"
77
},
88
"common": {
9+
"empty": " ",
910
"back": "Back",
1011
"confirm": "Confirm",
1112
"cancel": "Cancel",
@@ -157,14 +158,43 @@
157158
"table_notes": "Table notes",
158159
"field_notes": "Field notes",
159160
"select_all": "Select all",
160-
"mysql_data_source": "Modify MySQL data source",
161+
"mysql_data_source": "Modify {msg} data source",
161162
"configuration_information": "Configuration information",
162163
"data_source": "Do you want to delete the data source: {msg}?",
163164
"operate_with_caution": "After being deleted, the data source cannot be intelligently counted. Please operate with caution.",
164165
"data_source_de": "Unable to delete data source: {msg}",
165166
"cannot_be_deleted": "The chart of the dashboard uses this data source and cannot be deleted.",
166167
"got_it": "Got it"
167168
},
169+
"model": {
170+
"default_model": "Default model",
171+
"model_type": "Model type",
172+
"basic_model": "Basic model",
173+
"set_successfully": "Set successfully",
174+
"operate_with_caution": "After the system default model is replaced, the result of intelligent question will be affected, please operate with caution.",
175+
"system_default_model": "Do you want to set {msg} as the system default model?",
176+
"ai_model_configuration": "AI model configuration",
177+
"system_default_model_de": "System default model",
178+
"relevant_results_found": "No relevant results found",
179+
"add_model": "Add model",
180+
"select_supplier": "Select supplier",
181+
"the_basic_model": "Please set a name for the basic model",
182+
"the_basic_model_de": "Please select the basic model",
183+
"model_name": "Model name",
184+
"custom_model_name": "Custom model name",
185+
"enter_to_add": "For models not listed in the list, just enter the model name and press Enter to add",
186+
"api_domain_name": "API domain name",
187+
"advanced_settings": "Advanced settings",
188+
"model_parameters": "Model parameters",
189+
"add": "Add",
190+
"parameters": "Parameters",
191+
"display_name": "Display name",
192+
"parameter_value": "Parameter value",
193+
"text": "Text",
194+
"number": "Number",
195+
"parameter_type": "Parameter type",
196+
"verification_successful": "Verification successful"
197+
},
168198
"chat": {
169199
"chart_type": {
170200
"table": "Table",

frontend/src/i18n/zh-CN.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"AI Model Configuration": "模型配置"
77
},
88
"common": {
9+
"empty": "",
910
"back": "返回",
1011
"confirm": "确认",
1112
"cancel": "取消",
@@ -157,14 +158,43 @@
157158
"table_notes": "表备注",
158159
"field_notes": "字段备注",
159160
"select_all": "全选",
160-
"mysql_data_source": "修改 MySQL 数据源",
161+
"mysql_data_source": "修改 {msg} 数据源",
161162
"configuration_information": "配置信息",
162163
"data_source": "是否删除数据源:{msg}?",
163164
"operate_with_caution": "被删除后,将无法对该数据源进行智能问数,请谨慎操作。",
164165
"data_source_de": "无法删除数据源:{msg}",
165166
"cannot_be_deleted": "仪表板的图表使用了该数据源,不可删除。",
166167
"got_it": "知道了"
167168
},
169+
"model": {
170+
"default_model": "默认模型",
171+
"model_type": "模型类型",
172+
"basic_model": "基础模型",
173+
"set_successfully": "设置成功",
174+
"operate_with_caution": "系统默认模型被替换后,智能问数的结果将会受到影响,请谨慎操作。",
175+
"system_default_model": "是否设置 {msg} 为系统默认模型?",
176+
"ai_model_configuration": "AI 模型配置",
177+
"system_default_model_de": "系统默认模型",
178+
"relevant_results_found": "没有找到相关结果",
179+
"add_model": "添加模型",
180+
"select_supplier": "选择供应商",
181+
"the_basic_model": "请给基础模型设置一个名称",
182+
"the_basic_model_de": "请选择基础模型",
183+
"model_name": "模型名称",
184+
"custom_model_name": "自定义的模型名称",
185+
"enter_to_add": "列表中未列出的模型,直接输入模型名称,回车即可添加",
186+
"api_domain_name": "API 域名",
187+
"advanced_settings": "高级设置",
188+
"model_parameters": "模型参数",
189+
"add": "添加",
190+
"parameters": "参数",
191+
"display_name": "显示名称",
192+
"parameter_value": "参数值",
193+
"text": "文本",
194+
"number": "数值",
195+
"parameter_type": "参数类型",
196+
"verification_successful": "校验成功"
197+
},
168198
"chat": {
169199
"chart_type": {
170200
"table": "明细表",

frontend/src/views/ds/Card.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<script lang="ts" setup>
2-
import azure from '@/assets/model/icon_Azure_OpenAI_colorful.png'
32
import delIcon from '@/assets/svg/icon_delete.svg'
43
import icon_more_outlined from '@/assets/svg/icon_more_outlined.svg'
54
import icon_form_outlined from '@/assets/svg/icon_form_outlined.svg'
65
import icon_chat_outlined from '@/assets/svg/icon_chat_outlined.svg'
7-
import { ref, unref } from 'vue'
6+
import { ref, unref, computed } from 'vue'
87
import { ClickOutside as vClickOutside } from 'element-plus-secondary'
9-
8+
import { dsTypeWithImg } from './js/ds-type'
109
import edit from '@/assets/svg/icon_edit_outlined.svg'
1110
1211
const props = withDefaults(
@@ -27,7 +26,9 @@ const props = withDefaults(
2726
)
2827
2928
const emits = defineEmits(['edit', 'del', 'question', 'dataTableDetail'])
30-
29+
const icon = computed(() => {
30+
return (dsTypeWithImg.find((ele) => props.type === ele.type) || {}).img
31+
})
3132
const handleEdit = () => {
3233
emits('edit')
3334
}
@@ -53,7 +54,7 @@ const onClickOutside = () => {
5354
<template>
5455
<div class="card" @click="dataTableDetail">
5556
<div class="name-icon">
56-
<img :src="azure" width="32px" height="32px" />
57+
<img :src="icon" width="32px" height="32px" />
5758
<div class="info">
5859
<div class="name">{{ name }}</div>
5960
<div class="type">{{ type }}</div>
@@ -80,9 +81,9 @@ const onClickOutside = () => {
8081
<el-icon
8182
ref="buttonRef"
8283
v-click-outside="onClickOutside"
83-
@click.stop
8484
class="more"
8585
size="16"
86+
@click.stop
8687
>
8788
<icon_more_outlined></icon_more_outlined>
8889
</el-icon>

frontend/src/views/ds/DataTable.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ const changeStatus = (row: any) => {
304304
@closed="closeTable"
305305
>
306306
<el-input
307-
:placeholder="$t('datasource.please_enter')"
308307
v-model="tableComment"
308+
:placeholder="$t('datasource.please_enter')"
309309
:rows="3"
310310
type="textarea"
311311
/>
@@ -324,8 +324,8 @@ const changeStatus = (row: any) => {
324324
@closed="closeField"
325325
>
326326
<el-input
327-
:placeholder="$t('datasource.please_enter')"
328327
v-model="fieldComment"
328+
:placeholder="$t('datasource.please_enter')"
329329
:rows="3"
330330
type="textarea"
331331
/>

frontend/src/views/ds/Datasource.vue

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ const formatKeywords = (item: string) => {
6464
`<span class="isSearch">${defaultDatasourceKeywords.value}</span>`
6565
)
6666
}
67-
67+
const currentType = ref('')
6868
const handleEditDatasource = (res: any) => {
6969
activeStep.value = 1
7070
datasourceConfigvVisible.value = true
7171
editDatasource.value = true
72+
currentType.value = res.type_name
7273
nextTick(() => {
7374
datasourceFormRef.value.initForm(res)
7475
})
@@ -80,14 +81,6 @@ const handleAddDatasource = () => {
8081
}
8182
8283
const deleteHandler = (item: any) => {
83-
ElMessageBox.confirm(t('datasource.data_source_de', { msg: item.name }), {
84-
tip: t('datasource.cannot_be_deleted'),
85-
cancelButtonText: t('datasource.got_it'),
86-
showConfirmButton: false,
87-
customClass: 'confirm-no_icon',
88-
autofocus: false,
89-
})
90-
return
9184
ElMessageBox.confirm(t('datasource.data_source', { msg: item.name }), {
9285
confirmButtonType: 'danger',
9386
tip: t('datasource.operate_with_caution'),
@@ -106,9 +99,12 @@ const deleteHandler = (item: any) => {
10699
})
107100
})
108101
.catch(() => {
109-
ElMessage({
110-
type: 'info',
111-
message: 'Delete canceled',
102+
ElMessageBox.confirm(t('datasource.data_source_de', { msg: item.name }), {
103+
tip: t('datasource.cannot_be_deleted'),
104+
cancelButtonText: t('datasource.got_it'),
105+
showConfirmButton: false,
106+
customClass: 'confirm-no_icon',
107+
autofocus: false,
112108
})
113109
})
114110
}
@@ -255,7 +251,11 @@ const dataTableDetail = (ele: any) => {
255251
:show-close="false"
256252
>
257253
<template #header="{ close }">
258-
<span style="white-space: nowrap">{{ $t('datasource.new_data_source') }}</span>
254+
<span style="white-space: nowrap">{{
255+
editDatasource
256+
? t('datasource.mysql_data_source', { msg: currentType })
257+
: $t('datasource.new_data_source')
258+
}}</span>
259259
<div v-if="!editDatasource" class="flex-center" style="width: 100%">
260260
<el-steps custom style="max-width: 500px; flex: 1" :active="activeStep" align-center>
261261
<el-step>

frontend/src/views/ds/DatasourceForm.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ const close = () => {
8888
const initForm = (item: any, editTable: boolean = false) => {
8989
isEditTable.value = false
9090
dsFormRef.value!.clearValidate()
91-
console.log('item', item)
92-
9391
if (item) {
9492
dialogTitle.value = editTable ? t('ds.form.title.choose_tables') : t('ds.form.title.edit')
9593
isCreate.value = false
@@ -198,8 +196,7 @@ const save = async (formEl: FormInstance | undefined) => {
198196
if (form.value.id) {
199197
if (!isEditTable.value) {
200198
// only update datasource config info
201-
datasourceApi.update(requestObj).then((res) => {
202-
console.log(res)
199+
datasourceApi.update(requestObj).then(() => {
203200
close()
204201
emit('refresh')
205202
})
@@ -212,8 +209,7 @@ const save = async (formEl: FormInstance | undefined) => {
212209
}
213210
} else {
214211
requestObj.tables = list
215-
datasourceApi.add(requestObj).then((res: any) => {
216-
console.log(res)
212+
datasourceApi.add(requestObj).then(() => {
217213
close()
218214
emit('refresh')
219215
})

frontend/src/views/ds/ParamsForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ defineExpose({
5353
<DatasourceForm
5454
ref="datasourceFormRef"
5555
:active-step="2"
56-
activeName=""
56+
active-name=""
5757
@change-active-step="changeActiveStep"
5858
@refresh="refresh"
5959
></DatasourceForm>

frontend/src/views/ds/form.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@ const save = async (formEl: FormInstance | undefined) => {
332332
if (form.value.id) {
333333
if (!isEditTable.value) {
334334
// only update datasource config info
335-
datasourceApi.update(requestObj).then((res) => {
336-
console.log(res)
335+
datasourceApi.update(requestObj).then(() => {
337336
close()
338337
emit('refresh')
339338
})
@@ -346,8 +345,7 @@ const save = async (formEl: FormInstance | undefined) => {
346345
}
347346
} else {
348347
requestObj.tables = list
349-
datasourceApi.add(requestObj).then((res: any) => {
350-
console.log(res)
348+
datasourceApi.add(requestObj).then(() => {
351349
close()
352350
emit('refresh')
353351
})

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ const handleDel = () => {
3636
<div class="name-icon">
3737
<img :src="azure" width="32px" height="32px" />
3838
<span class="name">{{ name }}</span>
39-
<span class="default">默认模型</span>
39+
<span class="default">{{ $t('model.default_model') }}</span>
4040
</div>
4141
<div class="type-value">
42-
<span class="type">模型类型</span>
42+
<span class="type">{{ $t('model.model_type') }}</span>
4343
<span class="value"> {{ modleType }}</span>
4444
</div>
4545
<div class="type-value">
46-
<span class="type">基础模型</span>
46+
<span class="type">{{ $t('model.basic_model') }}</span>
4747
<span class="value"> {{ baseModle }}</span>
4848
</div>
4949
<div class="methods">

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,22 @@ const modelListWithSearch = computed(() => {
6868
})
6969
const beforeClose = () => {
7070
modelConfigvVisible.value = false
71-
ElMessage.success('设置成功')
72-
ElMessageBox.confirm('是否设置 Azure OpenAI 123 为系统默认模型?', {
73-
confirmButtonType: 'primary',
74-
tip: '系统默认模型被替换后,智能问数的结果将会受到影响,请谨慎操作。',
75-
confirmButtonText: t('datasource.confirm'),
76-
cancelButtonText: t('common.cancel'),
77-
customClass: 'confirm-no_icon',
78-
autofocus: false,
79-
})
80-
ElMessageBox.confirm('是否设置 Azure OpenAI 123 为系统默认模型?', {
81-
confirmButtonType: 'danger',
82-
confirmButtonText: t('dashboard.delete'),
83-
cancelButtonText: t('common.cancel'),
84-
customClass: 'confirm-no_icon',
85-
autofocus: false,
86-
})
71+
ElMessage.success(t('model.set_successfully'))
72+
// ElMessageBox.confirm(t('model.system_default_model', { msg: msg}), {
73+
// confirmButtonType: 'primary',
74+
// tip: t('model.operate_with_caution'),
75+
// confirmButtonText: t('datasource.confirm'),
76+
// cancelButtonText: t('common.cancel'),
77+
// customClass: 'confirm-no_icon',
78+
// autofocus: false,
79+
// })
80+
// ElMessageBox.confirm(t('model.system_default_model', { msg: msg}), {
81+
// confirmButtonType: 'danger',
82+
// confirmButtonText: t('dashboard.delete'),
83+
// cancelButtonText: t('common.cancel'),
84+
// customClass: 'confirm-no_icon',
85+
// autofocus: false,
86+
// })
8787
}
8888
const defaultModelListWithSearch = computed(() => {
8989
if (!defaultModelKeywords.value) return defaultModelList.value
@@ -192,7 +192,7 @@ const submit = (item: any) => {
192192
<template>
193193
<div class="model-config">
194194
<div class="model-methods">
195-
<span class="title">AI 模型配置</span>
195+
<span class="title">{{ t('model.ai_model_configuration') }}</span>
196196
<div class="button-input">
197197
<el-input
198198
v-model="keywords"
@@ -213,7 +213,7 @@ const submit = (item: any) => {
213213
<template #icon>
214214
<icon_admin_outlined></icon_admin_outlined>
215215
</template>
216-
系统默认模型
216+
{{ t('model.system_default_model_de') }}
217217
</el-button></template
218218
>
219219
<div class="popover">
@@ -244,7 +244,7 @@ const submit = (item: any) => {
244244
</el-icon>
245245
</div>
246246
<div v-if="!defaultModelListWithSearch.length" class="popover-item empty">
247-
没有找到相关结果
247+
{{ t('model.relevant_results_found') }}
248248
</div>
249249
</div>
250250
</div>
@@ -254,7 +254,7 @@ const submit = (item: any) => {
254254
<template #icon>
255255
<icon_add_outlined></icon_add_outlined>
256256
</template>
257-
添加模型
257+
{{ t('model.add_model') }}
258258
</el-button>
259259
</div>
260260
</div>
@@ -286,14 +286,14 @@ const submit = (item: any) => {
286286
:show-close="false"
287287
>
288288
<template #header="{ close }">
289-
<span style="white-space: nowrap">添加模型</span>
289+
<span style="white-space: nowrap">{{ t('model.add_model') }}</span>
290290
<div v-if="!editModel" class="flex-center" style="width: 100%">
291291
<el-steps custom style="max-width: 500px; flex: 1" :active="activeStep" align-center>
292292
<el-step>
293-
<template #title> 选择供应商 </template>
293+
<template #title> {{ t('model.select_supplier') }} </template>
294294
</el-step>
295295
<el-step>
296-
<template #title> 添加模型 </template>
296+
<template #title> {{ t('model.add_model') }} </template>
297297
</el-step>
298298
</el-steps>
299299
</div>

0 commit comments

Comments
 (0)