Skip to content

Commit 12ba1f9

Browse files
josixclaude
andcommitted
Add rendered-HTML review and past review corrections to translation skills
- .scripts/render_review.py (stdlib only): builds the given PO files' pages like `make build`, dumps the rendered prose to .render-review/, and flags rendered-only problems (leftover roles, CJK-Latin spacing, stray spaces around full-width punctuation, zh_CN wording, English paragraphs) - new review-rendered-html skill: build, read the text dump as a reader, and inspect Playwright screenshots of the changed sections; includes a table of common rendered-only problems and fixes - translate-po/references/review-corrections.md: what reviewers most often correct, mined from ~1,500 inline review comments in 150 merged PRs (#763-#1246), with examples and a table of reviewer-enforced terms - translate-po gains a past-review checklist step and a rendered-page step; validate-translation and check-terminology reference both; CLAUDE.md points to the new script; .gitignore covers the review output dirs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H2AUU3pZYEkfs9BY3mm7bn
1 parent a2de965 commit 12ba1f9

8 files changed

Lines changed: 773 additions & 1 deletion

File tree

‎.claude/skills/check-terminology/SKILL.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Check terminology against project glossary and zh_CN/zh_TW mappings.
1414
2. **Secondary:** `focused_terminology_dictionary.csv` - 118 key terms
1515
3. **Tertiary:** `.scripts/google_translate/utils.py` - zh_CN to zh_TW mappings
1616
4. **Usage evidence (not authority):** `.scripts/translation_memory.sh query "<term>"` - how existing translated .po entries render the term (skip if the command fails)
17+
5. **Reviewer-enforced terms:** the "Terminology enforced by reviewers" table in `../translate-po/references/review-corrections.md` - pairs reviewers repeatedly corrected (e.g. 傳回→回傳, 您→你, 協議→協定, 運行→執行), some context-dependent (串列 vs 清單, 檔案 vs 文件)
1718

1819
## Check Process
1920

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
name: review-rendered-html
3+
description: Builds translated PO files into HTML and reviews the rendered page for reading flow and formatting, by reading the extracted page text and checking Playwright screenshots. Use after translating or editing a PO file, before opening a PR.
4+
argument-hint: <po-file> [<po-file> ...]
5+
---
6+
7+
# review-rendered-html
8+
9+
PO-level checks (`msgfmt`, `make lint`, terminology) cannot show how a
10+
translation reads on the published page. reST roles disappear, links and
11+
literals change spacing, and Sphinx adds its own labels. Review the rendered
12+
HTML of every page you changed before opening a PR.
13+
14+
## Prerequisites
15+
16+
- CPython clone at `../cpython` on the branch matching `VERSION` in the
17+
Makefile, and the docs venv (`make prepare_deps` sets up both)
18+
- Playwright MCP tools (`browser_navigate`, `browser_take_screenshot`) for
19+
screenshots; without them, read the text dump only and say so in the report
20+
21+
## Step 1: Build and dump the rendered text
22+
23+
```bash
24+
python3 .scripts/render_review.py library/dataclasses.po [faq/library.po ...]
25+
```
26+
27+
- Builds only the given pages (same Sphinx options as `make build`) and writes
28+
the page prose, without code blocks, to `.render-review/<page>.txt`
29+
- Prints heuristic findings with the line in the text dump; `--no-build`
30+
re-checks without rebuilding
31+
- "build reported problems" about `redirects to builtins/...` comes from a
32+
reused build directory and does not affect the page
33+
34+
## Step 2: Read the text dump as a reader
35+
36+
Read `.render-review/<page>.txt` end to end, focusing on paragraphs from the
37+
entries you changed. For each one check:
38+
39+
- **Flow:** the sentence reads as natural Taiwanese technical writing; no
40+
translationese (被…所…, 將會是, 除…之外的其他事項), no dangling clauses
41+
after a role's text disappears
42+
- **Spacing:** one space between CJK and Latin/digits/literals; no space
43+
next to full-width punctuation; no stray space inside Chinese text
44+
- **Punctuation:** full-width `,。:;()「」` around Chinese; the colon before
45+
a code block stays `:`
46+
- **Completeness:** compare with the English page when meaning is unclear
47+
48+
Confirm or dismiss every heuristic finding by reading its context. Findings in
49+
entries you did not touch are follow-ups, not part of the current change.
50+
51+
Paragraphs still in English are usually not your bug. Either the entry is
52+
untranslated, or the PO msgid is older than the CPython clone, because the
53+
source changed after the last sync. Mention them in the report and don't fix
54+
them in the PO by hand.
55+
56+
## Step 3: Screenshot and inspect the layout
57+
58+
Serve the build and open the sections you changed:
59+
60+
```bash
61+
python3 -m http.server 8765 --bind 127.0.0.1 --directory ../cpython/Doc/build/html
62+
```
63+
64+
Then use the Playwright MCP tools:
65+
66+
1. `browser_resize` to 1280x1600
67+
2. `browser_navigate` to `http://127.0.0.1:8765/<page>.html#<anchor>`
68+
3. `browser_take_screenshot` with `filename: ".playwright-mcp/<name>.png"`
69+
(the MCP only writes inside the repo; `.playwright-mcp/` is gitignored)
70+
4. Read the PNG and check: links and `:term:` text sit flush with the Chinese
71+
around them, inline code has normal spacing, parameter lists, notes and
72+
admonitions keep their structure, and headings and the sidebar TOC show
73+
the translated titles
74+
75+
Stop the server when done.
76+
77+
## Common rendered-only problems and fixes
78+
79+
| Rendered | Cause in msgstr | Fix |
80+
|---|---|---|
81+
| `field可以` | ``` ``field``\ 可以 ``` | ``` ``field`` 可以 ``` (keep the space after a literal before CJK) |
82+
| `全域直譯器鎖(GIL) 來` | `` :term:`…`\ (GIL) 來 `` | `` :term:`…`\ (GIL)來 `` (full-width parens, no extra space) |
83+
| `磁碟區上的 替代資料串流` | `` 的 `替代資料串流 <url>`_ `` | `` 的\ `替代資料串流 <url>`_ `` |
84+
| `:meth:` or backticks visible | role typo such as `:meth: ` with a space | restore the exact role syntax |
85+
| `` `\ `` visible | escaped backslash doubled in the PO | one `\\ ` in the PO file (`\ ` in the value) |
86+
87+
A reST role or link must be followed by whitespace or ASCII/closing
88+
punctuation, so a full-width opening bracket after a role still needs `\ `.
89+
90+
## Report
91+
92+
List per page: findings fixed, findings dismissed (with reason), follow-ups
93+
in untouched entries, English paragraphs and their likely cause, and the
94+
screenshots you checked.

‎.claude/skills/translate-po/SKILL.md‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,41 @@ See `references/rst-cheatsheet.md` for complete rules.
7676
4. If uncertain, add `#, fuzzy` flag
7777
5. Never use zh_CN terms from `references/forbidden-terms.md`
7878

