Skip to content

Commit 9ab60e3

Browse files
authored
♻️ Refactor frontend internationalization component optimization #1107
2 parents a7ba1f4 + 6dcea3f commit 9ab60e3

File tree

9 files changed

+41
-68
lines changed

9 files changed

+41
-68
lines changed

frontend/app/[locale]/chat/components/chatLeftSidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ export function ChatSidebar({
621621
color={getRoleColor(userRole)}
622622
className="mt-1 cursor-auto w-fit"
623623
>
624-
{t(userRole === "admin" ? "role_admin" : "role_user")}
624+
{t(userRole === "admin" ? "auth.admin" : "auth.user")}
625625
</Tag>
626626
)}
627627
</div>

frontend/app/[locale]/chat/internal/chatInterface.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,8 @@ export function ChatInterface() {
610610
} else if (result.error === 'FILE_PARSING_FAILED') {
611611
errorMessage = t("chatInterface.fileParsingFailed");
612612
} else {
613-
// For any other error, show a generic message without exposing technical details
614-
errorMessage = t("chatInterface.fileProcessingFailed", {
615-
error: "Unknown error"
616-
});
613+
// For any other error, show a simple message
614+
errorMessage = t("chatInterface.fileProcessingStopped");
617615
}
618616

619617
lastMsg.content = errorMessage;

frontend/app/[locale]/setup/agents/components/AgentSetupOrchestrator.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export default function AgentSetupOrchestrator({
116116
);
117117
}
118118
} catch (error) {
119-
log.error(t("debug.log.fetchAgentListFailed"), error);
119+
log.error(t("agentConfig.agents.listFetchFailedDebug"), error);
120120
message.error(t("businessLogic.config.error.agentListFailed"));
121121
} finally {
122122
setIsLoadingTools(false);
@@ -573,7 +573,7 @@ export default function AgentSetupOrchestrator({
573573
setEnabledToolIds([]);
574574
}
575575
} catch (error) {
576-
log.error(t("debug.log.loadAgentDetailsFailed"), error);
576+
log.error(t("agentConfig.agents.detailsLoadFailed"), error);
577577
message.error(t("businessLogic.config.error.agentDetailFailed"));
578578
// If error occurs, reset editing state
579579
setIsEditingAgent(false);
@@ -653,7 +653,7 @@ export default function AgentSetupOrchestrator({
653653
);
654654
}
655655
} catch (error) {
656-
log.error(t("debug.log.importAgentFailed"), error);
656+
log.error(t("agentConfig.agents.importFailed"), error);
657657
message.error(t("businessLogic.config.error.agentImportFailed"));
658658
} finally {
659659
setIsImporting(false);
@@ -683,7 +683,7 @@ export default function AgentSetupOrchestrator({
683683
);
684684
}
685685
} catch (error) {
686-
log.error(t("debug.log.deleteAgentFailed"), error);
686+
log.error(t("agentConfig.agents.deleteFailed"), error);
687687
message.error(t("businessLogic.config.error.agentDeleteFailed"));
688688
} finally {
689689
setIsDeleteConfirmOpen(false);

frontend/app/[locale]/setup/agents/components/tool/ToolPool.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ function ToolPool({
341341
);
342342
}
343343
} catch (error) {
344-
log.error(t("debug.log.refreshToolsFailed"), error);
344+
log.error(t("agentConfig.tools.refreshFailedDebug"), error);
345345
message.error(t("toolManagement.message.refreshFailedRetry"));
346346
} finally {
347347
setIsRefreshing(false);

frontend/app/[locale]/setup/agents/config.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export default function AgentConfig() {
189189
);
190190
}
191191
} catch (error) {
192-
log.error(t("debug.log.exportAgentFailed"), error);
192+
log.error(t("agentConfig.agents.exportFailed"), error);
193193
message.error(t("businessLogic.config.error.agentExportFailed"));
194194
}
195195
};
@@ -228,7 +228,7 @@ export default function AgentConfig() {
228228
);
229229
}
230230
} catch (error) {
231-
log.error(t("debug.log.deleteAgentFailed"), error);
231+
log.error(t("agentConfig.agents.deleteFailed"), error);
232232
message.error(t("businessLogic.config.message.agentDeleteFailed"));
233233
}
234234
};
@@ -398,7 +398,7 @@ export default function AgentConfig() {
398398
message.error(t("agentConfig.tools.refreshFailed"));
399399
}
400400
} catch (error) {
401-
log.error(t("agentConfig.debug.refreshToolsFailed"), error);
401+
log.error(t("agentConfig.tools.refreshFailedDebug"), error);
402402
message.error(t("agentConfig.tools.refreshFailed"));
403403
}
404404
};

