Skip to content

feat(zh): Add complete Simplified Chinese translation (20 chapters, 104 sections) #48

feat(zh): Add complete Simplified Chinese translation (20 chapters, 104 sections)

feat(zh): Add complete Simplified Chinese translation (20 chapters, 104 sections) #48

Workflow file for this run

name: Translation QA
on:
pull_request:
paths:
- 'chapter */**'
- 'zh/第*/**'
- 'zh/GLOSSARY.md'
- 'zh/TRANSLATION_GUIDE.md'
- 'scripts/verify_translation.py'
- 'scripts/translation_rules.py'
- '.github/workflows/translation-qa.yml'
push:
branches: [main]
paths:
- 'chapter */**'
- 'zh/第*/**'
- 'zh/GLOSSARY.md'
- 'zh/TRANSLATION_GUIDE.md'
- 'scripts/verify_translation.py'
- 'scripts/translation_rules.py'
workflow_dispatch:
jobs:
qa:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Run translation QA — all 25 chapters
run: |
mkdir -p /tmp/translation-qa
PYTHONPATH="scripts:$PYTHONPATH" python3 scripts/verify_all_chapters.py --report-dir /tmp/translation-qa
- name: Glossary consistency audit
run: |
PYTHONPATH="scripts:$PYTHONPATH" python3 -c "
from pathlib import Path
from translation_rules import load_glossary, check_glossary_consistency
gl = load_glossary(Path('zh/GLOSSARY.md'))
import os, json
findings = []
for root, dirs, files in os.walk('zh/'):
dirs[:] = [d for d in dirs if d not in ('教辅', 'images', 'pdf', 'svgs')]
for fn in files:
if fn.endswith('.md'):
fp = os.path.join(root, fn)
text = Path(fp).read_text(encoding='utf-8')
f = check_glossary_consistency(text, gl)
for fi in f:
fi['file'] = fp
findings.extend(f)
report = {
'total_files_scanned': len(findings),
'findings': [
{'file': f['file'], 'en_term': f['en_term'],
'variants': f['variants_found'], 'preferred': f['preferred'],
'message': f['message']}
for f in findings
]
}
with open('/tmp/translation-qa/glossary.json', 'w') as out:
json.dump(report, out, ensure_ascii=False, indent=2)
if findings:
print(f'Glossary audit: {len(findings)} inconsistency findings')
for f in findings[:10]:
print(f' {f[\"file\"]}: {f[\"message\"]}')
else:
print('Glossary audit: clean')
"
- uses: actions/upload-artifact@v4
with:
name: translation-qa-report
path: /tmp/translation-qa