79+
### Step 5: Check Against Past Review Corrections
80+
81+
Reviewers of this repo keep asking for the same fixes. Before finishing,
82+
re-read every changed msgstr against `references/review-corrections.md`
83+
(mined from ~1,500 review comments). The most frequent ones:
84+
85+
1. **Phrasing and meaning:** no English word order, piles of 的 or needless
86+
被; the meaning must match the source exactly (most common correction)
87+
2. **Terms reviewers enforce:** argument→引數 / parameter→參數, 回傳 (not
88+
傳回/返回), 你 (not 您), 引發 (raise), 設定例外 (C API "set an
89+
exception"), 透過, 協定, 命令列, 用戶端, 執行 (not 運行), 產生 (not 生成),
90+
串列 only for a Python list (otherwise 清單); see the table in the reference
91+
3. **Spacing:** no space next to full-width punctuation, after 。, or
92+
between CJK characters
93+
4. **`\\ `:** use it between CJK and markup, but not next to `,。、:;)「」`
94+
(a full-width `(` right after markup still needs it)
95+
5. **Punctuation:** `、` for enumerations; keep `...` as in the source; keep
96+
ASCII quotes around literal values
97+
6. **Markup:** re-add ``literal`` markup Poedit drops; balanced backticks
98+
7. **Completeness:** no omissions (qualifiers, parentheticals, second
99+
occurrences) and no additions the source does not state (超譯)
100+
8. **Keep English:** socket, token, runtime, yield, library names, and words
101+
that are really parameter names; translate comments in code samples
102+
9. **Consistency:** one rendering per term within a page; search existing
103+
translations (translation memory) before coining a term
104+
10. **PO mechanics:** never just strip `#, fuzzy` without updating the
105+
translation; index-only entries as `English(譯文)`
106+
107+
### Step 6: Review the Rendered Page
108+
109+
After the PO file is saved, build and read the rendered page with the
110+
`review-rendered-html` skill (`python3 .scripts/render_review.py <file>.po`,
111+
then Playwright screenshots of the changed sections). Spacing around
112+
literals, roles and links can only be judged on the rendered page.
113+
79114
## Output Format
80115

81116
```
@@ -95,6 +130,8 @@ Before outputting, verify:
95130
- [ ] Terminology matches glossary
96131
- [ ] No forbidden zh_CN terms
97132
- [ ] Consistent with translation memory hits, unless they conflict with the glossary
133+
- [ ] Checked against past review corrections (`references/review-corrections.md`)
134+
- [ ] Rendered page reads naturally and its layout is correct (`review-rendered-html`)
98135

99136
## Examples
100137

@@ -154,4 +191,6 @@ msgstr "可能需要審核的翻譯"
154191
- `references/terminology.md` - Key term translations (186 terms)
155192
- `references/forbidden-terms.md` - zh_CN to zh_TW mappings
156193
- `references/rst-cheatsheet.md` - reST syntax rules
194+
- `references/review-corrections.md` - What reviewers most often correct, with examples and enforced terms
157195
- `.scripts/translation_memory.sh` - Translation memory lookup over this repo's .po files
196+
- `.scripts/render_review.py` - Build pages and check the rendered text (see `review-rendered-html`)

0 commit comments

Comments
 (0)