Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .claude/skills/translate-po/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Identify content type:
- Add space between Chinese and Latin: "使用 CPU 運算" (correct)
- No space with symbols: "使用「CPU」運算" (correct)

**Parentheses:** Chinese inside -> full-width `()`; English only inside ->
half-width with spaces around, e.g. "全域直譯器鎖 (GIL) 被停用". Annotate a term
only at its first occurrence on the page.

**Line Width:** Max 79 characters (use multi-line format for longer text)

### Step 3: reST Handling
Expand All @@ -43,7 +47,9 @@ See `references/rst-cheatsheet.md` for complete rules.
**Key patterns:**
- `:mod:`os`` -> Keep unchanged
- `:term:`iterator`` -> `:term:`疊代器 <iterator>``
- Chinese before role: "參閱\\ :mod:`os`"
- Role renders Latin (`:mod:`, `:func:`, `:class:`, `:ref:` without a title): plain space, "參閱 :mod:`os`"
- Role renders Chinese (`:term:`/`:ref:` with a translated title): `\\ ` separator, "一個\\ :term:`情境管理器 <context manager>`"
- `\\ ` renders as nothing, so never put it before a role that renders Latin (it removes the required CJK-Latin space). See `references/rst-cheatsheet.md`
- After `::` markers: "範例: ::"

### Step 4: Terminology Workflow
Expand All @@ -67,7 +73,8 @@ For uncertain translations, add `#, fuzzy` flag before the entry.
Before outputting, verify:
- [ ] Line length <= 79 characters
- [ ] Full-width punctuation in Chinese text
- [ ] CJK-Latin spacing correct
- [ ] CJK-Latin spacing correct (also across roles: no `\\ ` before roles that render Latin)
- [ ] Parentheses: English-only content uses half-width `( )` with spaces
- [ ] reST syntax preserved
- [ ] Terminology matches glossary
- [ ] No forbidden zh_CN terms
Expand All @@ -89,7 +96,7 @@ msgstr "此函式回傳一個疊代器。"
### With reST Role
```
msgid "See :func:`len` for details."
msgstr "詳情請參閱\\ :func:`len`。"
msgstr "詳情請參閱 :func:`len`。"
```

### With Link
Expand Down
31 changes: 28 additions & 3 deletions .claude/skills/translate-po/references/rst-cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ Rules for preserving reStructuredText syntax in translations.

## Backslash Escaping

Use `\\ ` (backslash-backslash-space) as zero-width separator:
`\\ ` (backslash-backslash-space) is a zero-width separator. It is needed where
reST requires a boundary but no visible space is wanted (see the table below
for when a plain space is the right choice instead):

### CJK Before Role
### CJK Before Role (only if the role renders Chinese)
```
# Wrong
參閱:mod:`os`模組

# Correct
參閱\\ :mod:`os` 模組
參閱 :mod:`os` 模組
```

### CJK After Link
Expand All @@ -58,6 +60,29 @@ Use `\\ ` (backslash-backslash-space) as zero-width separator:
`連結 <url>`_\\ 中
```

### Rendered Text Decides: `\\ ` or a Space

`\\ ` renders as nothing, so it removes the space the CJK-Latin rule requires.
Choose by what the role *renders*, not by how the source looks:

| Role renders | Use | Example |
|--------------|-----|---------|
| Chinese (`:term:` with a translated display text) | `\\ ` | `包含\\ :term:`擴充模組 <extension module>`\\ 的套件` |
| Latin (`:ref:`/`:doc:` with no explicit title, which shows the target's English section title; `:mod:`, `:func:`, `:class:`, etc.) | a plain space | `請參閱 :ref:`threadsafety`。` |

```
# Wrong: renders "請參閱C API Extension Support for Free Threading"
請參閱\\ :ref:`freethreading-extensions-howto`。

# Correct: renders "請參閱 C API Extension Support for Free Threading"
請參閱 :ref:`freethreading-extensions-howto`。
```

For `:ref:`/`:doc:` without an explicit title, the rendered text is the
target page's title, which is often still English, so check the rendered page.
A role with a translated title (`:ref:`詳細說明 <detail-section>``) renders
Chinese, so `\\ ` applies.

### Full-width Punctuation After Role
```
# May break build
Expand Down
Loading