Skip to content

Commit ad6074d

Browse files
committed
feat: Internationalization
1 parent cb809e3 commit ad6074d

File tree

15 files changed

+218
-90
lines changed

15 files changed

+218
-90
lines changed

frontend/src/components/layout/Workspace.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const handleDefaultWorkspaceChange = (item: any) => {
5656
v-model="workspaceKeywords"
5757
clearable
5858
style="width: 100%; margin-right: 12px"
59-
placeholder="通过名称搜索"
59+
:placeholder="$t('datasource.search_by_name')"
6060
>
6161
<template #prefix>
6262
<el-icon>

frontend/src/i18n/en.json

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"type": "Data Source Type",
6060
"status": "Status",
6161
"actions": "Actions",
62+
"pieces_in_total": "Showing {ms} records out of {msg}",
6263
"test_connection": "Test Connection",
6364
"connection_success": "Connection Successful",
6465
"connection_failed": "Connection Failed, Please Check Configuration",
@@ -135,9 +136,35 @@
135136
"success": "Connect success",
136137
"failed": "Connect failed"
137138
},
138-
"timeout":"Timeout(second)"
139+
"timeout": "Timeout(second)"
139140
}
140141
},
142+
"datasource": {
143+
"search_by_name": "Search by Name",
144+
"search": "Search",
145+
"all_types": "All types",
146+
"new_data_source": "New data source",
147+
"open_query": "Open query",
148+
"edit": "Edit",
149+
"source_connection_failed": "Data source connection failed",
150+
"confirm": "Confirm",
151+
"enabled_status": "Enabled status",
152+
"custom_notes": "Custom notes",
153+
"field_type": "Field type",
154+
"field_name": "Field name",
155+
"relevant_content_found": "No relevant content found",
156+
"please_enter": "Please enter",
157+
"table_notes": "Table notes",
158+
"field_notes": "Field notes",
159+
"select_all": "Select all",
160+
"mysql_data_source": "Modify MySQL data source",
161+
"configuration_information": "Configuration information",
162+
"data_source": "Do you want to delete the data source: {msg}?",
163+
"operate_with_caution": "After being deleted, the data source cannot be intelligently counted. Please operate with caution.",
164+
"data_source_de": "Unable to delete data source: {msg}",
165+
"cannot_be_deleted": "The chart of the dashboard uses this data source and cannot be deleted.",
166+
"got_it": "Got it"
167+
},
141168
"chat": {
142169
"chart_type": {
143170
"table": "Table",
@@ -174,4 +201,4 @@
174201
"back_community": "Restore to Community Edition",
175202
"confirm_tips": "Are you sure to restore to Community Edition?"
176203
}
177-
}
204+
}

frontend/src/i18n/zh-CN.json

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"name": "数据源名称",
5959
"type": "数据源类型",
6060
"status": "状态",
61+
"pieces_in_total": "显示 {ms} 条数据,共 {msg} 条",
6162
"actions": "操作",
6263
"test_connection": "测试连接",
6364
"connection_success": "连接成功",
@@ -135,9 +136,35 @@
135136
"success": "连接成功",
136137
"failed": "连接失败"
137138
},
138-
"timeout":"查询超时(秒)"
139+
"timeout": "查询超时(秒)"
139140
}
140141
},
142+
"datasource": {
143+
"search_by_name": "通过名称搜索",
144+
"search": "搜索",
145+
"all_types": "全部类型",
146+
"new_data_source": "新建数据源",
147+
"open_query": "开启问数",
148+
"edit": "编辑",
149+
"source_connection_failed": "数据源连接失败",
150+
"confirm": "确定",
151+
"enabled_status": "启用状态",
152+
"custom_notes": "自定义备注",
153+
"field_type": "字段类型",
154+
"field_name": "字段名称",
155+
"relevant_content_found": "没有找到相关内容",
156+
"please_enter": "请输入",
157+
"table_notes": "表备注",
158+
"field_notes": "字段备注",
159+
"select_all": "全选",
160+
"mysql_data_source": "修改 MySQL 数据源",
161+
"configuration_information": "配置信息",
162+
"data_source": "是否删除数据源:{msg}?",
163+
"operate_with_caution": "被删除后,将无法对该数据源进行智能问数,请谨慎操作。",
164+
"data_source_de": "无法删除数据源:{msg}",
165+
"cannot_be_deleted": "仪表板的图表使用了该数据源,不可删除。",
166+
"got_it": "知道了"
167+
},
141168
"chat": {
142169
"chart_type": {
143170
"table": "明细表",
@@ -174,4 +201,4 @@
174201
"back_community": "还原至社区版",
175202
"confirm_tips": "确定还原至社区版?"
176203
}
177-
}
204+
}

