feat: 全面支持中英文多语言切换

将翻译文件拆分为独立的 en.ts/zh.ts,为 t() 函数添加插值支持,
国际化 Dashboard 全部页面和组件(登录、注册、项目管理、设置、
MCP 集成等),修复 ThemeToggle 仅中文标签的 bug,
在 Dashboard header 中添加 LanguageToggle 组件。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-03 13:10:09 +08:00
parent 4b3a9481c6
commit 67295c22d1
19 changed files with 1005 additions and 517 deletions

View File

@@ -1,4 +1,5 @@
import { useTheme } from '../lib/theme';
import { useI18n } from '../lib/i18n';
const icons = {
light: (
@@ -18,26 +19,26 @@ const icons = {
),
};
const labels = { light: '浅色', dark: '深色', system: '跟随系统' } as const;
const order: Array<'light' | 'dark' | 'system'> = ['light', 'dark', 'system'];
export default function ThemeToggle() {
const { theme, setTheme } = useTheme();
const { t } = useI18n();
return (
<div className="flex items-center gap-1 p-1 rounded-lg bg-bg-tertiary">
{order.map((t) => (
{order.map((key) => (
<button
key={t}
onClick={() => setTheme(t)}
title={labels[t]}
key={key}
onClick={() => setTheme(key)}
title={t(`theme.${key}`)}
className={`flex items-center justify-center w-8 h-7 rounded-md transition-all duration-150 ${
theme === t
theme === key
? 'bg-bg-elevated text-text-primary shadow-sm'
: 'text-text-muted hover:text-text-secondary'
}`}
>
{icons[t]}
{icons[key]}
</button>
))}
</div>