frontend/components/auth/avatarDropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function AvatarDropdown() {
9696
<div className="font-medium">{user.email}</div>
9797
<div className="mt-1">
9898
<Tag color={getRoleColor(user.role)}>
99-
{t(user.role === "admin" ? "role_admin" : "role_user")}
99+
{t(user.role === "admin" ? "auth.admin" : "auth.user")}
100100
</Tag>
101101
</div>
102102
</div>

frontend/public/locales/en/common.json

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"chatInterface.componentUnmount": "Component Unmounted",
1515
"chatInterface.errorCancelingRequest": "Error canceling request",
1616
"chatInterface.requestTimeout": "Request Timeout",
17-
"chatInterface.requestTimeoutMessage": "Request exceeded 120 seconds and was automatically canceled",
1817
"chatInterface.requestTimeoutRetry": "Request timed out, please try again",
1918
"chatInterface.stopTimeoutRequestFailed": "Failed to stop timed-out request:",
2019
"chatInterface.refreshDialogListFailedButContinue": "Failed to refresh conversation list, but continuing to send message:",
@@ -28,19 +27,16 @@
2827
"chatInterface.fileParsingComplete": "File parsing complete",
2928
"chatInterface.fileParsingCompleteWithTruncation": "File parsing complete: {{truncationInfo}}",
3029
"chatInterface.truncationSeparator": "; ",
31-
"chatInterface.fileProcessingFailed": "File processing failed: {{error}}",
3230
"chatInterface.fileParsingFailed": "File parsing failed",
3331
"chatInterface.fileSizeExceeded": "File size exceeds the limit, please upload smaller files",
3432
"chatInterface.filePreprocessingStopped": "File parsing stopped",
35-
"chatInterface.userCancelledRequest": "User canceled the request",
3633
"chatInterface.conversationStopped": "Conversation stopped",
3734
"chatInterface.errorProcessingRequest": "An error occurred while processing the request",
3835
"chatInterface.errorFetchingConversationList": "Failed to fetch conversation list during initialization:",
3936
"chatInterface.errorFetchingConversationDetailsError": "Error fetching conversation details:",
4037
"chatInterface.errorFetchingAttachmentUrl": "Failed to fetch attachment URL: {{object_name}}",
4138
"chatInterface.renameFailed": "Rename failed:",
4239
"chatInterface.deleteConversation": "Delete Conversation",
43-
"chatInterface.stoppingCurrentConversationBeforeDeleting": "Stopping current conversation before deletion:",
4440
"chatInterface.stopConversationToDeleteFailed": "Failed to stop conversation for deletion:",
4541
"chatInterface.deleteFailed": "Delete failed:",
4642
"chatInterface.imageLoadFailed": "Image failed to load:",
@@ -60,8 +56,6 @@
6056
"chatPreprocess.preprocessResponseEmpty": "Preprocessing response is empty",
6157
"chatPreprocess.parsingPreprocessDataFailed": "Failed to parse preprocessing data:",
6258
"chatPreprocess.filePreprocessingFailed": "File preprocessing failed:",
63-
"chatPreprocess.uploadingFile": "Uploading file: {{name}}, type: {{type}}, size: {{size}}",
64-
"chatPreprocess.uploadingImage": "Uploading image: {{name}}, type: {{type}}, size: {{size}}",
6559
"chatPreprocess.fileUploadFailed": "File upload failed:",
6660
"chatPreprocess.parsingFile": "Parsing file...",
6761

@@ -221,7 +215,6 @@
221215
"chatStreamHandler.callingTool": "Calling tool...",
222216
"chatStreamHandler.parseSearchContentFailed": "Failed to parse search content:",
223217
"chatStreamHandler.processImageDataFailed": "Failed to process image data:",
224-
"chatStreamHandler.parseSSEFailed": "Failed to parse SSE data:",
225218
"chatStreamHandler.processRemainingDataFailed": "Failed to process remaining data:",
226219
"chatStreamHandler.thinking": "Thinking...",
227220
"chatStreamHandler.connectingMcpServer": "Connecting to MCP server...",
@@ -460,7 +453,6 @@
460453
"knowledgeBase.description.default": "Knowledge base created through document upload",
461454
"knowledgeBase.empty.title": "No Knowledge Base Selected",
462455
"knowledgeBase.empty.description": "Please select a knowledge base from the list on the left, or create a new one",
463-
"knowledgeBase.log.documentsPolled": "Polling service retrieved {{count}} documents",
464456
"knowledgeBase.error.createUpload": "Failed to create knowledge base or upload files:",
465457
"knowledgeBase.error.getSummary": "Failed to generate knowledge base summary:",
466458
"knowledgeBase.name.new": "new_base",
@@ -753,10 +745,6 @@
753745
"auth.inviteCodeHint.documentationUrl": "https://modelengine-group.github.io/nexent/en/contributing.html#%F0%9F%8C%9F-quick-memorial-wall-contribution",
754746
"auth.inviteCodeHint.viewDocumentation": "View Documentation",
755747

756-
"role_admin": "Admin",
757-
758-
"role_user": "User",
759-
760748
"toolManagement.refresh.title": "Refresh Tools List",
761749
"toolManagement.refresh.button.refreshing": "Refreshing",
762750
"toolManagement.refresh.button.refresh": "Refresh Tools",
@@ -767,12 +755,6 @@
767755
"toolManagement.message.refreshFailed": "Failed to refresh tools list",
768756
"toolManagement.message.refreshFailedRetry": "Failed to refresh tools list, please try again later",
769757

770-
"debug.console.refreshToolsFailed": "Failed to refresh tools list:",
771-
"debug.console.loadAgentDetailsFailed": "Failed to load Agent details:",
772-
"debug.console.importAgentFailed": "Failed to import Agent:",
773-
"debug.console.exportAgentFailed": "Failed to export Agent:",
774-
"debug.console.deleteAgentFailed": "Failed to delete Agent:",
775-
"debug.console.fetchAgentListFailed": "Failed to fetch Agent list:",
776758

777759
"mcpConfig.modal.title": "MCP Server Configuration",
778760
"mcpConfig.modal.close": "Close",
@@ -842,12 +824,17 @@
842824

843825
"agentConfig.tools.refreshSuccess": "Tool list refreshed successfully",
844826
"agentConfig.tools.refreshFailed": "Failed to refresh tool list",
845-
"agentConfig.debug.refreshToolsFailed": "Failed to refresh tool list:",
846-
"agentConfig.error.fetchToolsFailed": "Failed to fetch tools list, please try again later",
847-
"agentConfig.error.fetchAgentListFailed": "Failed to fetch agent list, please try again later",
848-
"agentConfig.error.fetchCreatingSubAgentIdFailed": "Failed to fetch creating sub agent ID, please try again later",
849-
"agentConfig.error.fetchAgentDetailsFailed": "Failed to fetch agent details, please try again later",
850-
"agentConfig.error.fetchAgentCallRelationshipFailed": "Failed to fetch agent call relationship, please try again later",
827+
"agentConfig.tools.fetchFailed": "Failed to fetch tools list, please try again later",
828+
"agentConfig.agents.listFetchFailed": "Failed to fetch agent list, please try again later",
829+
"agentConfig.agents.createSubAgentIdFailed": "Failed to fetch creating sub agent ID, please try again later",
830+
"agentConfig.agents.detailsFetchFailed": "Failed to fetch agent details, please try again later",
831+
"agentConfig.agents.callRelationshipFetchFailed": "Failed to fetch agent call relationship, please try again later",
832+
"agentConfig.tools.refreshFailedDebug": "Failed to refresh tools list:",
833+
"agentConfig.agents.detailsLoadFailed": "Failed to load Agent details:",
834+
"agentConfig.agents.importFailed": "Failed to import Agent:",
835+
"agentConfig.agents.exportFailed": "Failed to export Agent:",
836+
"agentConfig.agents.deleteFailed": "Failed to delete Agent:",
837+
"agentConfig.agents.listFetchFailedDebug": "Failed to fetch Agent list:",
851838

852839
"embedding.emptyWarningModal.title": "No Embedding Model Selected",
853840
"embedding.emptyWarningModal.content": "You have not selected an Embedding model. The knowledge base configuration, memory functions and some agent tools will be unavailable.",

frontend/public/locales/zh/common.json

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"chatInterface.componentUnmount": "组件卸载",
1515
"chatInterface.errorCancelingRequest": "取消请求时出错",
1616
"chatInterface.requestTimeout": "请求超时",
17-
"chatInterface.requestTimeoutMessage": "请求超过120秒已自动取消",
1817
"chatInterface.requestTimeoutRetry": "请求超时,请重试",
1918
"chatInterface.stopTimeoutRequestFailed": "停止超时请求失败:",
2019
"chatInterface.refreshDialogListFailedButContinue": "刷新对话列表失败,但继续发送消息:",
@@ -28,19 +27,16 @@
2827
"chatInterface.fileParsingComplete": "文件解析完成",
2928
"chatInterface.fileParsingCompleteWithTruncation": "文件解析完成:{{truncationInfo}}",
3029
"chatInterface.truncationSeparator": "",
31-
"chatInterface.fileProcessingFailed": "文件处理失败: {{error}}",
3230
"chatInterface.fileParsingFailed": "文件解析失败",
3331
"chatInterface.fileSizeExceeded": "文件大小超出限制,请上传更小的文件",
3432
"chatInterface.filePreprocessingStopped": "文件解析已停止",
35-
"chatInterface.userCancelledRequest": "用户取消了请求",
3633
"chatInterface.conversationStopped": "对话已停止",
3734
"chatInterface.errorProcessingRequest": "处理请求时发生错误",
3835
"chatInterface.errorFetchingConversationList": "初始化时获取对话列表失败:",
3936
"chatInterface.errorFetchingConversationDetailsError": "获取对话详情错误:",
4037
"chatInterface.errorFetchingAttachmentUrl": "获取附件URL失败: {{object_name}}",
4138
"chatInterface.renameFailed": "重命名失败:",
4239
"chatInterface.deleteConversation": "删除对话",
43-
"chatInterface.stoppingCurrentConversationBeforeDeleting": "删除对话前停止当前对话:",
4440
"chatInterface.stopConversationToDeleteFailed": "停止要删除的对话失败:",
4541
"chatInterface.deleteFailed": "删除失败:",
4642
"chatInterface.imageLoadFailed": "图片加载失败:",
@@ -60,8 +56,6 @@
6056
"chatPreprocess.preprocessResponseEmpty": "预处理响应为空",
6157
"chatPreprocess.parsingPreprocessDataFailed": "解析预处理数据失败:",
6258
"chatPreprocess.filePreprocessingFailed": "文件预处理失败:",
63-
"chatPreprocess.uploadingFile": "上传文件: {{name}}, 类型: {{type}}, 大小: {{size}}",
64-
"chatPreprocess.uploadingImage": "上传图片: {{name}}, 类型: {{type}}, 大小: {{size}}",
6559
"chatPreprocess.fileUploadFailed": "文件上传失败:",
6660
"chatPreprocess.parsingFile": "正在解析文件...",
6761

@@ -221,7 +215,6 @@
221215
"chatStreamHandler.callingTool": "工具调用中...",
222216
"chatStreamHandler.parseSearchContentFailed": "解析搜索内容失败:",
223217
"chatStreamHandler.processImageDataFailed": "处理图片数据失败:",
224-
"chatStreamHandler.parseSSEFailed": "SSE 数据解析失败:",
225218
"chatStreamHandler.processRemainingDataFailed": "处理剩余数据失败:",
226219
"chatStreamHandler.thinking": "正在思考中...",
227220
"chatStreamHandler.connectingMcpServer": "正在连接MCP服务器...",
@@ -461,7 +454,6 @@
461454
"knowledgeBase.description.default": "通过文档上传创建的知识库",
462455
"knowledgeBase.empty.title": "未选择知识库",
463456
"knowledgeBase.empty.description": "请在左侧列表选择一个知识库,或创建新的知识库",
464-
"knowledgeBase.log.documentsPolled": "轮询服务获取到 {{count}} 个文档",
465457
"knowledgeBase.error.createUpload": "知识库创建或上传失败:",
466458
"knowledgeBase.error.getSummary": "获取知识库总结失败:",
467459
"knowledgeBase.name.new": "新知识库",
@@ -753,10 +745,6 @@
753745
"auth.inviteCodeHint.documentationUrl": "https://modelengine-group.github.io/nexent/zh/contributing.html#%F0%9F%8C%9F-%E5%BC%80%E6%BA%90%E7%BA%AA%E5%BF%B5%E5%A2%99%E5%BF%AB%E9%80%9F%E8%B4%A1%E7%8C%AE",
754746
"auth.inviteCodeHint.viewDocumentation": "查看说明文档",
755747

756-
"role_admin": "管理员",
757-
758-
"role_user": "普通用户",
759-
760748
"toolManagement.refresh.title": "刷新工具列表",
761749
"toolManagement.refresh.button.refreshing": "刷新中",
762750
"toolManagement.refresh.button.refresh": "刷新工具",
@@ -767,12 +755,7 @@
767755
"toolManagement.message.refreshFailed": "刷新工具列表失败",
768756
"toolManagement.message.refreshFailedRetry": "刷新工具列表失败,请稍后重试",
769757

770-
"debug.console.refreshToolsFailed": "刷新工具列表失败:",
771-
"debug.console.loadAgentDetailsFailed": "加载Agent详情失败:",
772-
"debug.console.importAgentFailed": "导入Agent失败:",
773-
"debug.console.exportAgentFailed": "导出Agent失败:",
774-
"debug.console.deleteAgentFailed": "删除Agent失败:",
775-
"debug.console.fetchAgentListFailed": "获取 Agent 列表失败:",
758+
776759

777760
"mcpConfig.modal.title": "MCP服务器配置",
778761
"mcpConfig.modal.close": "关闭",
@@ -842,12 +825,17 @@
842825

843826
"agentConfig.tools.refreshSuccess": "工具列表已刷新",
844827
"agentConfig.tools.refreshFailed": "刷新工具列表失败",
845-
"agentConfig.debug.refreshToolsFailed": "刷新工具列表失败:",
846-
"agentConfig.error.fetchToolsFailed": "获取工具列表失败,请稍后重试",
847-
"agentConfig.error.fetchAgentListFailed": "获取Agent列表失败,请稍后重试",
848-
"agentConfig.error.fetchCreatingSubAgentIdFailed": "获取创建子Agent ID失败,请稍后重试",
849-
"agentConfig.error.fetchAgentDetailsFailed": "获取Agent详情失败,请稍后重试",
850-
"agentConfig.error.fetchAgentCallRelationshipFailed": "获取Agent调用关系失败,请稍后重试",
828+
"agentConfig.tools.fetchFailed": "获取工具列表失败,请稍后重试",
829+
"agentConfig.agents.listFetchFailed": "获取Agent列表失败,请稍后重试",
830+
"agentConfig.agents.createSubAgentIdFailed": "获取创建子Agent ID失败,请稍后重试",
831+
"agentConfig.agents.detailsFetchFailed": "获取Agent详情失败,请稍后重试",
832+
"agentConfig.agents.callRelationshipFetchFailed": "获取Agent调用关系失败,请稍后重试",
833+
"agentConfig.tools.refreshFailedDebug": "刷新工具列表失败:",
834+
"agentConfig.agents.detailsLoadFailed": "加载Agent详情失败:",
835+
"agentConfig.agents.importFailed": "导入Agent失败:",
836+
"agentConfig.agents.exportFailed": "导出Agent失败:",
837+
"agentConfig.agents.deleteFailed": "删除Agent失败:",
838+
"agentConfig.agents.listFetchFailedDebug": "获取 Agent 列表失败:",
851839

852840
"embedding.emptyWarningModal.title": "未选择向量化模型",
853841
"embedding.emptyWarningModal.content": "您未选择向量化模型,后续知识库配置、记忆功能、知识检索工具以及其他部分 Agent 工具将无法使用。",

frontend/services/agentConfigService.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const fetchTools = async () => {
4949
return {
5050
success: false,
5151
data: [],
52-
message: "agentConfig.error.fetchToolsFailed",
52+
message: "agentConfig.tools.fetchFailed",
5353
};
5454
}
5555
};
@@ -87,7 +87,7 @@ export const fetchAgentList = async () => {
8787
return {
8888
success: false,
8989
data: [],
90-
message: "agentConfig.error.fetchAgentListFailed",
90+
message: "agentConfig.agents.listFetchFailed",
9191
};
9292
}
9393
};
@@ -132,7 +132,7 @@ export const getCreatingSubAgentId = async () => {
132132
return {
133133
success: false,
134134
data: null,
135-
message: "agentConfig.error.fetchCreatingSubAgentIdFailed",
135+
message: "agentConfig.agents.createSubAgentIdFailed",
136136
};
137137
}
138138
};
@@ -467,7 +467,7 @@ export const searchAgentInfo = async (agentId: number) => {
467467
return {
468468
success: false,
469469
data: null,
470-
message: "agentConfig.error.fetchAgentDetailsFailed",
470+
message: "agentConfig.agents.detailsFetchFailed",
471471
};
472472
}
473473
};
@@ -505,7 +505,7 @@ export const fetchAllAgents = async () => {
505505
return {
506506
success: false,
507507
data: [],
508-
message: "agentConfig.error.fetchAgentListFailed",
508+
message: "agentConfig.agents.listFetchFailed",
509509
};
510510
}
511511
};
@@ -628,7 +628,7 @@ export const fetchAgentCallRelationship = async (agentId: number) => {
628628
return {
629629
success: false,
630630
data: null,
631-
message: 'agentConfig.error.fetchAgentCallRelationshipFailed'
631+
message: 'agentConfig.agents.callRelationshipFetchFailed'
632632
};
633633
}
634634
};

0 commit comments

Comments
 (0)