Translate Apple Localizable.xcstrings files using Claude AI
Project description
XCStrings Translator
Translate Apple's Localizable.xcstrings files using AI. Supports Claude, GPT, and Gemini.
xcstrings translate Localizable.xcstrings -l fr,es,it,ja,ko
Features
- Multi-provider - Choose Claude, GPT, or Gemini based on cost/quality needs
- Context-aware - Uses existing translations to understand meaning and tone
- Format-safe - Preserves
%@,%lld,%1$@and other specifiers - 35+ languages - All major App Store locales
- Cost estimation - Preview costs before translating
- Validation - Detect missing translations and format mismatches
Quick Start
# Install
pip install xcstrings-translator
# Set API key (pick one)
export ANTHROPIC_API_KEY=sk-... # Claude
export OPENAI_API_KEY=sk-... # GPT
export GOOGLE_API_KEY=... # Gemini
# Translate
xcstrings translate Localizable.xcstrings -l fr,de,ja
Models
| Model | Provider | Cost/1M tokens | Best for |
|---|---|---|---|
haiku |
Anthropic | $1 in / $5 out | Fast iteration |
sonnet |
Anthropic | $3 in / $15 out | Recommended |
opus |
Anthropic | $15 in / $75 out | Highest quality |
gpt-5-nano |
OpenAI | $0.05 in / $0.40 out | Cheapest |
gpt-5-mini |
OpenAI | $0.25 in / $2 out | Budget |
gpt-5 |
OpenAI | $1.25 in / $10 out | Quality |
gemini-2.0-flash |
$0.10 in / $0.40 out | Fast & cheap | |
gemini-3-flash |
$0.50 in / $3 out | Balanced | |
gemini-3-pro |
$2 in / $12 out | Quality |
xcstrings translate input.xcstrings -l fr -m haiku # fast/cheap
xcstrings translate input.xcstrings -l fr -m sonnet # balanced (default)
xcstrings translate input.xcstrings -l fr -m gpt-5-nano # cheapest
Commands
| Command | Description |
|---|---|
translate |
Translate to specified languages |
estimate |
Preview cost without translating |
info |
Show file stats and coverage |
validate |
Check for issues |
languages |
List all 35+ supported languages |
Usage Examples
# Translate to multiple languages
xcstrings translate Localizable.xcstrings -l fr,es,it,de,ja
# Estimate cost first
xcstrings translate Localizable.xcstrings -l fr,es,it --dry-run
# Use faster model
xcstrings translate Localizable.xcstrings -l fr -m haiku
# Parallel requests (faster for large files)
xcstrings translate Localizable.xcstrings -l fr,es -c 32
# Save to different file
xcstrings translate input.xcstrings -l fr -o translated.xcstrings
# Fill missing translations only
xcstrings translate Localizable.xcstrings --fill-missing
# Check translation coverage
xcstrings info Localizable.xcstrings
# Validate format specifiers
xcstrings validate Localizable.xcstrings
App Context
Provide context for better translations. Create context.md next to your xcstrings file:
# My Fitness App
A workout tracking app for athletes.
Tone: Motivational, energetic.
Use informal "you" (du/tu).
Or pass directly:
xcstrings translate input.xcstrings -l fr --context "A fitness app with motivational tone"
Python API
from src import XCStringsFile, XCStringsTranslator
# Load
xcstrings = XCStringsFile.from_file("Localizable.xcstrings")
# Translate
translator = XCStringsTranslator(model="sonnet")
xcstrings = translator.translate_file(xcstrings, ["fr", "es", "it"])
# Save
xcstrings.to_file("Localizable.xcstrings")
# Stats
print(f"Translated: {translator.stats.translated}")
print(f"Cost: ${translator.stats.input_tokens * 3 / 1e6 + translator.stats.output_tokens * 15 / 1e6:.2f}")
Supported Languages
European: en, de, fr, es, it, pt, pt-BR, nl, pl, sv, da, nb, fi, cs, sk, hu, ro, bg, el, sq, uk, ru, tr
Asian: ja, ko, zh-Hans, zh-Hant, th, vi, id, ms, hi
Middle Eastern: ar, he
Other: ca, eu
Options
| Option | Description | Default |
|---|---|---|
-l, --languages |
Target language codes | Required |
-m, --model |
AI model | sonnet |
-o, --output |
Output file | Overwrites input |
-b, --batch-size |
Strings per API call | 25 |
-c, --concurrency |
Parallel requests | 32 |
--context |
App description | context.md |
--overwrite |
Replace existing | false |
--dry-run |
Estimate only | false |
-f, --fill-missing |
Auto-detect languages | false |
Troubleshooting
"Unsupported language" - Use Apple codes: zh-Hans not zh-CN, pt-BR not pt_BR
Format mismatch - Run xcstrings validate to find issues
API errors - Check correct key is set for your model
License
MIT
Made with ❤️ by Justin Lanfermann
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xcstrings_translator-1.0.0.tar.gz.
File metadata
- Download URL: xcstrings_translator-1.0.0.tar.gz
- Upload date:
- Size: 27.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d03a58171d767fc21ec95a3348a419e1c7277478ddf6087927974b1d86236716
|
|
| MD5 |
0683761976c4d0f26d8a3ae65765e961
|
|
| BLAKE2b-256 |
cc2bf7733196f5a29e505183a6b70de400abe42fbbfc73f3432542ea5fd380b0
|
File details
Details for the file xcstrings_translator-1.0.0-py3-none-any.whl.
File metadata
- Download URL: xcstrings_translator-1.0.0-py3-none-any.whl
- Upload date:
- Size: 29.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d45abead7350e0848ccda0754d64d7a7fdef908867e57dc2b41c873d0097703
|
|
| MD5 |
d2cfda4df7c152bffa9feec024f8b73f
|
|
| BLAKE2b-256 |
ab4e1d589b63e3355e3f8430e318348f2ed95b5e0448a33119e773d1b0f36579
|