flutter_i18n_translator 0.1.0
flutter_i18n_translator: ^0.1.0 copied to clipboard
A CLI tool to translate JSON localization files.
markdown
flutter_i18n_translator #
A CLI tool to automatically translate missing keys in JSON localization files for Flutter/Dart projects.
It uses translator under the hood (Google Translate API).
✨ Features #
- Detects missing keys in your i18n JSON files.
- Translates missing entries using Google Translate.
- Supports batching with character limits.
- Placeholders (
{digit}
,{name}
, etc.) are preserved during translation. - Configurable via
i18nconfig.json
. - CLI flags to enable automation & debug logging.
📦 Installation #
Activate globally from pub.dev:
dart pub global activate flutter_i18n_translator
Or use locally in a project:
dev_dependencies:
flutter_i18n_translator: ^0.1.0
Run from project root:
dart run flutter_i18n_translator
⚙️ Configuration #
Create an i18nconfig.json
in your project root:
{
"defaultLocale": "en-US",
"locales": [
"en-US",
"fr-FR",
"ar-EG"
],
"localePath": "i18n"
}
defaultLocale
: The base locale with full translations.locales
: List of all locales you support.localePath
: Directory where JSON files are stored.
Example structure:
project_root/
i18n/
en-US.json
fr-FR.json
ar-EG.json
i18nconfig.json
🚀 Usage #
Run the tool from your project root:
flutter_i18n_translator
CLI Options #
--batch-limit <number> Set max characters per translation batch (default: 3000)
--auto-translate Automatically send translations without confirmation
--auto_apply-translations Apply translations without user prompt
--show-debug Enable debug messages
--no-debug Disable debug messages
--help, -h Show this help message
Examples #
Translate with default options:
flutter_i18n_translator
Set a smaller batch limit:
flutter_i18n_translator --batch-limit 1000
Translate & apply automatically:
flutter_i18n_translator --auto-translate --auto_apply-translations
Run silently without debug logs:
flutter_i18n_translator --no-debug
🛠 Development #
Clone the repo:
git clone https://github.com/MazenxELGayar/flutter_i18n_translator.git
cd flutter_i18n_translator
Run locally:
dart run bin/flutter_flutter_i18n_translator.dart --help
📄 License #
MIT License © 2025 Mazen El-Gayar