Fill missing i18n translations in the viewer HTML. Run this after adding or modifying English or Chinese UI strings in the I18N object inside claude_tap/viewer.html — it auto-translates to ja, ko, fr, ar, de, ru via OpenRouter.
Automatically fill missing translations for the viewer's I18N object. The script uses English and Chinese as source languages and translates to Japanese, Korean, French, Arabic, German, and Russian.
OPENROUTER_API_KEY must be set in the environment (it is in the user's .zshrc)google/gemini-2.5-flashAlways preview first to confirm which keys need translation:
uv run python scripts/translate_i18n.py --dry-run
This parses the I18N object in claude_tap/viewer.html, finds keys present in both en and zh-CN but missing in other languages, and lists them without modifying the file.
uv run python scripts/translate_i18n.py
The script calls OpenRouter once per target language, then writes the translations back into viewer.html in-place — preserving the existing code style (indentation, line endings, packed vs expanded format).
After translation, run the formatter and tests to make sure nothing broke:
uv run ruff format claude_tap/viewer.html
uv run pytest tests/test_translate_i18n.py -v
| Flag | Purpose |
|---|---|
--dry-run | Show missing keys only, no file changes |
--model MODEL | Override the OpenRouter model (default: google/gemini-2.5-flash) |
--target {viewer,cli} | Translation target preset (default: viewer) |
--file PATH | Override target file path |
--object-name NAME | Override the JS/Python i18n object name |
The script:
I18N JavaScript object from the HTML file using regexen + zh-CN but missing in target languagesAdded a new UI string: Add the key to both en and zh-CN blocks in the I18N object, then run this skill. The other 6 languages will be filled automatically.
Changed an existing string: The script only fills missing keys. To re-translate an existing key, first delete it from the target language blocks, then run the script.