Documentation/translate-xcstrings.md
Scripts/translate-xcstrings.mjs uses Xcode's native localization export/import flow, then fills unfinished xcstrings entries with an LLM through OpenRouter.
What it does:
.xcloc / .xliff bundles with xcodebuild -exportLocalizations.xcstrings translation units inside the exported XLIFFtranslatedxcodebuild -importLocalizations -mergeImportnpm install
export OPENROUTER_API_KEY="your-api-key"
Optional:
export OPENROUTER_MODEL="openai/gpt-4.1-mini"
export OPENROUTER_SITE_URL="https://github.com/linearmouse/linearmouse"
export OPENROUTER_APP_NAME="LinearMouse xcstrings translator"
Dry run first:
npm run translate:xcstrings -- --dry-run
Translate everything unfinished:
npm run translate:xcstrings
Translate only selected languages:
npm run translate:xcstrings -- --languages ja,zh-Hans,zh-Hant
Use a different model or smaller batches:
npm run translate:xcstrings -- --model openai/gpt-4.1 --batch-size 5
Limit a test run to a few translation units:
npm run translate:xcstrings -- --max-units 20
Keep the exported localization bundle for inspection:
npm run translate:xcstrings -- --languages ja --keep-export
original file ends with .xcstrings; other exported resources are left untouched.trans-unit items, so the model works on those units directly.