feat: 国际化

This commit is contained in:
junjun 2024-10-29 10:57:15 +08:00
parent e2ce49b1ce
commit 4473625fcc
7 changed files with 83 additions and 27 deletions

View File

@ -104,7 +104,7 @@ public class CopilotManage {
Map<Long, DatasourceSchemaDTO> dsMap = (Map<Long, DatasourceSchemaDTO>) sqlMap.get("dsMap");
boolean crossDs = Utils.isCrossDs(dsMap);
if (crossDs) {
DEException.throwException("跨源数据集不支持该功能");
DEException.throwException(Translator.get("i18n_copilot_cross_ds_error"));
}
// 调用copilot service 获取SQL和chart struct将返回SQL中表名替换成数据集SQL
@ -302,7 +302,7 @@ public class CopilotManage {
if (StringUtils.equalsIgnoreCase(receiveDTO.getChart().getType(), "pie")) {
AxisFieldDTO column = receiveDTO.getChart().getColumn();
if (fields.size() != 2 || column == null) {
DEException.throwException("当前字段不足以构建饼图: " + JsonUtil.toJSONString(receiveDTO));
DEException.throwException("build pie error: " + JsonUtil.toJSONString(receiveDTO));
}
AxisDTO axisDTO = new AxisDTO();
AxisFieldDTO x = new AxisFieldDTO();
@ -318,7 +318,7 @@ public class CopilotManage {
y.setName(column.getName());
y.setValue(column.getValue());
} else {
DEException.throwException("当前字段不足以构建饼图: " + JsonUtil.toJSONString(receiveDTO));
DEException.throwException("build pie error: " + JsonUtil.toJSONString(receiveDTO));
}
axisDTO.setX(x);
axisDTO.setY(y);

View File

@ -83,3 +83,5 @@ i18n_minute=\u5206\u949F
i18n_second=\u79D2
i18n_no_datasource_permission_to_create_column=\u65E0\u6570\u636E\u6E90\u8BBF\u95EE\u6743\u9650\uFF0C\u65E0\u6CD5\u521B\u5EFA\u8868\u5B57\u6BB5
i18n_copilot_cross_ds_error=\u8de8\u6e90\u6570\u636e\u96c6\u4e0d\u652f\u6301\u8be5\u529f\u80fd

View File

@ -1,6 +1,8 @@
<script lang="ts" setup>
import copilot from '@/assets/svg/copilot.svg'
import { onMounted, ref } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
const { t } = useI18n()
const visible = ref(true)
const emits = defineEmits(['confirm'])
@ -21,13 +23,13 @@ onMounted(() => {
show-arrow
>
<div class="copilot-popper-tips-content">
<p class="title">Copilot 对话分析</p>
<p class="title">{{ t('copilot.talking_analysis') }}</p>
<p class="constant">
你好我是 Copilot 对话分析
<br />点击一下开启可视化图表解答模式<br />&nbsp;
{{ t('copilot.hello') }}
<br />{{ t('copilot.click_talk') }}<br />&nbsp;
</p>
<div class="bottom">
<el-button size="middle" @click="confirm"> 我知道了 </el-button>
<el-button size="middle" @click="confirm"> {{ t('copilot.know') }} </el-button>
</div>
</div>
<template #reference>

View File

@ -3016,5 +3016,53 @@ export default {
module_name: '阈值告警',
setting: '阈值告警设置',
no_view_tip: '请在设置阈值告警前先保存'
},
relation: {
no_permission: '没有查看权限',
datasource: '数据源',
dataset: '数据集',
dashboard: '仪表板',
dataV: '数据大屏',
analysis: '血缘分析',
resource_type: '资源类型',
pls_choose: '请选择',
choose_resource: '选择资源',
list_chart: '列表视图',
mind_map: '脑图',
index: '序号',
datasource_name: '数据源名称',
dataset_name: '数据源集名称',
dashboard_name: '仪表板名称',
dataV_name: '数据大屏名称',
retract: '收起',
expand: '展开',
node_info: '节点详情',
node_name: '节点名称',
creator: '创建人',
last_update_time: '最近更新时间',
dependent: '资源依赖',
new_page: '新页面打开'
},
copilot: {
talking_analysis: 'Copilot 对话分析',
hello: '你好我是 Copilot 对话分析',
click_talk: '点击一下开启可视化图表解答模式',
know: '我知道了',
ds_prefix: '当前数据集为',
ds_suffix: '切换数据集将清空当前会话',
confirm: '确定要切换数据集吗',
choose_dataset: '选择数据集',
pls_choose_dataset: '请选择数据集',
chart: '图表',
line: '折线图',
bar: '柱状图',
pie: '饼图',
sorry: '抱歉根据已知信息无法回答这个问题请重新描述你的问题或提供更多信息',
hello1: '您好我是 Copilot很高兴为你服务',
answer: '回答中',
example: '您可以问我: 2020年各个销售部门销售额占比的饼图',
switch_chart: '切换图表类型',
switch_table: '切换至明细表',
download: '下载'
}
}

View File

@ -11,6 +11,8 @@ import { Column, Line, Pie } from '@antv/g2plot'
import { useElementSize } from '@vueuse/core'
import { downloadCanvas } from '@/utils/imgUtils'
import ExcelJS from 'exceljs'
import { useI18n } from '@/hooks/web/useI18n'
const { t } = useI18n()
interface Copilot {
msgType: string
question: string
@ -199,7 +201,7 @@ const downloadChart = () => {
exportExcel()
return
}
downloadCanvas('img', chartTypeRef.value, '图表')
downloadCanvas('img', chartTypeRef.value, t('copilot.chart'))
}
watch(
() => props.copilotInfo.loading,
@ -223,17 +225,17 @@ const activeCommand = ref('')
const curTypeList = [
{
label: '折线图',
label: t('copilot.line'),
value: 'line',
icon: icon_chartLineC
},
{
label: '柱状图',
label: t('copilot.bar'),
icon: icon_dashboard_outlinedC,
value: 'bar'
},
{
label: '饼图',
label: t('copilot.pie'),
icon: icon_pie_outlinedC,
value: 'pie'
}
@ -248,7 +250,7 @@ const tips = computed(() => {
return chart.title
}
if (msgStatus === 0) {
return '抱歉,根据已知信息无法回答这个问题,请重新描述你的问题或提供更多信息~'
return t('copilot.sorry')
} else if (msgType === 'user') {
return question
}
@ -274,15 +276,15 @@ const tips = computed(() => {
</el-icon>
<div ref="content" class="content">
<div v-if="isWelcome" class="question-or-title" style="font-size: 16px; font-weight: 500">
您好我是 Copilot很高兴为你服务
{{ t('copilot.hello1') }}
</div>
<div v-else-if="isAnswer" class="question-or-title" style="font-size: 16px; font-weight: 500">
回答中<span class="dot">...</span>
{{ t('copilot.answer') }}<span class="dot">...</span>
</div>
<div v-else class="question-or-title">
{{ tips }}
</div>
<div v-if="isWelcome" class="is-welcome">您可以问我: 2020年各个销售部门销售额占比的饼图</div>
<div v-if="isWelcome" class="is-welcome">{{ t('copilot.example') }}</div>
<div
v-else-if="copilotInfo.msgType === 'api' && copilotInfo.msgStatus === 1"
class="chart-type"
@ -324,14 +326,14 @@ const tips = computed(() => {
></component
></Icon>
</el-icon>
<el-tooltip effect="dark" content="切换图表类型" placement="top">
<el-tooltip effect="dark" :content="t('copilot.switch_chart')" placement="top">
<div
v-show="renderTable || renderTableLocal"
@click="switchChartType(activeCommand)"
class="fake-mask_select"
></div>
</el-tooltip>
<el-tooltip effect="dark" content="切换图表类型" placement="top">
<el-tooltip effect="dark" :content="t('copilot.switch_chart')" placement="top">
<el-select
popper-class="copilot-select_popper"
class="select-copilot-list"
@ -350,7 +352,7 @@ const tips = computed(() => {
</el-tooltip>
<el-divider direction="vertical" />
</template>
<el-tooltip effect="dark" content="切换至明细表" placement="top">
<el-tooltip effect="dark" :content="t('copilot.switch_table')" placement="top">
<el-icon
:class="(renderTable || renderTableLocal) && 'active'"
class="ed-icon_chart"
@ -360,7 +362,7 @@ const tips = computed(() => {
</el-icon>
</el-tooltip>
<el-divider direction="vertical" />
<el-tooltip effect="dark" content="下载" placement="top">
<el-tooltip effect="dark" :content="t('copilot.download')" placement="top">
<el-icon class="ed-icon_chart" @click="downloadChart">
<Icon name="chart-download"><chartDownload class="svg-icon" /></Icon>
</el-icon>

View File

@ -23,6 +23,8 @@ import DialogueChart from '@/views/copilot/DialogueChart.vue'
import { type Tree } from '@/views/visualized/data/dataset/form/CreatDsGroup.vue'
import { cloneDeep } from 'lodash-es'
import { iconFieldMap } from '@/components/icon-group/field-list'
import { useI18n } from '@/hooks/web/useI18n'
const { t } = useI18n()
const quota = shallowRef([])
const dimensions = shallowRef([])
const datasetTree = shallowRef([])
@ -105,8 +107,8 @@ const handleDatasetChange = () => {
if (!!oldId && !!historyArr.value.length) {
currentId = datasetId.value
datasetId.value = oldId
const msg = `当前数据集为【${oldName}】,切换数据集将清空当前会话。`
ElMessageBox.confirm('确定要切换数据集吗?', {
const msg = t('copilot.ds_prefix') + oldName + t('copilot.ds_suffix')
ElMessageBox.confirm(t('copilot.confirm'), {
confirmButtonType: 'primary',
type: 'warning',
tip: msg,
@ -209,7 +211,7 @@ const queryAnswer = (event?: KeyboardEvent) => {
<el-icon style="margin-right: 8px; font-size: 24px">
<Icon name="copilot"><copilot class="svg-icon" /></Icon>
</el-icon>
Copilot 对话分析
{{ t('copilot.talking_analysis') }}
</div>
<div class="copilot-service">
<div class="dialogue">
@ -243,7 +245,7 @@ const queryAnswer = (event?: KeyboardEvent) => {
</div>
</div>
<div class="dataset-select" :style="{ width: showLeft ? 0 : '280px' }">
<el-tooltip effect="dark" content="收起" placement="left">
<el-tooltip effect="dark" :content="t('relation.retract')" placement="left">
<p v-show="!showLeft" class="arrow-right" @click="handleShowLeft(true)">
<el-icon>
<Icon name="icon_right_outlined"><icon_right_outlined class="svg-icon" /></Icon>
@ -251,19 +253,19 @@ const queryAnswer = (event?: KeyboardEvent) => {
</p>
</el-tooltip>
<el-tooltip effect="dark" content="展开" placement="left">
<el-tooltip effect="dark" :content="t('relation.expand')" placement="left">
<p v-show="showLeft" class="left-outlined" @click="handleShowLeft(false)">
<el-icon>
<Icon name="icon_left_outlined"><icon_left_outlined class="svg-icon" /></Icon>
</el-icon>
</p>
</el-tooltip>
<div class="title-dataset_select">选择数据集</div>
<div class="title-dataset_select">{{ t('copilot.choose_dataset') }}</div>
<div style="margin: 0 16px" class="tree-select">
<el-tree-select
v-model="datasetId"
:data="computedTree"
placeholder="请选择数据集"
:placeholder="t('copilot.pls_choose_dataset')"
@change="handleDatasetChange"
:props="dsSelectProps"
style="width: 100%"

@ -1 +1 @@
Subproject commit 85af789a82861f38e22202f01ce6aee3c7beefbb
Subproject commit b0d35715a6af38153512801501465f8ac6171060