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
46 changes: 46 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"hooks": {
"PreToolUse": [
{
"matcher": "Edit",
"hooks": [
{
"type": "command",
"command": "if echo \"$CLAUDE_TOOL_INPUT\" | grep -q '\\.po\"'; then echo '[Translation Context] Remember: Use skills translate-po, terminology-check, validate-translation. Check doc-translate/references/terminology.md for terms.'; fi"
}
]
}
],
"PostToolUse": [
{
"matcher": "Edit",
"hooks": [
{
"type": "command",
"command": "if echo \"$CLAUDE_TOOL_INPUT\" | grep -q '\\.po\"'; then echo '[Post-Edit Reminder] Run: make lint to verify reST syntax. Check terminology with terminology-check skill.'; fi"
}
]
},
{
"matcher": "Write",
"hooks": [
{
"type": "command",
"command": "if echo \"$CLAUDE_TOOL_INPUT\" | grep -q '\\.po\"'; then echo '[Post-Write Reminder] PO file modified. Verify: 1) Line length <= 79 chars, 2) Terminology consistency, 3) reST syntax with make lint'; fi"
}
]
}
]
},
"permissions": {
"allow": [
"Bash(make lint)",
"Bash(make build *)",
"Bash(make fuzzy)",
"Bash(make todo)",
"Bash(make progress)",
"Bash(powrap *)"
]
}
}
170 changes: 170 additions & 0 deletions .claude/skills/terminology-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
---
name: terminology-check
description: Check and enforce terminology consistency based on project glossary. Identifies zh_CN variants and suggests zh_TW corrections.
metadata:
short-description: Terminology consistency checker
---

# terminology-check

## Scope
- Check terminology against project glossary
- Identify zh_CN to zh_TW conversion needs
- Track term usage consistency across files
- Suggest standardized translations

## Terminology Sources

### Primary: glossary.po
Official Python glossary translations at project root.

### Secondary: terminology.md
Quick reference at `doc-translate/references/terminology.md`.

### Tertiary: Built-in Mapping
Common zh_CN to zh_TW corrections (from `.scripts/google_translate/utils.py`).

## Forbidden Terms (zh_CN -> zh_TW)

These Simplified Chinese terms MUST be converted:

| Forbidden | Required | English |
|-----------|----------|---------|
| 創建 | 建立 | create |
| 代碼 | 程式碼 | code |
| 信息 | 資訊 | information |
| 模塊 | 模組 | module |
| 標誌 | 旗標 | flag |
| 異常 | 例外 | exception |
| 解釋器 | 直譯器 | interpreter |
| 頭文件 | 標頭檔 | header |
| 對象 | 物件 | object |
| 支持 | 支援 | support |
| 默認 | 預設 | default |
| 兼容 | 相容 | compatible |
| 字符串 | 字串 | string |
| 宏 | 巨集 | macro |
| 描述符 | 描述器 | descriptor |
| 字節 | 位元組 | bytes |
| 緩存 | 快取 | cache |
| 調用 | 呼叫 | call |
| 哈希 | 雜湊 | hash |
| 類型 | 型別 | type |
| 子類 | 子類別 | subclass |
| 實現 | 實作 | implement |
| 數據 | 資料 | data |
| 返回 | 回傳 | return |
| 指針 | 指標 | pointer |
| 字段 | 欄位 | field |
| 擴展 | 擴充 | extension |
| 遞歸 | 遞迴 | recursive |
| 用戶 | 使用者 | user |
| 算法 | 演算法 | algorithm |
| 優化 | 最佳化 | optimize |
| 字符 | 字元 | character |
| 設置 | 設定 | setting |
| 線程 | 執行緒 | thread |
| 進程 | 行程 | process |
| 迭代 | 疊代 | iterate |
| 內存 | 記憶體 | memory |
| 打印 | 印出 | print |
| 異步 | 非同步 | async |
| 調試 | 除錯 | debug |
| 堆棧 | 堆疊 | stack |
| 回調 | 回呼 | callback |
| 公共 | 公開 | public |
| 函數 | 函式 | function |
| 變量 | 變數 | variable |
| 常量 | 常數 | constant |
| 添加 | 新增 | add |
| 轉義 | 跳脫 | escape |
| 基類 | 基底類別 | base class |

## High-Frequency Terms (Keep in English)

These terms should NOT be translated, even if glossary has translations:

```
int, float, str, bytes, bool
list, tuple, dict, set
iterator, generator, iterable
pickle, module, method
True, False, None
```

## Standard Translations

Core Python terms with required zh_TW translations:

| English | Traditional Chinese |
|---------|---------------------|
| abstract base class | 抽象基底類別 |
| annotation | 註釋 |
| argument | 引數 |
| attribute | 屬性 |
| callable | 可呼叫物件 |
| class | 類別 |
| closure | 閉包 |
| context manager | 情境管理器 |
| coroutine | 協程 |
| decorator | 裝飾器 |
| descriptor | 描述器 |
| dictionary | 字典 |
| docstring | 說明字串 |
| exception | 例外 |
| expression | 運算式 |
| function | 函式 |
| generator | 產生器 |
| global | 全域 |
| immutable | 不可變物件 |
| import | 引入 |
| instance | 實例 |
| interpreter | 直譯器 |
| iterable | 可疊代物件 |
| iterator | 疊代器 |
| keyword argument | 關鍵字引數 |
| list comprehension | 串列綜合運算 |
| local | 區域 |
| method | 方法 |
| module | 模組 |
| mutable | 可變物件 |
| namespace | 命名空間 |
| object | 物件 |
| package | 套件 |
| parameter | 參數 |
| positional argument | 位置引數 |
| sequence | 序列 |
| slice | 切片 |
| statement | 陳述式 |
| type | 型別 |
| variable | 變數 |