frontend/src/views/ds/Card.vue

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import delIcon from '@/assets/svg/icon_delete.svg'
44
import icon_more_outlined from '@/assets/svg/icon_more_outlined.svg'
55
import icon_form_outlined from '@/assets/svg/icon_form_outlined.svg'
66
import icon_chat_outlined from '@/assets/svg/icon_chat_outlined.svg'
7+
import { ref, unref } from 'vue'
8+
import { ClickOutside as vClickOutside } from 'element-plus-secondary'
79
810
import edit from '@/assets/svg/icon_edit_outlined.svg'
911
@@ -31,7 +33,7 @@ const handleEdit = () => {
3133
}
3234
3335
const handleDel = () => {
34-
emits('del', props.id)
36+
emits('del')
3537
}
3638
3739
const handleQuestion = () => {
@@ -41,6 +43,11 @@ const handleQuestion = () => {
4143
const dataTableDetail = () => {
4244
emits('dataTableDetail')
4345
}
46+
const buttonRef = ref()
47+
const popoverRef = ref()
48+
const onClickOutside = () => {
49+
unref(popoverRef).popperRef?.delayHide?.()
50+
}
4451
</script>
4552

4653
<template>
@@ -63,30 +70,43 @@ const dataTableDetail = () => {
6370
</el-icon>
6471
{{ rate }}
6572
</div>
66-
<div class="methods">
73+
<div click.stop class="methods">
6774
<el-button type="primary" style="margin-right: 8px" @click.stop="handleQuestion">
6875
<el-icon style="margin-right: 2px" size="12">
6976
<icon_chat_outlined></icon_chat_outlined>
7077
</el-icon>
71-
开启问数
78+
{{ $t('datasource.open_query') }}
7279
</el-button>
73-
<el-popover click.stop :teleported="false" popper-class="popover-card" placement="bottom">
74-
<template #reference>
75-
<el-icon class="more" size="16"> <icon_more_outlined></icon_more_outlined> </el-icon
76-
></template>
77-
80+
<el-icon
81+
ref="buttonRef"
82+
v-click-outside="onClickOutside"
83+
@click.stop
84+
class="more"
85+
size="16"
86+
>
87+
<icon_more_outlined></icon_more_outlined>
88+
</el-icon>
89+
<el-popover
90+
ref="popoverRef"
91+
:virtual-ref="buttonRef"
92+
virtual-triggering
93+
trigger="click"
94+
:teleported="false"
95+
popper-class="popover-card"
96+
placement="bottom"
97+
>
7898
<div class="content">
7999
<div class="item" @click.stop="handleEdit">
80100
<el-icon size="16">
81101
<edit></edit>
82102
</el-icon>
83-
编辑
103+
{{ $t('datasource.edit') }}
84104
</div>
85105
<div class="item" @click.stop="handleDel">
86106
<el-icon size="16">
87107
<delIcon></delIcon>
88108
</el-icon>
89-
删除
109+
{{ $t('dashboard.delete') }}
90110
</div>
91111
</div>
92112
</el-popover>

frontend/src/views/ds/DataTable.vue

Lines changed: 65 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ const tableListWithSearch = computed(() => {
5959
ele.name.toLowerCase().includes(keywords.value.toLowerCase())
6060
)
6161
})
62-
62+
const total = ref(1000)
63+
const showNum = ref(100)
6364
const currentTable = ref<any>({})
6465
const ds = ref<any>({})
6566
const btnSelect = ref('q')
@@ -169,7 +170,7 @@ const changeStatus = (row: any) => {
169170
<template>
170171
<div class="data-table no-padding">
171172
<div class="info">
172-
数据源
173+
{{ $t('ds.title') }}
173174
<el-icon size="12">
174175
<icon_right_outlined></icon_right_outlined>
175176
</el-icon>
@@ -178,12 +179,20 @@ const changeStatus = (row: any) => {
178179
<div class="content">
179180
<div class="side-list">
180181
<div class="select-table_top">
181-
数据表
182-
<el-icon size="18" @click="handleSelectTableList">
183-
<icon_form_outlined></icon_form_outlined>
184-
</el-icon>
182+
{{ $t('ds.tables') }}
183+
184+
<el-tooltip effect="dark" :content="$t('ds.form.choose_tables')" placement="top">
185+
<el-icon size="18" @click="handleSelectTableList">
186+
<icon_form_outlined></icon_form_outlined>
187+
</el-icon>
188+
</el-tooltip>
185189
</div>
186-
<el-input v-model="keywords" clearable style="width: 232px" placeholder="搜索">
190+
<el-input
191+
v-model="keywords"
192+
clearable
193+
style="width: 232px"
194+
:placeholder="$t('datasource.search')"
195+
>
187196
<template #prefix>
188197
<el-icon>
189198
<icon_searchOutline_outlined class="svg-icon" />
@@ -206,7 +215,7 @@ const changeStatus = (row: any) => {
206215
</div>
207216
<EmptyBackground
208217
v-if="!!keywords && !tableListWithSearch.length"
209-
:description="'没有找到相关内容'"
218+
:description="$t('datasource.relevant_content_found')"
210219
img-type="tree"
211220
style="width: 100%; margin-top: 100px"
212221
/>
@@ -217,7 +226,8 @@ const changeStatus = (row: any) => {
217226
<div class="table-name">
218227
<div class="name">{{ currentTable.table_name }}</div>
219228
<div class="notes">
220-
{{ currentTable.custom_comment }}
229+
{{ $t('about.remark') }}:
230+
{{ currentTable.custom_comment || '-' }}
221231
<el-icon style="margin-left: 8px; cursor: pointer" size="16" @click="editTable">
222232
<edit></edit>
223233
</el-icon>
@@ -235,22 +245,27 @@ const changeStatus = (row: any) => {
235245

236246
<div class="preview-or-schema">
237247
<el-table v-if="btnSelect === 'd'" :data="fieldList" style="width: 100%">
238-
<el-table-column prop="field_name" :label="t('ds.field.name')" width="180" />
239-
<el-table-column prop="field_type" :label="t('ds.field.type')" width="180" />
240-
<el-table-column prop="field_comment" :label="t('ds.field.comment')" />
241-
<el-table-column :label="t('ds.field.custom_comment')">
248+
<el-table-column prop="field_name" :label="t('datasource.field_name')" width="180" />
249+
<el-table-column prop="field_type" :label="t('datasource.field_type')" width="180" />
250+
<el-table-column prop="field_comment" :label="t('about.remark')" />
251+
<el-table-column :label="t('datasource.custom_notes')">
242252
<template #default="scope">
243253
<div class="field-comment">
244254
<span>{{ scope.row.custom_comment }}</span>
245-
<el-tooltip :offset="14" effect="dark" content="编辑" placement="top">
255+
<el-tooltip
256+
:offset="14"
257+
effect="dark"
258+
:content="$t('datasource.edit')"
259+
placement="top"
260+
>
246261
<el-icon class="action-btn" size="16" @click="editField(scope.row)">
247262
<edit></edit>
248263
</el-icon>
249264
</el-tooltip>
250265
</div>
251266
</template>
252267
</el-table-column>
253-
<el-table-column :label="t('ds.field.status')" width="180">
268+
<el-table-column :label="t('datasource.enabled_status')" width="180">
254269
<template #default="scope">
255270
<div style="display: flex; align-items: center">
256271
<el-switch
@@ -262,29 +277,38 @@ const changeStatus = (row: any) => {
262277
</template>
263278
</el-table-column>
264279
</el-table>
265-
266-
<el-table v-else :data="previewData.data" style="width: 100%; height: 600px">
267-
<el-table-column
268-
v-for="(c, index) in previewData.fields"
269-
:key="index"
270-
:prop="c"
271-
:label="c"
272-
/>
273-
</el-table>
280+
<template v-else>
281+
<div class="preview-num">
282+
{{ t('ds.pieces_in_total', { msg: total, ms: showNum }) }}
283+
</div>
284+
<el-table :data="previewData.data" style="width: 100%; height: 600px">
285+
<el-table-column
286+
v-for="(c, index) in previewData.fields"
287+
:key="index"
288+
:prop="c"
289+
:label="c"
290+
/>
291+
</el-table>
292+
</template>
274293
</div>
275294
</div>
276295
</div>
277296
</div>
278297
</div>
279298
<el-dialog
280299
v-model="tableDialog"
281-
:title="t('ds.edit.table_comment')"
300+
:title="t('datasource.table_notes')"
282301
width="600"
283302
:destroy-on-close="true"
284303
:close-on-click-modal="false"
285304
@closed="closeTable"
286305
>
287-
<el-input v-model="tableComment" :rows="3" type="textarea" />
306+
<el-input
307+
:placeholder="$t('datasource.please_enter')"
308+
v-model="tableComment"
309+
:rows="3"
310+
type="textarea"
311+
/>
288312
<div style="display: flex; justify-content: flex-end; margin-top: 20px">
289313
<el-button @click="closeTable">{{ t('common.cancel') }}</el-button>
290314
<el-button type="primary" @click="saveTable">{{ t('common.confirm') }}</el-button>
@@ -293,13 +317,18 @@ const changeStatus = (row: any) => {
293317

294318
<el-dialog
295319
v-model="fieldDialog"
296-
:title="t('ds.edit.field_comment')"
320+
:title="t('datasource.field_notes')"
297321
width="600"
298322
:destroy-on-close="true"
299323
:close-on-click-modal="false"
300324
@closed="closeField"
301325
>
302-
<el-input v-model="fieldComment" :rows="3" type="textarea" />
326+
<el-input
327+
:placeholder="$t('datasource.please_enter')"
328+
v-model="fieldComment"
329+
:rows="3"
330+
type="textarea"
331+
/>
303332
<div style="display: flex; justify-content: flex-end; margin-top: 20px">
304333
<el-button @click="closeField">{{ t('common.cancel') }}</el-button>
305334
<el-button type="primary" @click="saveField">{{ t('common.confirm') }}</el-button>
@@ -467,6 +496,14 @@ const changeStatus = (row: any) => {
467496
}
468497
}
469498
}
499+
500+
.preview-num {
501+
margin: 12px 0;
502+
font-weight: 400;
503+
font-size: 14px;
504+
line-height: 22px;
505+
color: #646a73;
506+
}
470507
}
471508
}
472509
}

0 commit comments

Comments
 (0)