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
+141
View File
@@ -0,0 +1,141 @@
import type { Translations } from './zh'
const en: Translations = {
common: {
loading: 'Loading...',
save: 'Save',
cancel: 'Cancel',
delete: 'Delete',
confirm: 'Confirm',
search: 'Search',
back: 'Back',
login: 'Login',
register: 'Register',
logout: 'Logout',
retry: 'Retry',
noData: 'No data',
viewAll: 'View all',
},
nav: {
home: 'Home',
courses: 'Courses',
prompts: 'Prompts',
sandbox: 'AI Sandbox',
discover: 'Discover',
my: 'My',
tools: 'Tools',
community: 'Community',
},
sandbox: {
title: 'AI Sandbox',
subtitle: 'Experience AI conversations online, learn by doing',
placeholder: 'Type your question...',
send: 'Send',
sending: 'Sending...',
newChat: 'New Chat',
history: 'History',
searchHistory: 'Search history...',
noHistory: 'No history yet',
sceneGeneral: 'General',
sceneCoding: 'Coding',
sceneWriting: 'Writing',
sceneStudy: 'Study',
sceneEnglish: 'English',
modelGeneral: 'General',
modelDeepSeek: 'DeepSeek V4 Flash',
advancedParams: 'Advanced',
temperature: 'Temperature',
topP: 'Top P',
maxTokens: 'Max Tokens',
helpful: 'Helpful',
notHelpful: 'Not helpful',
runInCodeSandbox: 'Run in Code Sandbox',
shareToCommunity: 'Share to Community',
loginForMore: 'Login for more',
dailyQuota: '{used} used today, {remaining} remaining',
aiReplyDisclaimer: 'AI replies are for reference only.',
loginForMoreQuota: 'Login to get more usage and models.',
},
auth: {
loginTitle: 'Login',
registerTitle: 'Register',
phone: 'Phone',
password: 'Password',
nickname: 'Nickname',
},
learning: {
analytics: 'Learning Analytics',
analyticsDesc: 'Analyze your learning progress from AI sandbox conversations',
path: 'Learning Path',
pathDesc: 'Master AI skills systematically, step by step',
totalSessions: 'AI Conversations',
domainsCovered: 'Domains Covered',
avgMastery: 'Avg Mastery',
knowledgeDomains: 'Knowledge Domains',
weakAreas: 'Weak Areas',
weakDesc: 'You have less engagement in these areas. Consider strengthening:',
recommendations: 'Recommendations',
recDesc: 'Based on your weak areas, we recommend:',
toStrengthen: 'Needs work',
conversations: '{count} conversations',
clickToGo: 'Click to visit',
},
member: {
title: 'Membership',
desc: 'Manage your subscription',
currentPlan: 'Current Plan',
freeUser: 'You are on the free plan',
monthly: 'Monthly',
yearly: 'Yearly',
monthlyPrice: 'Subscribe ¥29.9/month',
yearlyPrice: 'Subscribe ¥199/year',
expires: 'Expires: {date}',
benefits: 'All courses + unlimited sandbox + exclusive prompts + ad-free',
orderHistory: 'Order History',
noOrders: 'No orders yet',
processing: 'Processing...',
},
compare: {
title: 'Compare Lab',
desc: 'Compare model responses side by side',
placeholder: 'Enter your prompt to compare...',
startCompare: 'Compare',
comparing: 'Comparing...',
},
codeSandbox: {
title: 'Code Sandbox',
run: 'Run',
runShortcut: 'Run (⌘⏎)',
template: 'Template...',
blank: 'Blank',
react: 'React (CDN)',
chart: 'Chart.js',
three: 'Three.js',
console: 'Console Output',
},
promptWorkshop: {
title: 'Prompt Workshop',
desc: 'Write, test, and optimize your prompts',
editor: 'Prompt Editor',
test: 'Test Prompt',
testing: 'Testing...',
clear: 'Clear',
saveToLibrary: 'Save to Library',
saveSuccess: 'Saved!',
variables: 'Variables',
role: 'Role',
task: 'Task',
outputFormat: 'Output Format',
constraints: 'Constraints',
insert: 'Insert',
testResult: 'Test Result',
saveDialogTitle: 'Save Prompt',
saveTitle: 'Title *',
saveDesc: 'Description',
saveTags: 'Tags',
saveTagsPlaceholder: 'Separate by commas, e.g. coding,Python,debug',
saving: 'Saving...',
},
}
export default en