|
| 1 | +# OpenIM Docs - Codex Agent Instructions |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +This is the OpenIM documentation site built with Docusaurus. It supports two locales: |
| 6 | +- **zh-Hans** (Chinese, default): Source files in `docs/` |
| 7 | +- **en** (English): Translated files in `i18n/en/` |
| 8 | + |
| 9 | +## Translation Task |
| 10 | + |
| 11 | +When asked to translate documentation, follow the rules below. |
| 12 | + |
| 13 | +### Path Mapping |
| 14 | + |
| 15 | +| Source (Chinese) | Target (English) | |
| 16 | +|-----------------|------------------| |
| 17 | +| `docs/sdks/` | `i18n/en/docusaurus-plugin-content-docs-sdks/current/` | |
| 18 | +| `docs/guides/` | `i18n/en/docusaurus-plugin-content-docs-guides/current/` | |
| 19 | +| `docs/restapi/` | `i18n/en/docusaurus-plugin-content-docs-restapi/current/` | |
| 20 | +| `docs/blog/` | `i18n/en/docusaurus-plugin-content-docs-blog/current/` | |
| 21 | + |
| 22 | +### Translation Rules |
| 23 | + |
| 24 | +1. **Keep unchanged**: |
| 25 | + - All code blocks (` ``` `) content |
| 26 | + - Frontmatter keys (only translate Chinese values like `title`, `description`) |
| 27 | + - JSX/MDX component tags (`<Tabs>`, `<TabItem>`, etc.) |
| 28 | + - Markdown link paths and URLs |
| 29 | + - Variable names, function names, class names |
| 30 | + - Import statements |
| 31 | + |
| 32 | +2. **Translate**: |
| 33 | + - All Chinese text content to natural English |
| 34 | + - Table headers and cell content (Chinese → English) |
| 35 | + - Section headings (e.g., `## 功能介绍` → `## Description`) |
| 36 | + - Inline comments in code examples (Chinese → English) |
| 37 | + |
| 38 | +3. **Common translations** (keep consistent across all files): |
| 39 | + - 功能介绍 → Description |
| 40 | + - 返回原型 → Return Prototype |
| 41 | + - 返回结果 → Return Results |
| 42 | + - 调用示例 → Call Example |
| 43 | + - 名称 → Name |
| 44 | + - 类型 → Type |
| 45 | + - 描述 → Description |
| 46 | + |
| 47 | +### Sidebar Labels |
| 48 | + |
| 49 | +Sidebar category labels for each docs plugin are translated in **two places**: |
| 50 | + |
| 51 | +1. **`_category_.json`** files in the corresponding `i18n/en/` directory |
| 52 | +2. **`current.json`** files at `i18n/en/docusaurus-plugin-content-docs-*/current.json` |
| 53 | + |
| 54 | +For `current.json`: |
| 55 | +- The **key** stays the same (may contain Chinese category name as identifier) |
| 56 | +- Only the **`message`** field should be translated to English |
| 57 | +- The **`description`** field should also be updated to reflect the English label |
| 58 | + |
| 59 | +Example: |
| 60 | +```json |
| 61 | +{ |
| 62 | + "sidebar.tutorialSidebar.category.用户管理": { |
| 63 | + "message": "User Management", |
| 64 | + "description": "The label for category 'User Management' in sidebar 'tutorialSidebar'" |
| 65 | + } |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +### New Category Handling |
| 70 | + |
| 71 | +If a new `_category_.json` is added in the source `docs/` directory: |
| 72 | +1. Create the corresponding `_category_.json` in `i18n/en/` with translated `label` |
| 73 | +2. Run `npx docusaurus write-translations --locale en` to regenerate `current.json` |
| 74 | +3. Translate any new Chinese entries in `current.json` |
| 75 | + |
| 76 | +## Verification |
| 77 | + |
| 78 | +After translating, verify: |
| 79 | +1. No Chinese characters remain in translated `message` values |
| 80 | +2. Build succeeds: `pnpm build` |
0 commit comments