skills: move translation skills to ./skills/, symlink from ~/.hermes/skills/

pptx-translate, chinese-text-normalize, dharma-translation: canonical
location now ./skills/ with symlinks in ~/.hermes/skills/.

translation-review: merged CSV/XLSX review + .dj comparison workflows
into single SKILL.md. Added buddhist-terminology.md and
terms-db-alignment.md references from Hermes version.
This commit is contained in:
iacore
2026-06-09 19:46:23 +08:00
parent 10c449f4d9
commit 7e8ba4b291
9 changed files with 693 additions and 51 deletions
+80 -51
View File
@@ -1,93 +1,122 @@
---
name: translation-review
description: Review Chinese↔English translation pairs for quality issues — terminology errors, grammar, consistency, formatting. Works with CSV/XLSX files and writes edit suggestions in .dj format.
description: Review Chinese↔English translations for quality issues — terminology, grammar, consistency, formatting. Two workflows: CSV/XLSX batch review (write .dj suggestions) and .dj comparison line-by-line review (surgical patching).
---
# Translation Review
## When to use
Two workflows, used depending on input format.
- User has a CSV or XLSX file with `Chinese`/`English` (or similar) columns
- User asks you to "find problems," "check translations," or "review localization"
- User mentions `.dj` edit-suggestions files
## Workflow A: CSV/XLSX batch review
## Workflow
Use when input is a CSV/XLSX with `Chinese`/`English` columns. Produces an `edit-suggestions.dj` file.
### 1. Get the data into CSV
If the file is XLSX, have the user export to CSV (or use `openpyxl` if installed). CSV is easier and faster to process. The user may also provide XHTML — CSV is preferred.
If XLSX, export to CSV (or use `openpyxl`). CSV is faster.
### 2. Read the full file
Use `read_file` with offsets to get the complete CSV into context. Don't sample — issues repeat across rows and you need full coverage.
Use `read_file` with offsets for complete coverage. Don't sample.
### 3. Write a systematic analysis script
Write a Python script to `/tmp/` and run it with `terminal: python3 /tmp/script.py`. Do NOT use heredocs (`<<'PYEOF'`) or `-c` — the terminal tool may block these. Always write to a temp file.
Write to `/tmp/script.py`, run with `python3 /tmp/script.py`. No heredocs or `-c`.
The script should:
- Parse the CSV with `csv.DictReader`
- Apply detection rules (regex-based) for each known issue category
- Collect issues with: CSV row number, page context, CN text, EN text, problem description, suggested fix
- Group/deduplicate identical issues across rows
- Parse CSV with `csv.DictReader`
- Apply detection rules per category
- Collect issues: row number, CN text, EN text, problem, suggested fix
- Group/deduplicate identical issues
Common detection categories for Chinese→English:
- **Buddhist terminology**: 正念→mindfulness (not "righteous thoughts"), 布施→generosity (not "alms"), 胜解→resolute conviction, etc.
- **Identity terms**: 学士/修士/胜士/智士 are practice stages, not "bachelor/monk/winner/wise man"
- **Literal machine translations**: "Is we"→"if we", "hard drive" for 硬盘 (endurance), "Walk without letting go" for 行舍不放逸
- **四摄法 terms**: 同事→"acting in harmony" (not "colleagues"), 爱语→"kind speech" (not "love words")
- **Grammar**: subject-verb agreement, "have it been"→"has it been", unbalanced quotes
- **Typos/formatting**: "AndroidAndroid", "IOS"→"iOS", unbalanced HTML tags, Chinese punctuation in English
- **UI terminology**: "Suspended"→"Paused" for media, product name consistency
- **Inconsistency**: same CN term translated differently across rows (e.g., "Bodhi Navigator" vs "Bodhi Navigation")
Common detection categories:
- **Buddhist terminology**: 正念→mindfulness (not "righteous thoughts"), 布施→generosity (not "alms")
- **Identity terms**: 学士/修士/胜士/智士 are practice stages, not titles
- **Literal machine translations**: "hard drive" for 硬盘 (endurance)
- **四摄法 terms**: 同事→"acting in harmony", 爱语→"kind speech"
- **Grammar**: subject-verb agreement, unbalanced quotes
- **Typos/formatting**: Chinese punctuation in English, "IOS"→"iOS"
- **Inconsistency**: same CN term translated differently across rows
### 4. Deduplicate into unique issue categories
The same error pattern often repeats across many rows (e.g., "subversion" for 覆 appears in 6+ rows). Group these into single entries in the .dj file — one entry per unique problem, with a list of affected rows.
### 5. Write edit-suggestions.dj
### 4. Write edit-suggestions.dj
Format:
```
# 1
original: <Chinese text or key term>
translated: <current English>
<Explanation of the problem and suggested fix.>
<Explanation and suggested fix.>
# 2
...
```
Each entry gets a `# N` header, `original:` and `translated:` fields, then a free-text explanation. End with suggested replacement text. Mention affected row numbers. For globally-wrong terms, note "Change globally."
One entry per problem category, not per row. Mention affected row numbers.
Do NOT write one entry per CSV row — group by problem type.
## Workflow B: .dj comparison file review
### 6. Sanity check
Use when input is a `.dj` comparison file (Chinese/English alternating line pairs). Produces `translation-findings.dj` and applies patches.
Run a quick second pass to catch: empty English fields, Chinese characters leaking into English column, untranslated rows (CN == EN), trailing whitespace.
### 1. Read the full file
Use `terminal: cat``read_file` deduplicates within a session.
### 2. Scan for problems (ordered by severity)
**Terms database drift** (systematic):
- Cross-reference glossary terms against the MPI terms database
- HTTP API: `http://localhost:8910/search?q=...` (start: `python3 /home/user/documents/mpi/terms-search/server.py &`)
- Prefer DoT定稿 > 内部特色词 > 佛教术语 > 经论名
- Fix both glossary comments AND body text
- See `references/terms-db-alignment.md` for batch-lookup patterns
**Real errors** (affect meaning):
- Mistranslation of key terms
- Garbled/malformed source text
- Wrong proper names or technical terms
**Inconsistency** (confusing but not wrong):
- Terminology drift across file
- Numbering style chaos
- Grammatical voice/person shifts
**Cleanup needed**:
- Processing artifacts (HTML comments, markers)
- Stray spacing in Chinese text
- Awkward line splits
- Odd word choices
**Missing content**: bare headings with no body — flag, don't invent.
### 3. Dump findings to `translation-findings.dj`
```
Finding N — Title (line numbers)
Chinese: ...
English: ...
Issue: description
```
### 4. Apply fixes with `patch`
Surgical string replacement. Verify every patch with `cat` — never rely on `read_file` (session dedup).
## Buddhist terminology reference
See `references/buddhist-terminology.md` for Chinese-English term mappings and common pitfalls.
## Pitfalls
- **Don't use heredocs or `-c` for multi-line Python** — write to `/tmp/script.py` first, then `python3 /tmp/script.py`. The terminal tool may block heredocs as long-lived processes.
- **Deduplicate aggressively** — 80+ raw issues may collapse to 20-25 unique categories. Writing one .dj entry per CSV row is useless noise.
- **Buddhist terminology is technical** — don't guess. 正念 is mindfulness (sati), not "righteous thoughts." 唯识 is Yogācāra/Consciousness-Only, not "knowledge and view alone." When uncertain, flag for human review rather than confidently suggesting wrong fixes.
- **Don't delete the comparison/对照 file** — translation projects keep these as intentional work artifacts.
- **Don't use heredocs or `-c`** — write to `/tmp/script.py` first
- **Deduplicate aggressively** — group by problem type, not per-row
- **Buddhist terminology is technical** — don't guess. When uncertain, flag for review
- **Never delete .dj comparison files** — intentional work artifacts
- **Verify patches with `cat`** — `read_file` dedup makes it unreliable
- **Re-read before fixing** — user may have made interim edits
## .dj file format reference
## References
```
# N
original: <source text>
translated: <current translation>
<Free-text explanation and suggestion. Can be multiple paragraphs.>
# N+1
...
```
Entries may end with `{% TK %}` to mark "to check" items. The file lives alongside the source CSV/XLSX in the same directory.
- `references/buddhist-terminology.md` — Chinese-English Buddhist term mappings and pitfalls
- `references/terms-db-alignment.md` — Batch-aligning glossary terms against the MPI terms database
@@ -0,0 +1,47 @@
# Buddhist Text Translation — Terminology
Terms encountered in Chinese-English translation of Dharma study materials. These may vary by translator/context; document actual usage per-project.
## Section headers (common triad)
| Chinese | English options seen | Notes |
|---------|---------------------|-------|
| 法义 | Understanding, Dharma Teachings | |
| 思考 | Contemplation, Reflection | Consistency within a document matters more than which word |
| 练习 | Practice, Application, Exercises | "Application" seen as section header; "Practice"/"Exercise" in running text |
## Key Buddhist terms
| Chinese | English | Pitfalls |
|---------|---------|----------|
| 慈经 | Metta Sutta (Karaniya Metta Sutta) | NOT "Mettavihari Sutta" |
| 回向 | Dedication (of merit) | |
| 因缘之网 | Web of Causes and Conditions | Also "Network of Causes and Conditions" |
| 感恩 | Gratitude | |
| 众生 | sentient beings | Consistent throughout |
| 使人内心调柔 | makes one's heart gentle | 使人 = makes ONE(self), never "makes others" |
| 利益思维 | benefit-oriented thinking | NOT "mindset of benefiting others" — it's about considering benefits TO oneself |
| 恩田 | field of gratitude / gratitude as a field of merit | |
| 观照 | attend to the mind / mindful observation | Contemplative practice, not intellectual study. NOT "observe" (passive) or "study" (analytical). |
| 闻思修 | hearing, contemplating, cultivating | 修 = broad cultivation/practice, not specifically 禅 (meditation). Distinct from 禅修 (meditative cultivation). |
| 八步三禅 | Eight Steps and Three Meditations | Community-specific structured contemplative method |
| 传帮带 | transmit, help, guide (three-part mentoring) | Core community methodology |
| 分灯 | lamp-dividing (decentralization) | Deliberate decentralization of authority across nodes |
| 自觉 | self-awareness, voluntary commitment | First of the "Three Spirits" |
| 法治 | rule-based governance | Second of the "Three Spirits" |
| 无我利他 | selfless service to others | Third of the "Three Spirits" |
| 凡夫心 | ordinary mind | Mind governed by afflictions, contrasted with awakened mind |
| 贪嗔痴 | greed, anger, ignorance (三毒) | The three root poisons: rāga, dveṣa, moha |
| 愿心 | mind of vows, bodhicitta aspiration | Plural "vows" in English |
| 重要感、优越感、主宰欲 | sense of importance, superiority, desire to control | Three ego-driven motivations |
## Structural patterns
- Section numbering: Chinese uses 一、二、三... English should pick one style (Part One/Two, First/Second, I/II) and stick with it.
- Poetry/prayer blocks: Chinese uses parallel structures (感恩... 感恩...; 愿... 愿...). English must match the parallelism.
- 愿 (yuàn) at sentence start = optative "May..." — not "we hope that", not "we should".
## Formatting artifacts
- Stray spaces between Chinese characters (eg. `感 恩 研 究`) are justified-text paste artifacts from the source document — remove them.
- `<!-- === Progress : Below are unprocessed === -->` is a processing marker — remove from final file.
@@ -0,0 +1,61 @@
# Terms Database Alignment
Batch-align translation glossary entries and body text against the MPI terms database.
## Setup
Start the HTTP API server if not running:
```
python3 /home/user/documents/mpi/terms-search/server.py &
```
Server listens on port 8910.
## Batch lookup pattern
Use Python via execute_code to query the API for multiple terms:
```python
import urllib.request, json, urllib.parse
terms = ["三无漏学", "八步三禅", "闻思修", ...]
for term in terms:
q = urllib.parse.quote(term)
resp = urllib.request.urlopen(f"http://localhost:8910/search?q={q}&limit=5", timeout=10)
data = json.loads(resp.read())
# Filter to authoritative sources
author_sources = ["DoT定稿", "内部特色词", "佛教术语", "经论名"]
relevant = [r for r in data["results"] if r["source"] in author_sources]
# Compare against current translation, report mismatches
```
Or with curl:
```
curl -s "http://localhost:8910/search?q=三级修学&limit=5" | python3 -c "import sys,json; ..."
```
## Priority ranking
When the same term has entries in multiple source tables, prefer:
1. DoT定稿 (highest authority — final translation decisions)
2. 内部特色词 (MPI internal terminology)
3. 佛教术语 (general Buddhist terminology)
4. 经论名 (sutra/shastra titles)
## Alignment workflow
1. Extract all Chinese glossary terms from `{% "TERM" ... %}` blocks in the .dj file
2. Extract body-text domain terms that may not have glossary entries
3. Batch-query each term against the HTTP API
4. Filter results to authoritative source tables
5. Compare DB canonical translation against current file translation
6. Flag mismatches where DB entry differs materially from current
7. Apply fixes with `patch` tool — fix both glossary comments AND body text occurrences
8. Verify with `grep` that no old terms remain
## Pitfalls
- `replace_all` can create doubled words when the surrounding context already contains the replacement string (e.g., "The Eight Steps" → "The The Eight Steps"). Prefer targeted single-replacement patches.
- The `search.py` CLI does not support `src:` or `loc:` filters — use the HTTP API.
- Start patches from the bottom of the file upward to preserve line numbers.
- Some DB entries are contextual phrases (e.g., "珍惜法缘" → a full sentence), not standalone term translations. Use standalone term entries where available.