## Check Process

1. **Extract terms** - Parse msgstr for Chinese phrases and English words
2. **Check forbidden** - Flag any zh_CN variants from the forbidden list
3. **Check consistency** - Compare with other translations of same term
4. **Check glossary** - Verify against official glossary.po
5. **Report issues** - List violations with suggestions

## Output Format

```
=== Terminology Report: library/functions.po ===

FORBIDDEN TERMS (must fix):
Line 42: "函數" -> "函式" (function)
Line 78: "返回" -> "回傳" (return)
Line 156: "對象" -> "物件" (object)

INCONSISTENT TERMS (review):
"iterator" translated as:
- "疊代器" (45 occurrences) <- standard
- "迭代器" (3 occurrences) <- zh_CN variant

Total: 3 forbidden, 1 inconsistent
```

## Related Skills
- `doc-translate` - General translation rules
- `validate-translation` - Comprehensive validation
156 changes: 156 additions & 0 deletions .claude/skills/translate-po.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
name: translate-po
description: Core skill for translating PO file entries from English to Traditional Chinese. Orchestrates doc-translate, rst-translate, and terminology-check.
metadata:
short-description: Translate PO entries EN->zh_TW
---

# translate-po

## Scope
- Translate English PO msgid entries to Traditional Chinese msgstr
- Apply all formatting, punctuation, and spacing rules
- Preserve reStructuredText syntax exactly
- Maintain terminology consistency with glossary
- Mark uncertain translations with fuzzy flag

## Prerequisites

Before translating, always:
1. Read the full msgid to understand context
2. Check msgctxt for additional context if present
3. Review translator comments (#. and #:)
4. Look up unfamiliar terms in glossary references

## Translation Workflow

### Step 1: Analyze Content Type

Identify what you're translating:
- **Pure prose** - No markup, straightforward translation
- **Code-only** - Preserve exactly, do not translate
- **Mixed** - Prose with inline code/roles (most common)
- **reST structural** - Directives, links, complex markup

### Step 2: Apply Translation Rules

#### Punctuation
```
Chinese sentences -> Full-width: 「」()、,。:;!?
English sentences -> Half-width: (),.;:!?
```

#### Spacing
```
Add space between CJK and Latin: 使用 CPU 運算
No space with symbols: 使用「CPU」運算
```

#### Terminology
- Use `terminology-check` skill for reference
- High-frequency terms stay English: int, float, str, list, tuple, dict, iterator, generator
- Follow glossary for standard terms

### Step 3: Handle reST Syntax

Use `rst-translate` skill rules:

#### Roles - Keep syntax, translate display text if needed
```
:mod:`os` -> :mod:`os` (unchanged)
:term:`iterator` -> :term:`疊代器 <iterator>`
:ref:`section-name` -> :ref:`章節名稱 <section-name>`
```

#### Backslash Escaping
```
CJK before role: 參閱\\ :mod:`os`
CJK after link: `連結 <url>`_\\ 中
Full-width after: :term:`object`\\(
```

#### Literal Blocks
```
msgid "Example::"
msgstr "範例: ::"
```

### Step 4: Format Output

#### Line Wrapping (max 79 chars)
```
msgstr ""
"第一行翻譯內容"
"第二行繼續翻譯。"
```

#### Fuzzy Flag
Add `#, fuzzy` when:
- Translation is uncertain
- Machine-translated content
- Needs human review

```
#, fuzzy
msgid "Original text"
msgstr "可能需要審核的翻譯"
```

## Quality Checklist

Before finalizing, verify:
- [ ] Line length <= 79 characters
- [ ] Punctuation rules followed (full-width for Chinese)
- [ ] Spacing rules followed (space between CJK/Latin)
- [ ] reST syntax preserved exactly
- [ ] Terminology consistent with glossary
- [ ] No empty msgstr (unless intentionally skipping)

## Examples

### Simple Prose
```
msgid "Python is a programming language."
msgstr "Python 是一種程式語言。"
```

### With Terminology
```
msgid "This function returns an iterator."
msgstr "此函式回傳一個疊代器。"
```

### With reST Role
```
msgid "See :func:`len` for details."
msgstr "詳情請參閱\\ :func:`len`。"
```

### With Link
```
msgid "Visit the `Python website <https://python.org>`_."
msgstr "請造訪 `Python 網站 <https://python.org>`_。"
```

### With Term Reference
```
msgid "Returns a :term:`context manager`."
msgstr "回傳一個\\ :term:`情境管理器 <context manager>`。"
```

### Mixed Content
```
msgid "The :class:`list` type is a :term:`mutable` sequence."
msgstr ":class:`list` 型別是一個\\ :term:`可變物件 <mutable>` 序列。"
```

## Related Skills
- `doc-translate` - General translation rules
- `rst-translate` - reST-specific rules
- `terminology-check` - Terminology validation
- `validate-translation` - Post-translation validation

## References
- Terminology: `doc-translate/references/terminology.md`
- Glossary: `glossary.po`
- Wiki: https://github.com/python/python-docs-zh-tw/wiki/術語列表
Loading