Automates Xcode .xcloc localization using reproducible, CI-friendly machine translation—built for real iOS teams.
Xcode exports .xcloc, but Apple provides no bulk translation workflow. This tool fills that gap.
If you've ever manually translated hundreds of localization strings, or copy-pasted between Xcode and Google Translate, you know the pain. This tool automates the entire workflow while maintaining safety and reproducibility.
1. Export .xcloc from Xcode
2. Open each language's XLIFF file
3. Copy string → Google Translate → Paste
4. Repeat 500 times
5. Hope you didn't break any %@ placeholders
6. Import back into Xcode
7. Build fails because placeholders got mangled
auto-translate-xcloc --workspace ./localizationThat's it. All languages translated. Placeholders preserved. XLIFF structure validated. Ready for Xcode import.
- 🎯 Zero Configuration — Automatically detects languages and structure
- 🛡️ Strict Placeholder Preservation — Validates
%@,%d,{0}, etc. are preserved exactly - 🌐 100+ Languages — Supports all major languages via Google Translate
- ⚡ CI-Friendly —
--dry-run,--only-missing,--fail-on-placeholder-mismatchmodes - 🔍 Smart Translation — Skips units (kg, ml), preserves formatting, handles special characters
- 💾 Safe by Default — Validates XLIFF structure, auto-restores on corruption
- 📦 Proper Package — Install via pip, use as CLI or Python library
- 🎯 Xcode Compatible — Works with iOS, macOS, watchOS, tvOS projects
pip install auto-translate-localizablesgit clone https://github.com/EhsanAzish80/Auto-Translate-localizables
cd Auto-Translate-localizables
pip install -e .auto-translate-xcloc --version# Translate all languages
auto-translate-xcloc --workspace /path/to/localization
# Dry run (see what would happen)
auto-translate-xcloc --workspace ./localization --dry-run
# Only translate missing strings (preserve existing)
auto-translate-xcloc --workspace ./localization --only-missing# Translate specific languages only
auto-translate-xcloc --workspace ./localization --only de fr es
# Skip certain languages
auto-translate-xcloc --workspace ./localization --skip en ar
# CI mode: fail on placeholder mismatches
auto-translate-xcloc --workspace ./localization --fail-on-placeholder-mismatch
# List all supported languages
auto-translate-xcloc --list-languagesworkspace/
├── en.xcloc/
│ └── Localized Contents/
│ └── en.xliff
├── de.xcloc/
│ └── Localized Contents/
│ └── de.xliff
├── fr.xcloc/
│ └── Localized Contents/
│ └── fr.xliff
└── es.xcloc/
└── Localized Contents/
└── es.xliff
This is the standard structure Xcode creates when you export localizations.
from auto_translate_localizables import XLIFFTranslator
# Create translator
translator = XLIFFTranslator(
workspace_dir="/path/to/localization",
fail_on_placeholder_mismatch=True
)
# Translate all languages
results = translator.process_all_languages(
skip_languages=['en'],
dry_run=False,
only_missing=False
)
# Process specific language
results = translator.process_language_folder('de', dry_run=False)
# Check for errors
if translator.errors:
for error in translator.errors:
print(f"Error: {error['file']}: {error['error']}")# 1. Export from Xcode
# Product → Export Localizations...
# 2. Translate
auto-translate-xcloc --workspace ./LocalizationExport
# 3. Import back to Xcode
# Product → Import Localizations...# After exporting from Xcode
git add localization/*.xcloc
auto-translate-xcloc --workspace ./localization
git diff # Review translations
git commit -m "Update translations"This repository includes ready-to-use GitHub Actions for automated translation workflows.
Automatically translates localization files when English changes or on manual trigger.
Triggers:
- ✅ When
en.xclocfiles change - ✅ Manual workflow dispatch with options
Features:
- Creates Pull Request with translated strings
- Validates placeholder preservation
- Only translates missing strings by default
- Configurable language selection
Manual Trigger Options:
Languages: Specify "de fr es" or "all"
Only missing: true/false
Create PR: true/false (direct commit option)
Validates translation quality on Pull Requests.
Runs on:
- ✅ Any PR that modifies
.xclocor.xlifffiles
Validates:
- ✅ Placeholder preservation
- ✅ XLIFF syntax correctness
The workflows are already configured in this repository. Just:
- Push to GitHub - workflows are ready to use
- Make a change to
en.xclocfiles - auto-translation triggers - Review the PR - translations are validated and ready
Go to Actions → Auto-Translate Localizations → Run workflow
🌍 Auto-translate localization files
✅ Translated 245 entries (0 errors)
✅ Placeholder validation passed
✅ XLIFF structure validated
📝 Pull Request created: #123
The tool strictly validates that placeholders are preserved:
# Original
"You have %d items in %@"
# ✅ Valid translation (German)
"Sie haben %d Artikel in %@"
# ❌ Invalid - placeholder count mismatch
"Sie haben Artikel in %@" # Missing %d
# ❌ Invalid - placeholder type changed
"Sie haben %@ Artikel in %d" # Swapped types- Validates XML structure before and after translation
- Auto-restores original file if corruption detected
- Preserves XML namespaces and attributes
- Maintains Xcode-compatible formatting
- Automatic delays between translations
- Prevents Google Translate rate limiting
- Configurable batch sizes
100+ languages supported. Run auto-translate-xcloc --list-languages for full list.
Common examples:
- 🇩🇪 German (
de) - 🇫🇷 French (
fr) - 🇪🇸 Spanish (
es,es-419,es-MX) - 🇨🇳 Chinese Simplified (
zh-Hans) - 🇹🇼 Chinese Traditional (
zh-Hant) - 🇯🇵 Japanese (
ja) - 🇰🇷 Korean (
ko) - 🇷🇺 Russian (
ru) - 🇵🇹 Portuguese (
pt,pt-BR,pt-PT) - And many more...
This tool uses Google Translate. Output quality varies by language. Always have translations reviewed by native speakers before shipping to production.
While the tool validates placeholder preservation, it cannot validate placeholder position correctness in all languages. Some languages require different word orders.
Google Translate has rate limits. For very large projects (1000+ strings), run with --only-missing on subsequent runs.
# Clone repository
git clone https://github.com/EhsanAzish80/Auto-Translate-localizables
cd Auto-Translate-localizables
# Install in editable mode with dev dependencies
pip install -e ".[dev]"
# Run tests (when available)
pytest
# Format code
black .
# Type checking
mypy auto_translate_localizablesauto-translate-localizables/
├── auto_translate_localizables/
│ ├── __init__.py # Package exports
│ ├── cli.py # CLI entry point
│ ├── translator.py # Core translation logic
│ └── language_map.py # Language code mappings
├── pyproject.toml # Modern Python packaging
├── README.md
└── LICENSE
# Export from Xcode to ~/Desktop/Localization
# Run translation
auto-translate-xcloc --workspace ~/Desktop/Localization
# Output:
# ============================================================
# XLIFF Bulk Translation
# ============================================================
# Workspace: /Users/you/Desktop/Localization
# Skipping: en
# Mode: TRANSLATION
# ============================================================
#
# ============================================================
# Processing DE -> de
# ============================================================
#
# [FILE] Localizable.xliff
# [✓] Translated 245 entries (0 errors)
#
# [✓] de -> 245 translated, 0 errors
#
# ============================================================
# TOTAL: 245 entries translated
# 0 errors
# ============================================================# You've added 20 new strings to English
auto-translate-xcloc --workspace ./localization --only-missing
# Only translates the 20 new strings, preserves existing translations# In CI pipeline
auto-translate-xcloc \
--workspace ./localization \
--dry-run \
--fail-on-placeholder-mismatch
# Exit code 0 = all good
# Exit code 1 = validation errors foundContributions welcome! This project follows standard Python best practices.
- DeepL translation provider support
- Azure Translator support
- Custom terminology/glossary support
- Translation memory (TM) integration
- Improved placeholder validation
- GUI improvements
- Test coverage
MIT License - see LICENSE file for details.
Built with:
- deep-translator - Translation API wrapper
- lxml - Robust XML processing
- Apple Xcode XLIFF format
- GitHub Issues: Report bugs or request features
- Author: Ehsan Azish
- Email: ehsanazish80@gmail.com
- GitHub Action for automated translation
- Pre-commit hook integration
- Translation quality scoring
- DeepL provider support
- OpenAI GPT translation option
- Per-language provider override
- Custom terminology support
- Translation memory (TM) support
- Terminology glossaries
- Translation review workflow
- Analytics and reporting
Star ⭐ this repo if it saved you time!