Skip to content

Commit fb7c608

Browse files
committed
feat: add Claude settings, skills, and agent guidelines
1 parent 8a3eb14 commit fb7c608

File tree

7 files changed

+585
-42
lines changed

7 files changed

+585
-42
lines changed

.claude/settings.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"$schema": "https://json.schemastore.org/claude-code-settings.json",
3+
"hooks": {
4+
"PreToolUse": [
5+
{
6+
"matcher": "Edit",
7+
"hooks": [
8+
{
9+
"type": "command",
10+
"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"
11+
}
12+
]
13+
}
14+
],
15+
"PostToolUse": [
16+
{
17+
"matcher": "Edit",
18+
"hooks": [
19+
{
20+
"type": "command",
21+
"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"
22+
}
23+
]
24+
},
25+
{
26+
"matcher": "Write",
27+
"hooks": [
28+
{
29+
"type": "command",
30+
"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"
31+
}
32+
]
33+
}
34+
]
35+
},
36+
"permissions": {
37+
"allow": [
38+
"Bash(make lint)",
39+
"Bash(make build *)",
40+
"Bash(make fuzzy)",
41+
"Bash(make todo)",
42+
"Bash(make progress)",
43+
"Bash(powrap *)"
44+
]
45+
}
46+
}
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
---
2+
name: terminology-check
3+
description: Check and enforce terminology consistency based on project glossary. Identifies zh_CN variants and suggests zh_TW corrections.
4+
metadata:
5+
short-description: Terminology consistency checker
6+
---
7+
8+
# terminology-check
9+
10+
## Scope
11+
- Check terminology against project glossary
12+
- Identify zh_CN to zh_TW conversion needs
13+
- Track term usage consistency across files
14+
- Suggest standardized translations
15+
16+
## Terminology Sources
17+
18+
### Primary: glossary.po
19+
Official Python glossary translations at project root.
20+
21+
### Secondary: terminology.md
22+
Quick reference at `doc-translate/references/terminology.md`.
23+
24+
### Tertiary: Built-in Mapping
25+
Common zh_CN to zh_TW corrections (from `.scripts/google_translate/utils.py`).
26+
27+
## Forbidden Terms (zh_CN -> zh_TW)
28+
29+
These Simplified Chinese terms MUST be converted:
30+
31+
| Forbidden | Required | English |
32+
|-----------|----------|---------|
33+
| 創建 | 建立 | create |
34+
| 代碼 | 程式碼 | code |
35+
| 信息 | 資訊 | information |
36+
| 模塊 | 模組 | module |
37+
| 標誌 | 旗標 | flag |
38+
| 異常 | 例外 | exception |
39+
| 解釋器 | 直譯器 | interpreter |
40+
| 頭文件 | 標頭檔 | header |
41+
| 對象 | 物件 | object |
42+
| 支持 | 支援 | support |
43+
| 默認 | 預設 | default |
44+
| 兼容 | 相容 | compatible |
45+
| 字符串 | 字串 | string |
46+
|| 巨集 | macro |
47+
| 描述符 | 描述器 | descriptor |
48+
| 字節 | 位元組 | bytes |
49+
| 緩存 | 快取 | cache |
50+
| 調用 | 呼叫 | call |
51+
| 哈希 | 雜湊 | hash |
52+
| 類型 | 型別 | type |
53+
| 子類 | 子類別 | subclass |
54+
| 實現 | 實作 | implement |
55+
| 數據 | 資料 | data |
56+
| 返回 | 回傳 | return |
57+
| 指針 | 指標 | pointer |
58+
| 字段 | 欄位 | field |
59+
| 擴展 | 擴充 | extension |
60+
| 遞歸 | 遞迴 | recursive |
61+
| 用戶 | 使用者 | user |
62+
| 算法 | 演算法 | algorithm |
63+
| 優化 | 最佳化 | optimize |
64+
| 字符 | 字元 | character |
65+
| 設置 | 設定 | setting |
66+
| 線程 | 執行緒 | thread |
67+
| 進程 | 行程 | process |
68+
| 迭代 | 疊代 | iterate |
69+
| 內存 | 記憶體 | memory |
70+
| 打印 | 印出 | print |
71+
| 異步 | 非同步 | async |
72+
| 調試 | 除錯 | debug |
73+
| 堆棧 | 堆疊 | stack |
74+
| 回調 | 回呼 | callback |
75+
| 公共 | 公開 | public |
76+
| 函數 | 函式 | function |
77+
| 變量 | 變數 | variable |
78+
| 常量 | 常數 | constant |
79+
| 添加 | 新增 | add |
80+
| 轉義 | 跳脫 | escape |
81+
| 基類 | 基底類別 | base class |
82+
83+
## High-Frequency Terms (Keep in English)
84+
85+
These terms should NOT be translated, even if glossary has translations:
86+
87+
```
88+
int, float, str, bytes, bool
89+
list, tuple, dict, set
90+
iterator, generator, iterable
91+
pickle, module, method
92+
True, False, None
93+
```
94+
95+
## Standard Translations
96+
97+
Core Python terms with required zh_TW translations:
98+
99+
| English | Traditional Chinese |
100+
|---------|---------------------|
101+
| abstract base class | 抽象基底類別 |
102+
| annotation | 註釋 |
103+
| argument | 引數 |
104+
| attribute | 屬性 |
105+
| callable | 可呼叫物件 |
106+
| class | 類別 |
107+
| closure | 閉包 |
108+
| context manager | 情境管理器 |
109+
| coroutine | 協程 |
110+
| decorator | 裝飾器 |
111+
| descriptor | 描述器 |
112+
| dictionary | 字典 |
113+
| docstring | 說明字串 |
114+
| exception | 例外 |
115+
| expression | 運算式 |
116+
| function | 函式 |
117+
| generator | 產生器 |
118+
| global | 全域 |
119+
| immutable | 不可變物件 |
120+
| import | 引入 |
121+
| instance | 實例 |
122+
| interpreter | 直譯器 |
123+
| iterable | 可疊代物件 |
124+
| iterator | 疊代器 |
125+
| keyword argument | 關鍵字引數 |
126+
| list comprehension | 串列綜合運算 |
127+
| local | 區域 |
128+
| method | 方法 |
129+
| module | 模組 |
130+
| mutable | 可變物件 |
131+
| namespace | 命名空間 |
132+
| object | 物件 |
133+
| package | 套件 |
134+
| parameter | 參數 |
135+
| positional argument | 位置引數 |
136+
| sequence | 序列 |
137+
| slice | 切片 |
138+
| statement | 陳述式 |
139+
| type | 型別 |
140+
| variable | 變數 |
141+
142+
## Check Process
143+
144+
1. **Extract terms** - Parse msgstr for Chinese phrases and English words
145+
2. **Check forbidden** - Flag any zh_CN variants from the forbidden list
146+
3. **Check consistency** - Compare with other translations of same term
147+
4. **Check glossary** - Verify against official glossary.po
148+
5. **Report issues** - List violations with suggestions
149+
150+
## Output Format
151+
152+
```
153+
=== Terminology Report: library/functions.po ===
154+
155+
FORBIDDEN TERMS (must fix):
156+
Line 42: "函數" -> "函式" (function)
157+
Line 78: "返回" -> "回傳" (return)
158+
Line 156: "對象" -> "物件" (object)
159+
160+
INCONSISTENT TERMS (review):
161+
"iterator" translated as:
162+
- "疊代器" (45 occurrences) <- standard
163+
- "迭代器" (3 occurrences) <- zh_CN variant
164+
165+
Total: 3 forbidden, 1 inconsistent
166+
```
167+
168+
## Related Skills
169+
- `doc-translate` - General translation rules
170+
- `validate-translation` - Comprehensive validation

