feat: P0a i18n 基础设施 + UI 语言切换

- 创建 i18n 模块 (provider + useT hook + useLang hook)
- 中/英翻译文件 (zh.ts / en.ts),覆盖沙盒/学习/会员/对比等核心页面
- LanguageProvider 包装 layout,支持 localStorage 持久化
- Header 添加语言切换按钮 (中<>EN)
- AGENTS.md 新增国际化约定
- opencode 源码克隆到 /tmp/opencode-source/ 供参考
This commit is contained in:
yuzhiran-dev
2026-05-18 10:12:37 +08:00
parent 11bb86854c
commit 9efa2d0425
10 changed files with 400 additions and 27 deletions
+140
View File
@@ -0,0 +1,140 @@
const zh = {
common: {
loading: '加载中...',
save: '保存',
cancel: '取消',
delete: '删除',
confirm: '确认',
search: '搜索',
back: '返回',
login: '登录',
register: '注册',
logout: '退出登录',
retry: '重试',
noData: '暂无数据',
viewAll: '查看全部',
},
nav: {
home: '首页',
courses: '课程',
prompts: '提示词库',
sandbox: 'AI 沙盒',
discover: '发现',
my: '我的',
tools: '工具',
community: '社区',
},
sandbox: {
title: 'AI 沙盒',
subtitle: '在线体验 AI 对话,边学边练',
placeholder: '输入你的问题...',
send: '发送',
sending: '发送中',
newChat: '新对话',
history: '历史记录',
searchHistory: '搜索历史...',
noHistory: '暂无历史记录',
sceneGeneral: '通用对话',
sceneCoding: '编程助手',
sceneWriting: '写作助手',
sceneStudy: '学习辅导',
sceneEnglish: '英语学习',
modelGeneral: '通用模式',
modelDeepSeek: 'DeepSeek V4 Flash',
advancedParams: '高级参数',
temperature: 'Temperature',
topP: 'Top P',
maxTokens: 'Max Tokens',
helpful: '有用',
notHelpful: '没用',
runInCodeSandbox: '在代码沙盒中运行',
shareToCommunity: '分享到社区',
loginForMore: '登录使用更多',
dailyQuota: '今日已用 {used} 次,剩余 {remaining} 次',
aiReplyDisclaimer: 'AI 回复由人工智能生成,仅供参考。',
loginForMoreQuota: '登录后可获得更多使用次数和更多模型选择。',
},
auth: {
loginTitle: '登录',
registerTitle: '注册',
phone: '手机号',
password: '密码',
nickname: '昵称',
},
learning: {
analytics: '学情分析',
analyticsDesc: '基于 AI 沙盒对话分析你的学习情况',
path: '学习路径',
pathDesc: '从入门到精通,系统掌握 AI 技能',
totalSessions: 'AI 对话次数',
domainsCovered: '涉及知识领域',
avgMastery: '平均掌握度',
knowledgeDomains: '知识领域覆盖',
weakAreas: '薄弱环节',
weakDesc: '以下领域你较少涉及,建议加强学习:',
recommendations: '推荐学习',
recDesc: '根据你的薄弱环节推荐以下内容',
toStrengthen: '待加强',
conversations: '{count} 次对话',
clickToGo: '点击前往',
},
member: {
title: '会员中心',
desc: '管理你的会员订阅',
currentPlan: '当前会员',
freeUser: '你当前是免费用户',
monthly: '月卡会员',
yearly: '年卡会员',
monthlyPrice: '开通月卡 ¥29.9/月',
yearlyPrice: '开通年卡 ¥199/年',
expires: '到期时间:{date}',
benefits: '会员权益:全部课程 + 不限次沙箱 + 专属提示词库 + 去广告',
orderHistory: '订单记录',
noOrders: '暂无订单记录',
processing: '处理中...',
},
compare: {
title: '对比实验室',
desc: '同题对比不同模型的表现',
placeholder: '输入你想对比的问题或提示词...',
startCompare: '开始对比',
comparing: '对比中...',
},
codeSandbox: {
title: '代码沙盒',
run: '运行',
runShortcut: '运行 (⌘⏎)',
template: '模板...',
blank: '空白',
react: 'React (CDN)',
chart: '图表 (Chart.js)',
three: '3D (Three.js)',
console: '控制台输出',
},
promptWorkshop: {
title: '提示词工坊',
desc: '编写、测试、优化你的提示词',
editor: '提示词编辑',
test: '测试提示词',
testing: '测试中...',
clear: '清空',
saveToLibrary: '保存到提示词库',
saveSuccess: '保存成功!',
variables: '变量设置',
role: '角色',
task: '任务',
outputFormat: '输出格式',
constraints: '约束条件',
insert: '插入',
testResult: '测试结果',
saveDialogTitle: '保存提示词',
saveTitle: '标题 *',
saveDesc: '描述',
saveTags: '标签',
saveTagsPlaceholder: '用逗号分隔,如:编程,Python,调试',
saving: '保存中...',
},
}
export type Translations = typeof zh
export default zh