Files
agent-park/src/components/locale/LocaleSwitcher.tsx
T
mzaxdandClaude 3869bb23bb refactor: 优化组件国际化实现
- 将客户端组件改为服务端组件,使用 getTranslations
- LocaleSwitcher 简化为接收 switchUrl prop
- ProjectCard/ProjectList/ExternalLinkCard 等组件支持 i18n
- 优化 webhook 去重查询,关联 links 数据
- 移除 ProjectDetail 中的客户端交互逻辑(ShareButtons 暂时禁用)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-29 19:58:23 +08:00

23 lines
544 B
TypeScript

'use client'
import Link from 'next/link'
const locales = ['zh', 'en'] as const
const localeNames: Record<string, string> = {
zh: '中文',
en: 'EN'
}
export function LocaleSwitcher({ currentLocale, switchUrl }: { currentLocale: string; switchUrl: string }) {
const otherLocale = currentLocale === 'zh' ? 'en' : 'zh'
return (
<Link
href={switchUrl}
className="font-display text-sm font-bold hover:opacity-70 transition-opacity"
>
{localeNames[currentLocale]} / {localeNames[otherLocale]}
</Link>
)
}