sync_translations
A simple and powerful Dart command-line tool that helps you synchronize translation files across multiple locales in your Flutter or Dart projects.
This tool ensures that all translation keys are consistent across different language files — it adds missing keys, removes unused ones, and keeps your localization organized and up to date.
🚀 Features
✅ Compare and synchronize .json, .arb, or .yaml translation files
✅ Detect missing or extra keys between locales
✅ Automatically insert missing keys with default values
✅ Supports nested translation structures
✅ Simple command-line usage
✅ Fast and safe — built with pure Dart
📦 Installation
dart pub global activate sync_translations
⚙️ Usage
Run the following command in your project root:
sync_translations
Options
| Option | Description |
|---|---|
--source |
The main translation file (e.g., English) |
--targets |
One or more translation files to sync with the source |
--dry-run |
Shows changes without writing them |
--overwrite |
Overwrites files automatically |
--indent |
Sets JSON indentation (default: 2) |
Example:
sync_translations
🧩 Example
en.json
{
"hello": "Hello",
"bye": "Goodbye"
}
ar.json (before)
{
"hello": "مرحبا"
}
After running:
sync_translations --source en.json --targets ar.json --overwrite
ar.json (after)
{
"hello": "مرحبا",
"bye": "Goodbye"
}
🧠 Why use this?
Maintaining multiple translation files by hand is error-prone.
sync_translations keeps them clean, synchronized, and complete — saving hours of manual editing.
🧰 Contributing
Contributions are welcome!
If you’d like to improve the tool or add a new feature:
- Fork the repo
- Create a feature branch (
git checkout -b feature/awesome-improvement) - Commit your changes
- Open a Pull Request 🚀
🪪 License
This project is licensed under the MIT License.
Links
- Repository: GitHub
- Issues: Report bugs or request features
- Author: Mahmoud Othman
Libraries
- sync_translations
- utils/filters
- utils/generate_locale_keys
- utils/git_utils
- utils/humanizer
- utils/key_sanitizer
- Utility to sanitize strings into Dart-safe variable names.
- utils/processor
- utils/validate_json_files