Skip to content

Commit 9cb076b

Browse files
feat: i18n
1 parent ab597af commit 9cb076b

File tree

3 files changed

+51
-22
lines changed

3 files changed

+51
-22
lines changed

ui/src/locales/lang/zh_CN/views/function-lib.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,27 @@ export default {
4646
placeholder: '请输入参数值',
4747
requiredMessage: '请输入参数值'
4848
},
49+
paramName: {
50+
label: '参数名',
51+
placeholder: '请输入参数名',
52+
requiredMessage: '请输入参数名'
53+
},
54+
dataType: {
55+
label: '数据类型',
56+
},
57+
source: {
58+
label: '来源',
59+
custom: '自定义',
60+
reference: '引用参数',
61+
},
62+
required: {
63+
label: '是否必填',
64+
},
4965
param: {
5066
outputParam: '输出参数',
5167
paramInfo1: '使用函数时显示',
5268
paramInfo2: '使用函数时不显示',
53-
paramName: '参数名',
54-
dataType: '数据类型',
5569
required: '必填',
56-
source: '来源',
57-
custom: '自定义',
58-
referenceParam: '引用参数',
5970
code: '代码',
6071
result: '结果'
6172
},

ui/src/views/function-lib/component/FieldFormDialog.vue

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<template>
22
<el-dialog
3-
:title="isEdit ? '编辑参数' : '添加参数'"
3+
:title="
4+
isEdit
5+
? $t('views.functionLib.functionForm.title.editParam')
6+
: $t('views.functionLib.functionForm.title.addParam')
7+
"
48
v-model="dialogVisible"
59
:close-on-click-modal="false"
610
:close-on-press-escape="false"
@@ -14,33 +18,42 @@
1418
:model="form"
1519
require-asterisk-position="right"
1620
>
17-
<el-form-item label="参数名" prop="name">
21+
<el-form-item :label="$t('views.functionLib.functionForm.form.paramName.label')" prop="name">
1822
<el-input
1923
v-model="form.name"
20-
placeholder="请输入参数名"
24+
:placeholder="$t('views.functionLib.functionForm.form.paramName.placeholder')"
2125
maxlength="64"
2226
show-word-limit
2327
@blur="form.name = form.name.trim()"
2428
/>
2529
</el-form-item>
26-
<el-form-item label="数据类型">
30+
<el-form-item :label="$t('views.functionLib.functionForm.form.dataType.label')">
2731
<el-select v-model="form.type">
2832
<el-option v-for="item in typeOptions" :key="item" :label="item" :value="item" />
2933
</el-select>
3034
</el-form-item>
31-
<el-form-item label="来源">
35+
<el-form-item :label="$t('views.functionLib.functionForm.form.source.label')">
3236
<el-select v-model="form.source">
33-
<el-option label="引用变量" value="reference" />
34-
<el-option label="自定义" value="custom" />
37+
<el-option
38+
:label="$t('views.functionLib.functionForm.form.source.reference')"
39+
value="reference"
40+
/>
41+
<el-option
42+
:label="$t('views.functionLib.functionForm.form.source.custom')"
43+
value="custom"
44+
/>
3545
</el-select>
3646
</el-form-item>
37-
<el-form-item label="是否必填" @click.prevent>
47+
<el-form-item
48+
:label="$t('views.functionLib.functionForm.form.required.label')"
49+
@click.prevent
50+
>
3851
<el-switch size="small" v-model="form.is_required"></el-switch>
3952
</el-form-item>
4053
</el-form>
4154
<template #footer>
4255
<span class="dialog-footer">
43-
<el-button @click.prevent="dialogVisible = false"> {{$t('common.cancel')}} </el-button>
56+
<el-button @click.prevent="dialogVisible = false"> {{ $t('common.cancel') }} </el-button>
4457
<el-button type="primary" @click="submit(fieldFormRef)" :loading="loading">
4558
{{ isEdit ? $t('common.save') : $t('common.add') }}
4659
</el-button>
@@ -52,7 +65,7 @@
5265
import { ref, reactive, watch } from 'vue'
5366
import type { FormInstance } from 'element-plus'
5467
import { cloneDeep } from 'lodash'
55-
68+
import { t } from '@/locales'
5669
const typeOptions = ['string', 'int', 'dict', 'array', 'float']
5770
5871
const emit = defineEmits(['refresh'])
@@ -69,7 +82,13 @@ const form = ref<any>({
6982
})
7083
7184
const rules = reactive({
72-
name: [{ required: true, message: '请输入参数名', trigger: 'blur' }]
85+
name: [
86+
{
87+
required: true,
88+
message: t('views.functionLib.functionForm.form.paramName.placeholder'),
89+
trigger: 'blur'
90+
}
91+
]
7392
})
7493
7594
const dialogVisible = ref<boolean>(false)
@@ -95,7 +114,6 @@ const open = (row: any) => {
95114
dialogVisible.value = true
96115
}
97116
98-
99117
const submit = async (formEl: FormInstance | undefined) => {
100118
if (!formEl) return
101119
await formEl.validate((valid) => {

ui/src/views/function-lib/component/FunctionFormDrawer.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@
8080
<el-table :data="form.input_field_list" class="mb-16">
8181
<el-table-column
8282
prop="name"
83-
:label="$t('views.functionLib.functionForm.form.param.paramName')"
83+
:label="$t('views.functionLib.functionForm.form.paramName.label')"
8484
/>
85-
<el-table-column :label="$t('views.functionLib.functionForm.form.param.dataType')">
85+
<el-table-column :label="$t('views.functionLib.functionForm.form.dataType.label')">
8686
<template #default="{ row }">
8787
<el-tag type="info" class="info-tag">{{ row.type }}</el-tag>
8888
</template>
@@ -96,13 +96,13 @@
9696
</el-table-column>
9797
<el-table-column
9898
prop="source"
99-
:label="$t('views.functionLib.functionForm.form.param.source')"
99+
:label="$t('views.functionLib.functionForm.form.source.label')"
100100
>
101101
<template #default="{ row }">
102102
{{
103103
row.source === 'custom'
104-
? $t('views.functionLib.functionForm.form.param.custom')
105-
: $t('views.functionLib.functionForm.form.param.referenceParam')
104+
? $t('views.functionLib.functionForm.form.source.custom')
105+
: $t('views.functionLib.functionForm.form.source.reference')
106106
}}
107107
</template>
108108
</el-table-column>

0 commit comments

Comments
 (0)