Merge pull request #12611 from dataease/pr@dev-v2_st

feat(数据源): 国际化
This commit is contained in:
dataeaseShu 2024-10-10 14:29:20 +08:00 committed by GitHub
commit a26d40450b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 164 additions and 51 deletions

View File

@ -189,6 +189,49 @@ export default {
cannot_be_empty_: 'Filter field cannot be empty',
cannot_be_empty_de_ruler: 'Rule condition cannot be empty'
},
data_source: {
the_request_address: 'Please enter the request address',
name_already_exists: 'A parameter with the same name already exists:',
name_already_exists_de: 'A parameter table with the same name already exists',
verification_failed: 'Verification failed',
interface_parameters: 'Interface parameters',
extract_parameters: 'Extract parameters',
view_data_structure: 'View data structure',
the_data_structure: 'There is no data yet, please check the fields in the data structure',
parameter: 'parameter',
fixed_value: 'fixed value',
time_function: 'time function',
customize: 'Customize',
that_day: 'that day',
value: 'value',
name_use_parameters: 'Available ${parameter name}, use parameters',
add_parameters: 'Add parameters',
data_source_name: 'Data source name',
data_source_name_de: 'Please enter the data source name',
a_folder_name: 'Please enter a folder name',
data_source: 'data source',
the_destination_folder: 'Please select the destination folder',
source_saved_successfully: 'Data source saved successfully',
relevant_content_found: 'No relevant content found',
recently_created: 'Recently created',
cannot_be_empty: 'SSH host cannot be empty',
cannot_be_empty_de: 'SSH port cannot be empty',
cannot_be_empty_de_name: 'SSH username cannot be empty',
cannot_be_empty_de_pwd: 'SSH password cannot be empty',
cannot_be_empty_d_key: 'SSH key cannot be empty',
enter_parameter_name: 'Please enter parameter name',
to_64_characters: 'Parameter names are limited to 2 to 64 characters',
the_interface_name: 'Please enter the interface name',
to_64_characters_de: 'The interface name is limited to 2 to 64 characters.',
sure_to_delete: 'Are you sure to delete?',
rename: 'Rename',
delete: 'delete',
source_configuration_information: 'Data source configuration information',
data_update_settings: 'Data update settings',
connection_method: 'Connection method',
hostname: 'hostname',
jdbc_connection: 'JDBC connection'
},
login: {
welcome: 'Welcome',
btn: 'Login',

View File

@ -206,6 +206,49 @@ export default {
cannot_be_empty_: '过滤字段不能为空',
cannot_be_empty_de_ruler: '规则条件不能为空'
},
data_source: {
the_request_address: '请输入请求地址',
name_already_exists: '已经存在同名参数',
name_already_exists_de: '已经存在同名的参数表',
verification_failed: '校验失败',
interface_parameters: '接口参数',
extract_parameters: '提取参数',
view_data_structure: '查看数据结构',
the_data_structure: '暂无数据请在数据结构勾选字段',
parameter: '参数',
fixed_value: '固定值',
time_function: '时间函数',
customize: '自定义',
that_day: '当天',
value: '值',
name_use_parameters: '可用${参数名}使用参数',
add_parameters: '添加参数',
data_source_name: '数据源名称',
data_source_name_de: '请输入数据源名称',
a_folder_name: '请输入文件夹名称',
data_source: '数据源',
the_destination_folder: '请选择目标文件夹',
source_saved_successfully: '保存数据源成功',
relevant_content_found: '没有找到相关内容',
recently_created: '最近创建',
cannot_be_empty: 'SSH主机不能为空',
cannot_be_empty_de: 'SSH端口不能为空',
cannot_be_empty_de_name: 'SSH用户名不能为空',
cannot_be_empty_de_pwd: 'SSH密码不能为空',
cannot_be_empty_de_key: 'SSH key不能为空',
enter_parameter_name: '请输入参数名称',
to_64_characters: '参数名称限制264字符',
the_interface_name: '请输入接口名称',
to_64_characters_de: '接口名称限制264字符',
sure_to_delete: '确定删除吗?',
rename: '重命名',
delete: '删除',
source_configuration_information: '数据源配置信息',
data_update_settings: '数据更新设置',
connection_method: '连接方式',
hostname: '主机名',
jdbc_connection: 'JDBC 连接'
},
dynamic_time: {
set_default: '设置默认值',
fix: '固定时间',

View File

@ -145,7 +145,7 @@ const rule = reactive<FormRules>({
url: [
{
required: true,
message: '请输入请求地址',
message: t('data_source.the_request_address'),
trigger: 'blur'
}
],
@ -229,7 +229,7 @@ const saveItem = () => {
apiItem.fields[i].name === paramsList[j].fields[k].name &&
apiItem.serialNumber !== paramsList[j].serialNumber
) {
ElMessage.error('已经存在同名参数:' + apiItem.fields[i].name)
ElMessage.error(t('data_source.name_already_exists') + apiItem.fields[i].name)
return
}
}
@ -263,7 +263,7 @@ const next = () => {
paramsList[i].name === apiItem.name &&
apiItem.serialNumber !== paramsList[i].serialNumber
) {
ElMessage.error('已经存在同名的参数表')
ElMessage.error(t('data_source.name_already_exists_de'))
return
}
}
@ -321,7 +321,7 @@ const validate = () => {
ElMessage.success(t('datasource.validate_success'))
})
.catch(() => {
ElMessage.error('校验失败')
ElMessage.error(t('data_source.verification_failed'))
})
}
})
@ -444,7 +444,9 @@ defineExpose({
<template>
<el-drawer
:title="activeName === 'table' ? t('datasource.data_table') : '接口参数'"
:title="
activeName === 'table' ? t('datasource.data_table') : t('data_source.interface_parameters')
"
v-model="edit_api_item"
custom-class="api-datasource-drawer"
size="840px"
@ -470,7 +472,9 @@ defineExpose({
{{ active <= 1 ? '2' : '' }}
</span>
<span class="title">{{
activeName === 'table' ? t('datasource.api_step_2') : '提取参数'
activeName === 'table'
? t('datasource.api_step_2')
: t('data_source.extract_parameters')
}}</span>
</div>
</template>
@ -557,7 +561,9 @@ defineExpose({
</el-select>
</template>
<template #append>
<el-button @click="showApiData">查看数据结构 </el-button>
<el-button @click="showApiData"
>{{ t('data_source.view_data_structure') }}
</el-button>
</template>
</el-input>
</el-form-item>
@ -704,7 +710,7 @@ defineExpose({
>
<empty-background
v-if="showEmpty"
description="暂无数据,请在数据结构勾选字段"
:description="t('data_source.the_data_structure')"
img-type="select"
/>
<el-auto-resizer v-else>

View File

@ -86,30 +86,30 @@ const createFilter = (queryString: string) => {
}
const options = [
{
label: '参数',
label: t('data_source.parameter'),
value: 'params'
},
{
label: '固定值',
label: t('data_source.fixed_value'),
value: 'fixed'
},
{
label: '时间函数',
label: t('data_source.time_function'),
value: 'timeFun'
},
{
label: '自定义',
label: t('data_source.customize'),
value: 'custom'
}
]
const timeFunLists = [
{
label: '当天yyyy-MM-dd',
label: t('data_source.that_day') + 'yyyy-MM-dd',
value: 'currentDay yyyy-MM-dd'
},
{
label: '当天yyyy/MM/dd',
label: t('data_source.that_day') + 'yyyy/MM/dd',
value: 'currentDay yyyy/MM/dd'
}
]
@ -204,7 +204,11 @@ const timeFunLists = [
"
v-model="element.value"
:disabled="isReadOnly"
:placeholder="element.nameType === 'fixed' ? '值' : '可用${参数名},使用参数'"
:placeholder="
element.nameType === 'fixed'
? t('data_source.value')
: t('data_source.name_use_parameters')
"
show-word-limit
/>
</el-col>
@ -236,7 +240,7 @@ const timeFunLists = [
<template #icon>
<icon name="icon_add_outlined"><icon_add_outlined class="svg-icon" /></icon>
</template>
添加参数
{{ t('data_source.add_parameters') }}
</el-button>
</div>
</template>

View File

@ -106,29 +106,29 @@ const changeNameType = element => {
const activeName = inject('api-active-name')
const options = [
{
label: '参数',
label: t('data_source.parameter'),
value: 'params'
},
{
label: '固定值',
label: t('data_source.fixed_value'),
value: 'fixed'
},
{
label: '时间函数',
label: t('data_source.time_function'),
value: 'timeFun'
},
{
label: '自定义',
label: t('data_source.customize'),
value: 'custom'
}
]
const timeFunLists = [
{
label: '当天yyyy-MM-dd',
label: t('data_source.that_day') + 'yyyy-MM-dd',
value: 'currentDay yyyy-MM-dd'
},
{
label: '当天yyyy/MM/dd',
label: t('data_source.that_day') + 'yyyy/MM/dd',
value: 'currentDay yyyy/MM/dd'
}
]
@ -230,7 +230,11 @@ const timeFunLists = [
v-model="element.value"
:disabled="isReadOnly"
class="input-with-autocomplete"
:placeholder="element.nameType === 'fixed' ? '值' : '可用${参数名},使用参数'"
:placeholder="
element.nameType === 'fixed'
? t('data_source.value')
: t('data_source.name_use_parameters')
"
value-key="name"
highlight-first-item
/>
@ -262,7 +266,7 @@ const timeFunLists = [
<template #icon>
<icon name="icon_add_outlined"><icon_add_outlined class="svg-icon" /></icon>
</template>
添加参数
{{ t('data_source.add_parameters') }}
</el-button>
</div>
</template>

View File

@ -70,7 +70,9 @@ const showPid = computed(() => {
})
const labelName = computed(() => {
return nodeType.value === 'folder' ? t('deDataset.folder_name') : '数据源名称'
return nodeType.value === 'folder'
? t('deDataset.folder_name')
: t('data_source.data_source_name')
})
const dialogTitle = computed(() => {
@ -135,7 +137,8 @@ const createInit = (type, data: Tree, exec, name: string) => {
datasetForm.name = ''
nodeType.value = type
filterText.value = ''
placeholder.value = type === 'folder' ? '请输入文件夹名称' : '请输入数据源名称'
placeholder.value =
type === 'folder' ? t('data_source.a_folder_name') : t('data_source.data_source_name_de')
dsType = data.type
if (type === 'datasource') {
request = data.request
@ -146,7 +149,7 @@ const createInit = (type, data: Tree, exec, name: string) => {
dfs(res as unknown as Tree[])
state.tData = (res as unknown as Tree[]) || []
if (state.tData.length && state.tData[0].name === 'root' && state.tData[0].id === '0') {
state.tData[0].name = '数据源'
state.tData[0].name = t('data_source.data_source')
}
})
}
@ -226,7 +229,7 @@ const finallyCb = () => {
}
const checkPid = pid => {
if (pid !== 0 && !pid) {
ElMessage.error('请选择目标文件夹')
ElMessage.error(t('data_source.the_destination_folder'))
return false
}
return true
@ -284,7 +287,7 @@ const saveDataset = () => {
if (res !== undefined) {
wsCache.set('ds-new-success', true)
emits('handleShowFinishPage', { ...res, pid: params.pid })
ElMessage.success('保存数据源成功')
ElMessage.success(t('data_source.source_saved_successfully'))
successCb()
}
})
@ -302,7 +305,7 @@ const saveDataset = () => {
if (res !== undefined) {
wsCache.set('ds-new-success', true)
emits('handleShowFinishPage', { ...res, pid: params.pid })
ElMessage.success('保存数据源成功')
ElMessage.success(t('data_source.source_saved_successfully'))
successCb()
}
})
@ -399,7 +402,7 @@ const emits = defineEmits(['finish', 'handleShowFinishPage'])
</el-tree>
<div v-if="searchEmpty" class="empty-search">
<img :src="nothingTree" />
<span>没有找到相关内容</span>
<span>{{ t('data_source.relevant_content_found') }}</span>
</div>
</div>
</div>

View File

@ -4,6 +4,7 @@ import { dsTypes, typeList, nameMap } from './option'
import Icon from '@/components/icon-custom/src/Icon.vue'
import { XpackComponent } from '@/components/plugin'
import { iconDatasourceMap } from '@/components/icon-group/datasource-list'
import { useI18n } from '@/hooks/web/useI18n'
export type DsType = 'OLTP' | 'OLAP' | 'DL' | 'OTHER' | 'LOCAL' | 'latestUse' | 'all'
const props = defineProps({
@ -19,6 +20,7 @@ const props = defineProps({
type: Array
}
})
const { t } = useI18n()
const databaseList = shallowRef([])
const currentTypeList = computed(() => {
@ -53,7 +55,7 @@ const currentTypeList = computed(() => {
})
})
dbList = dbList.filter(ele => ele.name.toLowerCase().includes(props.filterText.trim()))
dstypes.push({ name: '最近创建', dbList })
dstypes.push({ name: t('data_source.recently_created'), dbList })
return dstypes
}
const index = typeList.findIndex(ele => props.currentType === ele)

View File

@ -173,21 +173,21 @@ const authMethodList = [
const validateSshHost = (_: any, value: any, callback: any) => {
if ((value === undefined || value === null || value === '') && form.value.configuration.useSSH) {
callback(new Error('SSH主机不能为空'))
callback(new Error(t('data_source.cannot_be_empty')))
}
return callback()
}
const validateSshPort = (_: any, value: any, callback: any) => {
if ((value === undefined || value === null || value === '') && form.value.configuration.useSSH) {
callback(new Error('SSH端口不能为空'))
callback(new Error(t('data_source.cannot_be_empty_de')))
}
return callback()
}
const validateSshUserName = (_: any, value: any, callback: any) => {
if ((value === undefined || value === null || value === '') && form.value.configuration.useSSH) {
callback(new Error('SSH用户名不能为空'))
callback(new Error(t('data_source.cannot_be_empty_de_name')))
}
return callback()
}
@ -198,7 +198,7 @@ const validateSshPassword = (_: any, value: any, callback: any) => {
form.value.configuration.useSSH &&
form.value.configuration.sshType === 'password'
) {
callback(new Error('SSH密码不能为空'))
callback(new Error(t('data_source.cannot_be_empty_de_pwd')))
}
return callback()
}
@ -209,7 +209,7 @@ const validateSshkey = (_: any, value: any, callback: any) => {
form.value.configuration.useSSH &&
form.value.configuration.sshType === 'sshkey'
) {
callback(new Error('SSH key不能为空'))
callback(new Error(t('data_source.cannot_be_empty_de_key')))
}
return callback()
}
@ -586,13 +586,13 @@ const paramsObjRules = {
name: [
{
required: true,
message: '请输入参数名称',
message: t('data_source.enter_parameter_name'),
trigger: 'change'
},
{
min: 2,
max: 64,
message: '参数名称限制264字符',
message: t('data_source.to_64_characters'),
trigger: 'blur'
}
]
@ -602,13 +602,13 @@ const apiObjRules = {
name: [
{
required: true,
message: '请输入接口名称',
message: t('data_source.the_interface_name'),
trigger: 'change'
},
{
min: 2,
max: 64,
message: '接口名称限制264字符',
message: t('data_source.to_64_characters_de'),
trigger: 'blur'
}
]
@ -663,7 +663,7 @@ const handleApiParams = (cmd: string, data) => {
apiObj.value.serialNumber = data.serialNumber
}
if (cmd === 'delete') {
ElMessageBox.confirm('确定删除吗?', {
ElMessageBox.confirm(t('data_source.sure_to_delete'), {
confirmButtonType: 'danger',
type: 'warning',
autofocus: false,
@ -691,7 +691,7 @@ const editParams = data => {
}
const delParams = data => {
ElMessageBox.confirm('确定删除吗?', {
ElMessageBox.confirm(t('data_source.sure_to_delete'), {
confirmButtonType: 'danger',
type: 'warning',
autofocus: false,
@ -702,12 +702,12 @@ const delParams = data => {
}
const datasetTypeList = [
{
label: '重命名',
label: t('data_source.rename'),
svgName: icon_rename_outlined,
command: 'rename'
},
{
label: '删除',
label: t('data_source.delete'),
svgName: icon_deleteTrash_outlined,
command: 'delete'
}
@ -724,9 +724,13 @@ defineExpose({
<div class="editor-detail">
<div class="detail-inner create-dialog">
<div v-show="form.type === 'API'" class="info-update">
<div :class="activeStep === 1 && 'active'" class="info-text">数据源配置信息</div>
<div :class="activeStep === 1 && 'active'" class="info-text">
{{ t('data_source.source_configuration_information') }}
</div>
<div class="update-info-line"></div>
<div :class="activeStep === 2 && 'active'" class="update-text">数据更新设置</div>
<div :class="activeStep === 2 && 'active'" class="update-text">
{{ t('data_source.data_update_settings') }}
</div>
</div>
<div class="title-form_primary base-info" v-show="activeStep !== 2 && form.type === 'API'">
{{ t('datasource.basic_info') }}
@ -766,7 +770,7 @@ defineExpose({
<div class="title-form_primary flex-space table-info-mr" v-show="activeStep !== 2">
<el-tabs v-model="activeName" class="api-tabs">
<el-tab-pane :label="t('datasource.data_table')" name="table"></el-tab-pane>
<el-tab-pane label="接口参数" name="params"></el-tab-pane>
<el-tab-pane :label="t('data_source.connection_method')" name="params"></el-tab-pane>
</el-tabs>
<el-button type="primary" style="margin-left: auto" @click="() => addApiItem(null)">
<template #icon>
@ -928,10 +932,14 @@ defineExpose({
</div>
</template>
<template v-if="notapiexcelconfig">
<el-form-item label="连接方式" prop="type" v-if="form.type !== 'es'">
<el-form-item
:label="t('data_source.connection_method')"
prop="type"
v-if="form.type !== 'es'"
>
<el-radio-group v-model="form.configuration.urlType">
<el-radio label="hostName">主机名</el-radio>
<el-radio label="jdbcUrl">JDBC 连接</el-radio>
<el-radio label="hostName">{{ t('data_source.hostname') }}</el-radio>
<el-radio label="jdbcUrl">{{ t('data_source.jdbc_connection') }}</el-radio>
</el-radio-group>
</el-form-item>