feat(i18n): add missing locale keys and extract hardcoded Chinese strings
- Add 26 missing i18n keys to ko-KR and ru-RU for image upload, storage, VLM model, and multimodal features - Add 7 new tool name keys (queryKnowledgeGraph, finalAnswer, readSkill, executeSkillScript, dataAnalysis, dataSchema, databaseQuery) to all 4 locales (zh-CN, en-US, ko-KR, ru-RU) - Replace hardcoded Chinese tool name map (TOOL_NAME_DISPLAY) in AgentStreamDisplay with i18n key references via i18n.global.t(), merged into existing TOOL_NAME_KEYS - Fix hardcoded Chinese error message in KnowledgeBase.vue to use existing i18n key knowledgeBase.fileExists
This commit is contained in:
@@ -348,6 +348,7 @@ import { getChunkByIdOnly } from '@/api/knowledge-base';
|
||||
import { MessagePlugin } from 'tdesign-vue-next';
|
||||
import { useUIStore } from '@/stores/ui';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import i18n from '@/i18n';
|
||||
import { openMermaidFullscreen } from '@/utils/mermaidViewer';
|
||||
import { hydrateProtectedFileImages } from '@/utils/security';
|
||||
import {
|
||||
@@ -418,6 +419,13 @@ const TOOL_NAME_KEYS: Record<string, string> = {
|
||||
knowledge_graph_extract: 'agentStream.tools.knowledgeGraphExtract',
|
||||
thinking: 'agentStream.tools.thinking',
|
||||
image_analysis: 'agentStream.tools.imageAnalysis',
|
||||
query_knowledge_graph: 'agentStream.tools.queryKnowledgeGraph',
|
||||
final_answer: 'agentStream.tools.finalAnswer',
|
||||
read_skill: 'agentStream.tools.readSkill',
|
||||
execute_skill_script: 'agentStream.tools.executeSkillScript',
|
||||
data_analysis: 'agentStream.tools.dataAnalysis',
|
||||
data_schema: 'agentStream.tools.dataSchema',
|
||||
database_query: 'agentStream.tools.databaseQuery',
|
||||
};
|
||||
|
||||
const getLocalizedToolName = (toolName?: string | null): string => {
|
||||
@@ -456,34 +464,14 @@ const formatMCPToolName = (rawName: string): string => {
|
||||
return humanized;
|
||||
};
|
||||
|
||||
const TOOL_NAME_DISPLAY: Record<string, string> = {
|
||||
knowledge_search: '语义搜索',
|
||||
search_knowledge: '语义搜索',
|
||||
grep_chunks: '文本搜索',
|
||||
list_knowledge_chunks: '阅读文档内容',
|
||||
get_document_info: '获取文档信息',
|
||||
query_knowledge_graph: '知识图谱查询',
|
||||
web_search: '网络搜索',
|
||||
web_fetch: '网页抓取',
|
||||
todo_write: '制定计划',
|
||||
final_answer: '生成回答',
|
||||
thinking: '思考',
|
||||
read_skill: '读取技能',
|
||||
execute_skill_script: '执行技能脚本',
|
||||
data_analysis: '数据分析',
|
||||
data_schema: '数据结构',
|
||||
database_query: '数据库查询',
|
||||
image_analysis: '查看图片内容',
|
||||
};
|
||||
|
||||
const UUID_RE = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;
|
||||
const ID_LABEL_RE = /\b(knowledge_base_id|knowledge_id|chunk_id|knowledge_base_ids)\s*[:=]\s*/gi;
|
||||
|
||||
const sanitizeForDisplay = (text: string): string => {
|
||||
if (!text) return text;
|
||||
let result = text;
|
||||
for (const [name, display] of Object.entries(TOOL_NAME_DISPLAY)) {
|
||||
result = result.replaceAll(name, display);
|
||||
for (const [name, i18nKey] of Object.entries(TOOL_NAME_KEYS)) {
|
||||
result = result.replaceAll(name, i18n.global.t(i18nKey));
|
||||
}
|
||||
// Format any remaining mcp_ tool names inline
|
||||
result = result.replace(/\bmcp_([a-z0-9_]+)/g, (_match, rest) => {
|
||||
|
||||
@@ -1048,7 +1048,7 @@ const handleDocumentUpload = async (event: Event) => {
|
||||
failCount++;
|
||||
let errorMessage = error?.error?.message || error?.message || t('knowledgeBase.uploadFailed');
|
||||
if (error?.code === 'duplicate_file') {
|
||||
errorMessage = "文件已存在";
|
||||
errorMessage = t('knowledgeBase.fileExists');
|
||||
}
|
||||
if (totalCount === 1) {
|
||||
MessagePlugin.error(errorMessage);
|
||||
|
||||
Reference in New Issue
Block a user