| name | react-chinese-localization |
| title | React/TypeScript Chinese Localization |
| description | Systematically localize English React/TypeScript UI components to Chinese while maintaining code functionality and build integrity |
| version | 1.0.0 |
| trigger | when asked to translate, localize, or Chinese-ify a React/TypeScript project's UI |
React/TypeScript Chinese Localization
Goal
Transform all user-facing English text in a React/TypeScript project to Chinese while preserving:
- Code functionality (variable names, functions, APIs unchanged)
- Build success (no TypeScript errors)
- Styling and formatting
Prerequisites
- Node.js and npm/yarn installed
- Project has a working build system (vite, webpack, etc.)
- Source files are in
.tsx or .jsx format
Step-by-Step Process
1. Discover All UI Components
find ./src -name "*.tsx" -o -name "*.jsx" | head -20
ls -la ./src/components/ | grep -i panel
ls -la ./src/pages/ 2>/dev/null || true
2. Create Translation Mapping
First read the main components to understand the UI structure. Create a glossary:
| English | Chinese | Notes |
|---|
| Dashboard | 仪表盘 | Main view |
| Settings | 设置 | Configuration |
| Profile | 用户画像 / 档案 | User profile |
| What I Know | 知识概览 | Creative translation |
| What I Remember | 记忆状态 | Context-dependent |
| Active | 活跃 / 运行中 | For status |
| Silent | 静默 / 未运行 | For status |
| Load/Loading | 加载 | Actions |
| Save | 保存 | Actions |
| Cancel | 取消 | Actions |
| Delete | 删除 | Actions |
3. Systematic File-by-File Translation
For each component file:
-
Read the file to understand structure
-
Identify translatable strings:
- Panel titles (
title="What I Know")
- Button labels
- Status messages
- Descriptive text
- Column headers
- Navigation labels
-
Replace English with Chinese:
- Only change string literals inside JSX or component props
- Preserve: variable names, function names, CSS classes, API endpoints
- Preserve: technical terms if they don't have good Chinese equivalents
-
Preserve formatting:
- Keep indentation
- Keep CSS-in-JS styling
- Keep component structure
4. Key Translation Patterns
Panel/Card Titles:
<Panel title="What I Know">
<Panel title="知识概览">
Status Indicators:
<span>{status === 'alive' ? 'Running' : 'Stopped'}</span>
<span>{status === 'alive' ? '运行中' : '已停止'}</span>
Labels and Descriptions:
<div><span>Messages:</span> {count}</div>
<div><span>消息数:</span> {count}</div>
Navigation:
{ label: 'Dashboard', value: 'dashboard' }
{ label: '仪表盘', value: 'dashboard' }
5. Build Verification
After all files are modified:
cd frontend
npm run build 2>&1
Must see:
- ✓ No TypeScript errors
- ✓ No ESLint errors
- ✓ Build completes successfully
6. Deploy Updated Build
cp -r dist/* ../backend/static/
7. Verify in Browser
- Check all tabs/nav items are translated
- Check panel titles
- Check button labels
- Check status messages
- Verify no broken layouts
Common Pitfalls
-
Don't translate:
- Variable names (
const userName → keep as is)
- Function names (
handleClick → keep as is)
- CSS class names (
className="dashboard-panel" → keep as is)
- API endpoints (
/api/v1/sessions → keep as is)
- Route paths (
/dashboard → keep as is)
- Technical identifiers (model names like "GPT-4", "Claude")
-
Preserve punctuation style:
- English:
Hello, World!
- Chinese:
你好,世界! (use Chinese punctuation)
-
Context matters:
- "Profile" as a noun → "用户画像"
- "Profile" as a verb/action → "查看画像"
-
Keep it concise:
- Chinese text can be wider; watch for layout breaks
- Use shorter translations if space is tight
Files Typically Modified
*Panel.tsx - Main content panels
*Page.tsx - Page components
TopBar.tsx / Header.tsx - Navigation
Sidebar.tsx - Navigation menu
CommandPalette.tsx - Command interface
BootScreen.tsx / Loading.tsx - Splash screens
useTheme.tsx / theme.ts - Theme names
Verification Checklist
Example Complete Workflow
ls src/components/*.tsx
npm run build
cp -r dist/* backend/static/
curl http://localhost:3001