Translate Docs (zh-CN → en-US)
Translates Chinese Markdown docs to English for the oceanbase-design site.
File naming conventions
Dumi default locale is en-US at /; zh-CN uses /zh-CN prefix.
| Area |
English (en-US) |
Chinese (zh-CN) |
docs/** site docs |
foo.md |
foo.zh-CN.md |
packages/**/src/** component docs |
index.en-US.md |
index.md |
Rules
docs/: unsuffixed .md = English; .zh-CN.md = Chinese (including docs/blog/).
packages/: index.md = Chinese; index.en-US.md = English (legacy layout; do not rename without a migration plan).
- Internal links in Chinese docs: locale-agnostic paths (
/components/button). rehypePlugin adds /zh-CN for .zh-CN.md files.
- Sidebar locale filtering uses filename suffix (see
isSidebarItemZhCN in .dumi/theme/utils.ts).
When to Use
- User asks to translate a doc, create English version, or generate
*.en-US.md / split *.zh-CN.md
- Batch translating
docs/ or packages/*/src/**/index.md for i18n
Workflow
- Read the source Chinese file (
.md in packages, or .zh-CN.md in docs)
- Apply glossary.json for consistent terminology
- Translate content; preserve structure (see rules below)
- Write output:
docs/foo.zh-CN.md → docs/foo.md
packages/design/src/button/index.md → packages/design/src/button/index.en-US.md
Rules
Do NOT translate
- Code blocks (
...) — keep as-is; only translate Chinese comments inside code if present
- Frontmatter keys:
title, order, group, path, nav — translate values only
- Link paths:
/components/button, /docs/design-introduce — keep unchanged
<code src="..."> — keep src path; translate title and description attributes
<embed src="..."> — keep src path unchanged
- File paths, package names, API names
Do translate
- Body text, headings, paragraphs, list items
- Frontmatter
title, group.title, nav.title values
<code title="..." description="..."> attribute values
- Table headers and cell content (except code/API names)
Structure preservation
- Keep heading levels (
#, ##, ###)
- Keep Markdown syntax (lists, tables, links)
- Keep Dumi directives:
<code>, <embed>, <!-- prettier-ignore -->
Glossary
Use glossary.json for term mapping. Key entries:
| 中文 |
English |
| 按钮 |
Button |
| 表单 |
Form |
| 表格 |
Table |
| 全局配置 |
ConfigProvider |
| 分页 |
Pagination |
| 日期选择 |
DatePicker |
| 选择器 |
Select |
| 输入框 |
Input |
| 设计系统 |
design system |
| 组件库 |
component library |
Full list in glossary.json. When translating, prefer these mappings for consistency.
Output naming
| Source (Chinese) |
Output (English) |
docs/design/design-introduce.zh-CN.md |
docs/design/design-introduce.md |
docs/design/react/for-agents.zh-CN.md |
docs/design/react/for-agents.md |
packages/design/src/button/index.md |
packages/design/src/button/index.en-US.md |
Integration with baoyu-translate
When baoyu-translate (from JimLiu/baoyu-skills) is available:
- Use
/translate --to en-US --mode normal docs/design/design-introduce.md for full workflow (analyze → translate)
- Use
--mode refined for publication-quality docs (analyze → translate → review → polish)
- Output:
{source}-en-US/translation.md — copy to {source}.en-US.md for Dumi
- Project EXTEND.md:
.baoyu-skills/baoyu-translate/EXTEND.md (glossary: glossary-zh-en.md)
Composer / Batch Tips
When translating multiple files with Cursor Composer:
- Batch prompt: "Translate the following docs to English using the translate-docs skill. Create *.en-US.md for each. Apply glossary.json for terminology."
- Consistency check: After batch translation, run "Compare keys/terms across all *.en-US.md files. List any inconsistent translations."
- Review: Always do human spot-check on P0 docs (design-introduce, quickstart, component overview).
Demo Anglicization
Exposed component demos (sidebar-locales.ts whitelist) must use English UI text in demo/*.{ts,tsx}.
Strategy
- One shared English demo per example; both
index.md and index.en-US.md reference the same src
- Align with ant-design demos when a counterpart exists (
ant-design/components/{name}/demo/)
- For OB-only components (
Filter, BasicLayout, ProTable, etc.), use glossary.json demoMock entries
Translate in demos
- Labels, placeholders, button text, table columns, mock data, chart categories
- Code comments when they contain Chinese
Do NOT translate
- Imports, API prop names, types
- i18n/locale demos that intentionally show language switching
- CJK sample text in font-rendering demos
Allowlist (keep CJK)
| File |
Reason |
packages/design/src/locale/demo/basic.tsx |
Locale switching demo |
packages/design/src/typography/demo/font-family.tsx |
CJK font sample text |
packages/ui/src/DateRanger/demo/locale.tsx |
Locale switching demo |
packages/ui/src/DateRanger/demo/copy-paste.tsx |
Copy/paste format + locale demo |
Verification
pnpm lint:demo-locale
Script: scripts/check-demo-locale.mjs — scans exposed components only; supports --allowlist.
Example
Input (excerpt):
---
title: Button 按钮
---
## 组件说明
按钮用于开始一个即时操作。
Output:
---
title: Button
---
## Component Description
Button is used to trigger an instant action.
1---2name: translate-docs3description: Translates Chinese Markdown documentation to English for oceanbase-design i18n. Use when translating docs, creating *.en-US.md files, or when the user asks for doc translation, i18n translation, or zh-CN to en-US conversion.4---56# Translate Docs (zh-CN → en-US)78Translates Chinese Markdown docs to English for the oceanbase-design site.910## File naming conventions1112Dumi default locale is **en-US** at `/`; **zh-CN** uses `/zh-CN` prefix.1314| Area | English (en-US) | Chinese (zh-CN) |15| ----------------------------------- | ---------------- | --------------- |16| `docs/**` site docs | `foo.md` | `foo.zh-CN.md` |17| `packages/**/src/**` component docs | `index.en-US.md` | `index.md` |1819**Rules**2021- `docs/`: unsuffixed `.md` = English; `.zh-CN.md` = Chinese (including `docs/blog/`).22- `packages/`: `index.md` = Chinese; `index.en-US.md` = English (legacy layout; do not rename without a migration plan).23- Internal links in Chinese docs: locale-agnostic paths (`/components/button`). `rehypePlugin` adds `/zh-CN` for `.zh-CN.md` files.24- Sidebar locale filtering uses filename suffix (see `isSidebarItemZhCN` in `.dumi/theme/utils.ts`).2526## When to Use2728- User asks to translate a doc, create English version, or generate `*.en-US.md` / split `*.zh-CN.md`29- Batch translating `docs/` or `packages/*/src/**/index.md` for i18n3031## Workflow32331. Read the source Chinese file (`.md` in packages, or `.zh-CN.md` in docs)342. Apply [glossary.json](glossary.json) for consistent terminology353. Translate content; preserve structure (see rules below)364. Write output:37 - `docs/foo.zh-CN.md` → `docs/foo.md`38 - `packages/design/src/button/index.md` → `packages/design/src/button/index.en-US.md`3940## Rules4142### Do NOT translate4344- Code blocks (`...`) — keep as-is; only translate Chinese comments inside code if present45- Frontmatter keys: `title`, `order`, `group`, `path`, `nav` — translate values only46- Link paths: `/components/button`, `/docs/design-introduce` — keep unchanged47- `<code src="...">` — keep `src` path; translate `title` and `description` attributes48- `<embed src="...">` — keep `src` path unchanged49- File paths, package names, API names5051### Do translate5253- Body text, headings, paragraphs, list items54- Frontmatter `title`, `group.title`, `nav.title` values55- `<code title="..." description="...">` attribute values56- Table headers and cell content (except code/API names)5758### Structure preservation5960- Keep heading levels (`#`, `##`, `###`)61- Keep Markdown syntax (lists, tables, links)62- Keep Dumi directives: `<code>`, `<embed>`, `<!-- prettier-ignore -->`6364## Glossary6566Use [glossary.json](glossary.json) for term mapping. Key entries:6768| 中文 | English |69| -------- | ----------------- |70| 按钮 | Button |71| 表单 | Form |72| 表格 | Table |73| 全局配置 | ConfigProvider |74| 分页 | Pagination |75| 日期选择 | DatePicker |76| 选择器 | Select |77| 输入框 | Input |78| 设计系统 | design system |79| 组件库 | component library |8081Full list in [glossary.json](glossary.json). When translating, prefer these mappings for consistency.8283## Output naming8485| Source (Chinese) | Output (English) |86| --------------------------------------- | ------------------------------------------- |87| `docs/design/design-introduce.zh-CN.md` | `docs/design/design-introduce.md` |88| `docs/design/react/for-agents.zh-CN.md` | `docs/design/react/for-agents.md` |89| `packages/design/src/button/index.md` | `packages/design/src/button/index.en-US.md` |9091## Integration with baoyu-translate9293When `baoyu-translate` (from JimLiu/baoyu-skills) is available:9495- Use `/translate --to en-US --mode normal docs/design/design-introduce.md` for full workflow (analyze → translate)96- Use `--mode refined` for publication-quality docs (analyze → translate → review → polish)97- Output: `{source}-en-US/translation.md` — copy to `{source}.en-US.md` for Dumi98- Project EXTEND.md: `.baoyu-skills/baoyu-translate/EXTEND.md` (glossary: `glossary-zh-en.md`)99100## Composer / Batch Tips101102When translating multiple files with Cursor Composer:103104- **Batch prompt**: "Translate the following docs to English using the translate-docs skill. Create \*.en-US.md for each. Apply glossary.json for terminology."105- **Consistency check**: After batch translation, run "Compare keys/terms across all \*.en-US.md files. List any inconsistent translations."106- **Review**: Always do human spot-check on P0 docs (design-introduce, quickstart, component overview).107108## Demo Anglicization109110Exposed component demos (`sidebar-locales.ts` whitelist) must use **English UI text** in `demo/*.{ts,tsx}`.111112### Strategy113114- One shared English demo per example; both `index.md` and `index.en-US.md` reference the same `src`115- Align with ant-design demos when a counterpart exists (`ant-design/components/{name}/demo/`)116- For OB-only components (`Filter`, `BasicLayout`, `ProTable`, etc.), use [glossary.json](glossary.json) `demoMock` entries117118### Translate in demos119120- Labels, placeholders, button text, table columns, mock data, chart categories121- Code comments when they contain Chinese122123### Do NOT translate124125- Imports, API prop names, types126- i18n/locale demos that intentionally show language switching127- CJK sample text in font-rendering demos128129### Allowlist (keep CJK)130131| File | Reason |132| ----------------------------------------------------- | ------------------------------- |133| `packages/design/src/locale/demo/basic.tsx` | Locale switching demo |134| `packages/design/src/typography/demo/font-family.tsx` | CJK font sample text |135| `packages/ui/src/DateRanger/demo/locale.tsx` | Locale switching demo |136| `packages/ui/src/DateRanger/demo/copy-paste.tsx` | Copy/paste format + locale demo |137138### Verification139140```bash141pnpm lint:demo-locale142```143144Script: `scripts/check-demo-locale.mjs` — scans exposed components only; supports `--allowlist`.145146## Example147148**Input (excerpt):**149150```markdown151---152title: Button 按钮153---154155## 组件说明156157按钮用于开始一个即时操作。158```159160**Output:**161162```markdown163---164title: Button165---166167## Component Description168169Button is used to trigger an instant action.170```