feat: 支持多语言提示词本地化和界面优化
- 添加 prompt_locale 参数支持简体中文、繁体中文和英文提示词本地化 - 移除内置 agents 配置以简化系统架构 - 更新 ContextBuilder 使用动态提示词模板而非硬编码内容 - 在 AgentLoop、Web 接口和 AgentService 中传递 locale 参数 - 添加输出语言指令确保用户界面内容按指定语言生成 - 扩展前端 LanguageSwitcher 组件支持三种语言选项 - 优化 Header 和侧边栏组件的响应式布局和文本截断处理 - 更新测试用例验证不同语言环境下的提示词正确性
This commit is contained in:
32
app-instance/frontend/lib/i18n/core.test.ts
Normal file
32
app-instance/frontend/lib/i18n/core.test.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { isAppLocale, normalizeAppLocale, pickAppText } from '@/lib/i18n/core';
|
||||
|
||||
describe('app locale normalization', () => {
|
||||
it('accepts simplified Chinese, English, and traditional Chinese locales', () => {
|
||||
expect(isAppLocale('zh-CN')).toBe(true);
|
||||
expect(isAppLocale('en-US')).toBe(true);
|
||||
expect(isAppLocale('zh-Hant')).toBe(true);
|
||||
});
|
||||
|
||||
it('normalizes common traditional Chinese locale tags', () => {
|
||||
expect(normalizeAppLocale('zh-TW')).toBe('zh-Hant');
|
||||
expect(normalizeAppLocale('zh-HK')).toBe('zh-Hant');
|
||||
expect(normalizeAppLocale('zh-Hant')).toBe('zh-Hant');
|
||||
});
|
||||
});
|
||||
|
||||
describe('app text picker', () => {
|
||||
it('returns simplified Chinese text for zh-CN', () => {
|
||||
expect(pickAppText('zh-CN', '任务状态', 'Task status')).toBe('任务状态');
|
||||
});
|
||||
|
||||
it('returns English text for en-US', () => {
|
||||
expect(pickAppText('en-US', '任务状态', 'Task status')).toBe('Task status');
|
||||
});
|
||||
|
||||
it('returns traditional Chinese text for zh-Hant', () => {
|
||||
expect(pickAppText('zh-Hant', '任务状态', 'Task status')).toBe('任務狀態');
|
||||
expect(pickAppText('zh-Hant', '智能体结果', 'Agent results')).toBe('智慧體結果');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user