Professional localization analyzer for Swift/iOS projects with auto-translation
Project description
Localization Analyzer
๐ Professional localization analysis and management tool for multi-platform projects.
Why localization-analyzer?
Unlike other tools that only handle one aspect of localization, this is an all-in-one CLI that covers the entire localization workflow:
| Feature | localization-analyzer | BartyCrouch | translate-toolkit |
|---|---|---|---|
| Analyze hardcoded strings | โ | โ | โ |
| Auto-translate | โ | โ | โ |
| Modular .strings support | โ | โ | โ |
| Health scoring | โ | โ | โ |
| Dynamic key detection | โ | โ | โ |
| Stats & reporting | โ | โ | โ |
| Diff between languages | โ | โ | โ |
| Validation | โ | โ | โ |
| Sync languages | โ | โ | โ |
| Interactive HTML dashboard | โ | โ | โ |
| Built-in report server | โ | โ | โ |
Features
Analysis & Detection
- ๐ Smart Detection: Find hardcoded strings automatically
- ๐ฏ Dynamic Key Detection: Skip false positives like
activity.\(id) - ๐ Health Score: Track localization quality (0-100)
- ๐ Key Management: Detect missing and dead keys
Translation & Management
- ๐ Auto-Translate: Google Translate integration (free, no API key)
- ๐ฆ Modular Support: Handle AI.strings, Common.strings, etc.
- โ Add Languages: Create new language with auto-translation
- ๐ Sync: Keep all languages in sync
Validation & Reporting
- โ Validate: Check syntax, placeholders, duplicates
- ๐ Stats: Completion percentages per language
- ๐ Diff: Compare two languages
- ๐ Reports: JSON, Markdown, Console, Interactive HTML Dashboard
- ๐ Live Preview: Built-in server to view reports in browser
Developer Experience
- โก Fast: Multi-threaded analysis
- ๐พ Cache: Translation caching for speed
- ๐ง Auto-Fix: Automatically fix hardcoded strings
- ๐ CI/CD Ready: Exit codes for pipeline integration
Installation
From PyPI (recommended)
pip install localization-analyzer
From Source
git clone https://github.com/sezginpak/localization-analyzer.git
cd localization-analyzer
pip install -e .
Quick Start
1. Initialize Configuration
cd your-project
localization-analyzer init --framework swift
This creates .localization.yml in your project root.
2. Run Analysis
localization-analyzer analyze --verbose
3. View Interactive HTML Report
# Generate HTML report and open in browser
localization-analyzer analyze --serve
# Enable edit mode (inline editing + batch editing)
localization-analyzer analyze --serve --edit
# Or just generate HTML file
localization-analyzer analyze --html report.html
Edit Mode Features:
- ๐๏ธ Inline Edit: Double-click any text to edit and save directly
- โ๏ธ Selection: Check items to select for batch operations
- ๐ Batch Edit: Edit multiple translations at once in a modal
- ๐พ Auto-Save: Changes are saved directly to .strings files
4. Check Statistics
# View completion stats for all languages
localization-analyzer stats
# Show missing keys per language
localization-analyzer stats --missing
# Export as JSON for CI/CD
localization-analyzer stats --json
5. Add New Language with Translation
# Add Spanish with auto-translation from English
localization-analyzer lang --add es --translate
# Preview first (dry-run)
localization-analyzer lang --add es --translate --dry-run
6. Translate Missing Keys
# Translate missing keys from English to German
localization-analyzer translate --source en --target de
# Force re-translate all keys
localization-analyzer translate --source en --target de --force
7. Sync Languages
# Sync all languages with English (source)
localization-analyzer sync --translate
# Sync specific language
localization-analyzer sync --lang de --translate
8. Compare Languages
# Diff between English and Spanish
localization-analyzer diff --source en --target es
# Fail if missing keys (for CI)
localization-analyzer diff --source en --target es --fail-on-missing
9. Validate Files
# Full validation
localization-analyzer validate --consistency
# Check specific aspects
localization-analyzer validate --syntax
localization-analyzer validate --placeholders
Commands Reference
| Command | Description |
|---|---|
init |
Initialize configuration file |
analyze |
Run comprehensive analysis |
stats |
Show localization statistics |
translate |
Auto-translate keys |
lang |
Manage languages (add/remove/list/sync) |
sync |
Synchronize all languages |
diff |
Compare two languages |
validate |
Validate localization files |
missing |
Find and fix missing keys |
fix |
Auto-fix hardcoded strings |
generate |
Generate L10n enum |
discover |
Auto-discover tables/modules |
Configuration
Create .localization.yml in your project root:
project:
name: MyApp
framework: swift
paths:
source: .
localization: ./Resources
exclude:
- build/
- Pods/
- .build/
languages:
primary: en
supported:
- en
- es
- de
- tr
- pt
# Optional: Module mapping
tables:
AI: AI
Common: Common
Garden: Garden
auto_fix:
enabled: true
min_priority: 8
backup: true
reports:
formats:
- json
- console
- html # Interactive HTML dashboard
output: ./localization_reports/
CI/CD Integration
GitHub Actions
name: Localization Check
on: [push, pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install localization-analyzer
run: pip install localization-analyzer
- name: Check localization health
run: localization-analyzer analyze --fail-below 90
- name: Validate syntax
run: localization-analyzer validate --syntax
- name: Check missing translations
run: localization-analyzer stats --ci --threshold 95
GitLab CI
localization:
image: python:3.11
script:
- pip install localization-analyzer
- localization-analyzer analyze --fail-below 90
- localization-analyzer validate --consistency
Python API
from localization_analyzer import LocalizationAnalyzer
from localization_analyzer.frameworks import SwiftAdapter
from localization_analyzer.core.file_manager import LocalizationFileManager
from pathlib import Path
# Create analyzer
adapter = SwiftAdapter()
analyzer = LocalizationAnalyzer(
project_dir=Path('.'),
adapter=adapter
)
# Run analysis
result = analyzer.analyze()
# Check results
print(f"Health Score: {result.health.score}/100")
print(f"Localization Rate: {result.health.localization_rate}%")
print(f"Hardcoded Strings: {len(result.hardcoded_strings)}")
# File manager for direct key management
file_manager = LocalizationFileManager(adapter, Path('./Resources'))
file_manager.load_all_keys()
# Add a key to specific module
file_manager.add_key(
key="new.feature.title",
translations={"en": "New Feature", "es": "Nueva Funciรณn"},
module="Common"
)
Supported Frameworks
| Framework | Status | File Format |
|---|---|---|
| Swift/iOS | โ Full Support | .strings (modular) |
| React | ๐ง Coming Soon | .json |
| Flutter | ๐ง Coming Soon | .arb |
| Android | ๐ง Coming Soon | .xml |
Key Features Explained
Health Score (0-100)
Calculated based on:
- Localization Rate: % of localized vs hardcoded strings
- Missing Keys: Keys used in code but not in files
- Dead Keys: Keys in files but not used in code
- Consistency: Same keys across all languages
Dynamic Key Detection
Smart detection skips false positives:
// These won't be flagged as missing:
"activity.\(id)".localized // Dynamic key
"style.\(rawValue)".localized // Dynamic key
Modular .strings Support
Works with modern Swift projects:
Resources/
โโโ en.lproj/
โ โโโ AI.strings
โ โโโ Common.strings
โ โโโ Garden.strings
โ โโโ Settings.strings
โโโ es.lproj/
โโโ AI.strings
โโโ Common.strings
โโโ ...
Translation Caching
Translations are cached to avoid re-translating:
.localization_cache/
โโโ translations.json
Development
Setup Development Environment
git clone https://github.com/sezginpak/localization-analyzer.git
cd localization-analyzer
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
Project Structure
localization-analyzer/
โโโ localization_analyzer/
โ โโโ core/ # Analysis engine
โ โ โโโ analyzer.py # Main analyzer
โ โ โโโ file_manager.py # File I/O
โ โโโ frameworks/ # Framework adapters
โ โ โโโ swift.py # Swift/iOS adapter
โ โโโ features/ # Feature modules
โ โ โโโ translator.py # Auto-translation
โ โ โโโ validator.py # Validation
โ โ โโโ stats.py # Statistics
โ โ โโโ diff.py # Language diff
โ โ โโโ sync.py # Sync languages
โ โโโ reports/ # Report generators
โ โโโ utils/ # Utilities
โโโ tests/ # Test suite (40+ tests)
โโโ examples/ # Example projects
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT License - see LICENSE file for details.
Author
Sezgin Paksoy
- GitHub: @sezginpak
Support
- ๐ Issues: GitHub Issues
- ๐ Docs: Documentation
Made with โค๏ธ for the iOS/Swift developer community
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 localization_analyzer-1.14.0.tar.gz.
File metadata
- Download URL: localization_analyzer-1.14.0.tar.gz
- Upload date:
- Size: 126.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cce77ee5d236971aa7a119b302185d2174c1b71814707d477fb3f5d99a1370aa
|
|
| MD5 |
9f050b707db022fcdf6538d3211745d0
|
|
| BLAKE2b-256 |
2fe086016e41ce61b583225368a550f3335b879d44de3f9fef232ada9e14360c
|
File details
Details for the file localization_analyzer-1.14.0-py3-none-any.whl.
File metadata
- Download URL: localization_analyzer-1.14.0-py3-none-any.whl
- Upload date:
- Size: 106.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4dee59d641b3ac61ec61e1006e12c2d5d6c344e4d414a8f94e13fd3dc6d7a3cf
|
|
| MD5 |
abe16d4178c657212c51bd5a377edf8c
|
|
| BLAKE2b-256 |
5ee95d9b62f958cdfcaa2eb65e2b32de406121e4736685ce8d244e1d7155463d
|