.claude/skills/translate-po.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
name: translate-po
3+
description: Core skill for translating PO file entries from English to Traditional Chinese. Orchestrates doc-translate, rst-translate, and terminology-check.
4+
metadata:
5+
short-description: Translate PO entries EN->zh_TW
6+
---
7+
8+
# translate-po
9+
10+
## Scope
11+
- Translate English PO msgid entries to Traditional Chinese msgstr
12+
- Apply all formatting, punctuation, and spacing rules
13+
- Preserve reStructuredText syntax exactly
14+
- Maintain terminology consistency with glossary
15+
- Mark uncertain translations with fuzzy flag
16+
17+
## Prerequisites
18+
19+
Before translating, always:
20+
1. Read the full msgid to understand context
21+
2. Check msgctxt for additional context if present
22+
3. Review translator comments (#. and #:)
23+
4. Look up unfamiliar terms in glossary references
24+
25+
## Translation Workflow
26+
27+
### Step 1: Analyze Content Type
28+
29+
Identify what you're translating:
30+
- **Pure prose** - No markup, straightforward translation
31+
- **Code-only** - Preserve exactly, do not translate
32+
- **Mixed** - Prose with inline code/roles (most common)
33+
- **reST structural** - Directives, links, complex markup
34+
35+
### Step 2: Apply Translation Rules
36+
37+
#### Punctuation
38+
```
39+
Chinese sentences -> Full-width: 「」()、,。:;!?
40+
English sentences -> Half-width: (),.;:!?
41+
```
42+
43+
#### Spacing
44+
```
45+
Add space between CJK and Latin: 使用 CPU 運算
46+
No space with symbols: 使用「CPU」運算
47+
```
48+
49+
#### Terminology
50+
- Use `terminology-check` skill for reference
51+
- High-frequency terms stay English: int, float, str, list, tuple, dict, iterator, generator
52+
- Follow glossary for standard terms
53+
54+
### Step 3: Handle reST Syntax
55+
56+
Use `rst-translate` skill rules:
57+
58+
#### Roles - Keep syntax, translate display text if needed
59+
```
60+
:mod:`os` -> :mod:`os` (unchanged)
61+
:term:`iterator` -> :term:`疊代器 <iterator>`
62+
:ref:`section-name` -> :ref:`章節名稱 <section-name>`
63+
```
64+
65+
#### Backslash Escaping
66+
```
67+
CJK before role: 參閱\\ :mod:`os`
68+
CJK after link: `連結 <url>`_\\ 中
69+
Full-width after: :term:`object`\\(
70+
```
71+
72+
#### Literal Blocks
73+
```
74+
msgid "Example::"
75+
msgstr "範例: ::"
76+
```
77+
78+
### Step 4: Format Output
79+
80+
#### Line Wrapping (max 79 chars)
81+
```
82+
msgstr ""
83+
"第一行翻譯內容"
84+
"第二行繼續翻譯。"
85+
```
86+
87+
#### Fuzzy Flag
88+
Add `#, fuzzy` when:
89+
- Translation is uncertain
90+
- Machine-translated content
91+
- Needs human review
92+
93+
```
94+
#, fuzzy
95+
msgid "Original text"
96+
msgstr "可能需要審核的翻譯"
97+
```
98+
99+
## Quality Checklist
100+
101+
Before finalizing, verify:
102+
- [ ] Line length <= 79 characters
103+
- [ ] Punctuation rules followed (full-width for Chinese)
104+
- [ ] Spacing rules followed (space between CJK/Latin)
105+
- [ ] reST syntax preserved exactly
106+
- [ ] Terminology consistent with glossary
107+
- [ ] No empty msgstr (unless intentionally skipping)
108+
109+
## Examples
110+
111+
### Simple Prose
112+
```
113+
msgid "Python is a programming language."
114+
msgstr "Python 是一種程式語言。"
115+
```
116+
117+
### With Terminology
118+
```
119+
msgid "This function returns an iterator."
120+
msgstr "此函式回傳一個疊代器。"
121+
```
122+
123+
### With reST Role
124+
```
125+
msgid "See :func:`len` for details."
126+
msgstr "詳情請參閱\\ :func:`len`。"
127+
```
128+
129+
### With Link
130+
```
131+
msgid "Visit the `Python website <https://python.org>`_."
132+
msgstr "請造訪 `Python 網站 <https://python.org>`_。"
133+
```
134+
135+
### With Term Reference
136+
```
137+
msgid "Returns a :term:`context manager`."
138+
msgstr "回傳一個\\ :term:`情境管理器 <context manager>`。"
139+
```
140+
141+
### Mixed Content
142+
```
143+
msgid "The :class:`list` type is a :term:`mutable` sequence."
144+
msgstr ":class:`list` 型別是一個\\ :term:`可變物件 <mutable>` 序列。"
145+
```
146+
147+
## Related Skills
148+
- `doc-translate` - General translation rules
149+
- `rst-translate` - reST-specific rules
150+
- `terminology-check` - Terminology validation
151+
- `validate-translation` - Post-translation validation
152+
153+
## References
154+
- Terminology: `doc-translate/references/terminology.md`
155+
- Glossary: `glossary.po`
156+
- Wiki: https://github.com/python/python-docs-zh-tw/wiki/術語列表

0 commit comments

Comments
 (0)