- 添加 prompt_locale 参数支持简体中文、繁体中文和英文提示词本地化 - 移除内置 agents 配置以简化系统架构 - 更新 ContextBuilder 使用动态提示词模板而非硬编码内容 - 在 AgentLoop、Web 接口和 AgentService 中传递 locale 参数 - 添加输出语言指令确保用户界面内容按指定语言生成 - 扩展前端 LanguageSwitcher 组件支持三种语言选项 - 优化 Header 和侧边栏组件的响应式布局和文本截断处理 - 更新测试用例验证不同语言环境下的提示词正确性
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
'use client';
|
|
|
|
import { Languages } from 'lucide-react';
|
|
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from '@/components/ui/select';
|
|
import type { AppLocale } from '@/lib/i18n/core';
|
|
import { pickAppText } from '@/lib/i18n/core';
|
|
import { useAppI18n } from '@/lib/i18n/provider';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
const OPTIONS = [
|
|
{ value: 'zh-CN', label: '中文', shortLabel: '中' },
|
|
{ value: 'en-US', label: 'English', shortLabel: 'EN' },
|
|
{ value: 'zh-Hant', label: '繁體中文', shortLabel: '繁' },
|
|
] as const;
|
|
|
|
export function LanguageSwitcher({ className }: { className?: string }) {
|
|
const { locale, setLocale } = useAppI18n();
|
|
const selectedOption = OPTIONS.find((option) => option.value === locale) ?? OPTIONS[0];
|
|
|
|
return (
|
|
<Select value={locale} onValueChange={(value) => setLocale(value as AppLocale)}>
|
|
<SelectTrigger
|
|
className={cn('h-11 w-[92px] gap-1.5 bg-muted/30 px-2 sm:w-[138px] sm:gap-2 sm:px-3', className)}
|
|
aria-label={pickAppText(locale, '选择语言', 'Select language')}
|
|
>
|
|
<Languages className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
|
|
<SelectValue aria-label={selectedOption.label}>
|
|
<span className="min-w-0 flex-1 truncate text-left">
|
|
<span className="sm:hidden">{selectedOption.shortLabel}</span>
|
|
<span className="hidden sm:inline">{selectedOption.label}</span>
|
|
</span>
|
|
</SelectValue>
|
|
</SelectTrigger>
|
|
<SelectContent align="end">
|
|
{OPTIONS.map((option) => (
|
|
<SelectItem key={option.value} value={option.value}>
|
|
{option.label}
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
);
|
|
}
|