From 8fcf935201b428a9e52df3ee40a762ac15339b16 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=8E=8B=E4=B8=B9?=
<12582130+fit2cloudwangdan@user.noreply.gitee.com>
Date: Thu, 16 Jan 2025 18:04:58 +0800
Subject: [PATCH] feat: i18n
---
.../locales/lang/zh_CN/components/ai-chat.ts | 13 +++++++
ui/src/locales/lang/zh_CN/components/index.ts | 4 ++-
.../lang/zh_CN/views/application-workflow.ts | 34 ++++++++++++++++++-
.../locales/lang/zh_CN/views/application.ts | 6 +++-
ui/src/locales/lang/zh_CN/views/index.ts | 4 ++-
.../component/DropdownMenu.vue | 24 ++++++++-----
.../component/PublishHistory.vue | 13 ++++---
ui/src/views/application-workflow/index.vue | 29 +++++++++-------
ui/src/views/chat/auth/component/password.vue | 7 ++--
ui/src/views/chat/embed/index.vue | 10 +++---
ui/src/views/chat/pc/index.vue | 30 +++++++++-------
ui/src/workflow/common/AddFormCollect.vue | 3 +-
ui/src/workflow/common/EditFormCollect.vue | 3 +-
ui/src/workflow/common/NodeCascader.vue | 11 +++---
ui/src/workflow/common/app-node.ts | 7 ++--
15 files changed, 136 insertions(+), 62 deletions(-)
create mode 100644 ui/src/locales/lang/zh_CN/components/ai-chat.ts
diff --git a/ui/src/locales/lang/zh_CN/components/ai-chat.ts b/ui/src/locales/lang/zh_CN/components/ai-chat.ts
new file mode 100644
index 000000000..53e3b0e7f
--- /dev/null
+++ b/ui/src/locales/lang/zh_CN/components/ai-chat.ts
@@ -0,0 +1,13 @@
+export default {
+ noHistory: '暂无历史记录',
+ createChat: '新建对话',
+ history: '历史记录',
+ only20history: '仅显示最近 20 条对话',
+ question_count: '条提问',
+ exportReords: '导出聊天记录',
+ passwordValidator: {
+ title: '请输入密码打开链接',
+ errorMessage1: '密码不能为空',
+ errorMessage2: '密码错误'
+ }
+}
diff --git a/ui/src/locales/lang/zh_CN/components/index.ts b/ui/src/locales/lang/zh_CN/components/index.ts
index 4804c9f9f..9622d4d71 100644
--- a/ui/src/locales/lang/zh_CN/components/index.ts
+++ b/ui/src/locales/lang/zh_CN/components/index.ts
@@ -1,4 +1,6 @@
import dynamicsForm from './dynamics-form'
+import chat from './ai-chat'
export default {
- dynamicsForm
+ dynamicsForm,
+ chat
}
diff --git a/ui/src/locales/lang/zh_CN/views/application-workflow.ts b/ui/src/locales/lang/zh_CN/views/application-workflow.ts
index 03048022a..adf658e49 100644
--- a/ui/src/locales/lang/zh_CN/views/application-workflow.ts
+++ b/ui/src/locales/lang/zh_CN/views/application-workflow.ts
@@ -1,3 +1,35 @@
export default {
-
+ node: '节点',
+ baseNodes: '基础组件',
+ searchBar: {
+ placeholder: '按名称搜索'
+ },
+ info: {
+ previewVersion: '预览版本:',
+ saveTime: '保存时间:'
+ },
+ setting: {
+ restoreVersion: '恢复版本',
+ restoreCurrentVersion: '恢复此版本',
+ addComponent: '添加组件',
+ public: '发布',
+ releaseHistory: '发布历史',
+ autoSave: '自动保存',
+ latestRelease: '最近发布'
+ },
+ tip: {
+ publicSuccess: '发布成功',
+ noData: '没有找到相关结果',
+ nameMessage: '名字不能为空!',
+ onlyRight: '只允许从右边的锚点连出',
+ notRecyclable: '不可循环连线',
+ onlylest: '只允许连接左边的锚点'
+ },
+ variable: {
+ global: '全局变量',
+ Referencing: '引用变量',
+ ReferencingRequired: '引用变量必填',
+ ReferencingError: '引用变量错误',
+ NoReferencing:'不存在的引用变量',
+ }
}
diff --git a/ui/src/locales/lang/zh_CN/views/application.ts b/ui/src/locales/lang/zh_CN/views/application.ts
index 4628cfffa..b6eeabe70 100644
--- a/ui/src/locales/lang/zh_CN/views/application.ts
+++ b/ui/src/locales/lang/zh_CN/views/application.ts
@@ -1,3 +1,6 @@
+import Password from '@/views/chat/auth/component/password.vue'
+import { create } from 'lodash'
+
export default {
title: '应用',
createApplication: '创建应用',
@@ -195,5 +198,6 @@ export default {
text: '针对用户提问调试段落匹配情况,保障回答效果。',
emptyMessage1: '命中段落显示在这里',
emptyMessage2: '没有命中的分段'
- }
+ },
+
}
diff --git a/ui/src/locales/lang/zh_CN/views/index.ts b/ui/src/locales/lang/zh_CN/views/index.ts
index fc4c1afe7..07f96de0c 100644
--- a/ui/src/locales/lang/zh_CN/views/index.ts
+++ b/ui/src/locales/lang/zh_CN/views/index.ts
@@ -11,6 +11,7 @@ import document from './document';
import paragraph from './paragraph';
import problem from './problem';
import log from './log';
+import applicationWorkflow from './application-workflow';
export default {
notFound,
application,
@@ -24,5 +25,6 @@ export default {
document,
paragraph,
problem,
- log
+ log,
+ applicationWorkflow
};
diff --git a/ui/src/views/application-workflow/component/DropdownMenu.vue b/ui/src/views/application-workflow/component/DropdownMenu.vue
index 8d9a25c46..e9401b286 100644
--- a/ui/src/views/application-workflow/component/DropdownMenu.vue
+++ b/ui/src/views/application-workflow/component/DropdownMenu.vue
@@ -2,14 +2,18 @@
- 没有找到相关结果
+ {{ $t('views.applicationWorkflow.tip.noData') }}
diff --git a/ui/src/views/application-workflow/component/PublishHistory.vue b/ui/src/views/application-workflow/component/PublishHistory.vue
index 151be3eb5..4674b4de8 100644
--- a/ui/src/views/application-workflow/component/PublishHistory.vue
+++ b/ui/src/views/application-workflow/component/PublishHistory.vue
@@ -1,6 +1,6 @@
-
发布历史
+
{{ $t('views.applicationWorkflow.setting.releaseHistory') }}
@@ -23,7 +23,9 @@
:write="row.writeStatus"
@close="closeWrite(row)"
/>
-
最近发布
+
{{
+ $t('views.applicationWorkflow.setting.latestRelease')
+ }}
@@ -46,7 +48,7 @@
- 恢复此版本
+ {{ $t('views.applicationWorkflow.setting.restoreCurrentVersion') }}
@@ -57,7 +59,7 @@
- 暂无历史记录
+ {{ $t('components.chat.noHistory') }}
@@ -72,6 +74,7 @@ import { useRoute } from 'vue-router'
import applicationApi from '@/api/application'
import { datetimeFormat } from '@/utils/time'
import { MsgSuccess, MsgError } from '@/utils/message'
+import { t } from '@/locales'
const route = useRoute()
const {
params: { id }
@@ -114,7 +117,7 @@ function editName(val: string, item: any) {
getList()
})
} else {
- MsgError('名字不能为空!')
+ MsgError(t('views.applicationWorkflow.tip.nameMessage'))
}
}
diff --git a/ui/src/views/application-workflow/index.vue b/ui/src/views/application-workflow/index.vue
index 9a6eac4b6..f0a5a6208 100644
--- a/ui/src/views/application-workflow/index.vue
+++ b/ui/src/views/application-workflow/index.vue
@@ -8,23 +8,26 @@
{{ detail?.name }}
预览版本:
+ >{{ $t('views.applicationWorkflow.info.previewVersion') }}
{{ currentVersion.name || datetimeFormat(currentVersion.update_time) }}
保存时间:{{ datetimeFormat(saveTime) }}{{ $t('views.applicationWorkflow.info.saveTime')
+ }}{{ datetimeFormat(saveTime) }}
- 恢复版本
+
+ {{ $t('views.applicationWorkflow.setting.restoreVersion') }}
+
-
添加组件
+
{{ $t('views.applicationWorkflow.setting.addComponent') }}
{{ $t('common.debug') }}
{{ $t('common.save') }}
-
发布
+
{{ $t('views.applicationWorkflow.setting.public') }}
@@ -43,11 +46,11 @@
- 发布历史
+ {{ $t('views.applicationWorkflow.setting.releaseHistory') }}
- 自动保存
+ {{ $t('views.applicationWorkflow.setting.autoSave') }}
@@ -146,7 +149,7 @@ import { datetimeFormat } from '@/utils/time'
import useStore from '@/stores'
import { WorkFlowInstance } from '@/workflow/common/validate'
import { hasPermission } from '@/utils/permission'
-
+import { t } from '@/locales'
const { user, application } = useStore()
const router = useRouter()
const route = useRoute()
@@ -258,17 +261,17 @@ async function publicHandle() {
return
}
applicationApi.putPublishApplication(id as String, obj, loading).then(() => {
- MsgSuccess('发布成功')
+ MsgSuccess(t('views.applicationWorkflow.tip.publicSuccess'))
})
})
.catch((res: any) => {
const node = res.node
const err_message = res.errMessage
if (typeof err_message == 'string') {
- MsgError(res.node.properties?.stepName + '节点 ' + err_message)
+ MsgError(res.node.properties?.stepName + `${t('views.applicationWorkflow.node')} ` + err_message)
} else {
const keys = Object.keys(err_message)
- MsgError(node.properties?.stepName + '节点 ' + err_message[keys[0]]?.[0]?.message)
+ MsgError(node.properties?.stepName + `${t('views.applicationWorkflow.node')} ` + err_message[keys[0]]?.[0]?.message)
}
})
}
@@ -297,10 +300,10 @@ const clickShowDebug = () => {
const node = res.node
const err_message = res.errMessage
if (typeof err_message == 'string') {
- MsgError(res.node.properties?.stepName + '节点 ' + err_message)
+ MsgError(res.node.properties?.stepName + `${t('views.applicationWorkflow.node')} ` + err_message)
} else {
const keys = Object.keys(err_message)
- MsgError(node.properties?.stepName + '节点 ' + err_message[keys[0]]?.[0]?.message)
+ MsgError(node.properties?.stepName + `${t('views.applicationWorkflow.node')} ` + err_message[keys[0]]?.[0]?.message)
}
})
}
diff --git a/ui/src/views/chat/auth/component/password.vue b/ui/src/views/chat/auth/component/password.vue
index 689d6bff4..21993c046 100644
--- a/ui/src/views/chat/auth/component/password.vue
+++ b/ui/src/views/chat/auth/component/password.vue
@@ -3,7 +3,7 @@
:modelValue="show"
modal-class="positioned-mask"
width="300"
- title="请输入密码打开链接"
+ :title="$t('components.chat.passwordValidator.title')"
custom-class="no-close-button"
:close-on-click-modal="false"
:close-on-press-escape="false"
@@ -26,6 +26,7 @@
import { ref, computed } from 'vue'
import { useRoute } from 'vue-router'
import useStore from '@/stores'
+import { t } from '@/locales'
const route = useRoute()
const FormRef = ref()
const {
@@ -51,10 +52,10 @@ const auth = () => {
}
const validator_auth = (rule: any, value: string, callback: any) => {
if (value === '') {
- callback(new Error('密码不能为空'))
+ callback(new Error(t('components.chat.passwordValidator.errorMessage1')))
} else {
auth().catch(() => {
- callback(new Error('密码错误'))
+ callback(new Error(t('components.chat.passwordValidator.errorMessage2')))
})
}
}
diff --git a/ui/src/views/chat/embed/index.vue b/ui/src/views/chat/embed/index.vue
index 37ee5c4f2..544b9755f 100644
--- a/ui/src/views/chat/embed/index.vue
+++ b/ui/src/views/chat/embed/index.vue
@@ -47,7 +47,8 @@
- 新建对话
+ {{ $t('components.chat.createChat') }}
@@ -71,7 +72,7 @@
- 历史记录
+ {{ $t('components.chat.history') }}
@@ -99,13 +100,13 @@
- 暂无历史记录
+ {{ $t('components.chat.noHistory') }}
- 仅显示最近 20 条对话
+ {{ $t('components.chat.only20history') }}
@@ -119,7 +120,6 @@ import { ref, onMounted, reactive, nextTick, computed } from 'vue'
import { isAppIcon } from '@/utils/application'
import { hexToRgba } from '@/utils/theme'
import useStore from '@/stores'
-
const { user, log } = useStore()
const AiChatRef = ref()
diff --git a/ui/src/views/chat/pc/index.vue b/ui/src/views/chat/pc/index.vue
index 9c8752906..d4b288cb2 100644
--- a/ui/src/views/chat/pc/index.vue
+++ b/ui/src/views/chat/pc/index.vue
@@ -38,9 +38,9 @@
- 新建对话
+ {{ $t('components.chat.createChat') }}
- 历史记录
+ {{ $t('components.chat.history') }}
@@ -76,13 +76,13 @@
- 暂无历史记录
+ {{ $t('components.chat.noHistory') }}
- 仅显示最近 20 条对话
+ {{ $t('components.chat.only20history') }}
@@ -101,14 +101,18 @@
style="font-size: 16px"
>
- {{ paginationConfig.total }} 条提问
+ {{ paginationConfig.total }} {{ $t('components.chat.question_count') }}
-
+
- 导出 Markdown
- 导出 HTML
+ {{ $t('common.exprt') }} Markdown
+ {{ $t('common.exprt') }} HTML
@@ -147,7 +151,7 @@ import { isAppIcon } from '@/utils/application'
import useStore from '@/stores'
import useResize from '@/layout/hooks/useResize'
import { hexToRgba } from '@/utils/theme'
-
+import { t } from '@/locales'
useResize()
const { user, log, common } = useStore()
@@ -175,7 +179,7 @@ const classObj = computed(() => {
const newObj = {
id: 'new',
- abstract: '新建对话'
+ abstract: t('components.chat.createChat')
}
const props = defineProps<{
application_profile: any
@@ -202,7 +206,7 @@ const paginationConfig = ref({
const currentRecordList = ref([])
const currentChatId = ref('new') // 当前历史记录Id 默认为'new'
-const currentChatName = ref('新建对话')
+const currentChatName = ref(t('components.chat.createChat'))
const mouseId = ref('')
function mouseenter(row: any) {
@@ -212,7 +216,7 @@ function deleteLog(row: any) {
log.asyncDelChatClientLog(applicationDetail.value.id, row.id, left_loading).then(() => {
if (currentChatId.value === row.id) {
currentChatId.value = 'new'
- currentChatName.value = '新建对话'
+ currentChatName.value = t('components.chat.createChat')
paginationConfig.value.current_page = 1
paginationConfig.value.total = 0
currentRecordList.value = []
@@ -247,7 +251,7 @@ function newChat() {
currentRecordList.value = []
}
currentChatId.value = 'new'
- currentChatName.value = '新建对话'
+ currentChatName.value = t('components.chat.createChat')
if (common.isMobile()) {
isCollapse.value = false
}
diff --git a/ui/src/workflow/common/AddFormCollect.vue b/ui/src/workflow/common/AddFormCollect.vue
index 6eac3058a..db15703a6 100644
--- a/ui/src/workflow/common/AddFormCollect.vue
+++ b/ui/src/workflow/common/AddFormCollect.vue
@@ -25,9 +25,10 @@