🧩 Smart Localization Manager
A powerful VS Code extension for managing Flutter/Dart localization files with automatic synchronization, missing key detection, and real-time watching capabilities.
✨ Features
- 🔄 Automatic Key Generation: Generate
locale_keys.g.dart from your translation files
- 👁️ Real-time Watching: Monitor Arabic and English translation files for changes
- 🔍 Missing Key Detection: Automatically identify untranslated keys between languages
- 📊 Visual Status: Clear status bar indicator showing watch state (🟢 Watching / 🔴 Stopped)
- 📝 Detailed Logging: Output channel for detailed operation logs
- ⚙️ Configurable Paths: Customize all file paths through VS Code settings
🚀 Getting Started
📋 Commands
Access these commands through the Command Palette (Ctrl+Shift+P or Cmd+Shift+P):
1. Localization: Generate Keys
- Executes your Dart localization script (if exists)
- Compares Arabic and English translation files
- Generates/updates
untranslated.json with missing keys
- Shows summary of synchronization status
2. Localization: Start Watching
- Begins monitoring
ar.json and en.json for changes
- Automatically regenerates keys on file changes
- Updates status bar to show 🟢 Watching Localization
- Provides real-time notifications
3. Localization: Stop Watching
- Stops file monitoring
- Updates status bar to show 🔴 Localization Stopped
Status Bar Toggle
Click the status bar item to quickly toggle watching on/off.
📄 Generated Files
untranslated.json
The extension maintains this file with missing translation keys:
{
"missing_in_en": [
"home.newFeature",
"profile.logout"
],
"missing_in_ar": [
"settings.theme",
"about.contact"
]
}
missing_in_en: Keys that exist in Arabic but not in English
missing_in_ar: Keys that exist in English but not in Arabic
When you add a translation for a missing key, it's automatically removed from this file on the next generation.
⚙️ Configuration
Customize the extension through VS Code Settings (Ctrl+, or Cmd+,):
{
"localization.autoWatch": false,
"localization.arFilePath": "assets/translations/ar.json",
"localization.enFilePath": "assets/translations/en.json",
"localization.generatedKeysPath": "lib/generated/locale_keys.g.dart",
"localization.untranslatedPath": "assets/translations/untranslated.json",
"localization.dartScriptPath": "tools/generate_localization_doc.dart"
}
Settings Explained
| Setting |
Default |
Description |
autoWatch |
false |
Automatically start watching when workspace opens |
arFilePath |
assets/translations/ar.json |
Path to Arabic translation file |
enFilePath |
assets/translations/en.json |
Path to English translation file |
generatedKeysPath |
lib/generated/locale_keys.g.dart |
Output path for generated keys |
untranslatedPath |
assets/translations/untranslated.json |
Output path for missing keys |
dartScriptPath |
tools/generate_localization_doc.dart |
Path to Dart generation script |
🎯 How It Works
Key Detection Algorithm
- Parse JSON Files: Recursively parse both translation files
- Flatten Keys: Convert nested objects to dot-notation keys (e.g.,
home.title)
- Compare Sets: Identify keys present in one language but missing in the other
- Auto-Sync: Remove keys from
untranslated.json when they're added to both files
Example
ar.json:
{
"home": {
"title": "الرئيسية",
"welcome": "مرحبا"
},
"profile": {
"settings": "الإعدادات"
}
}
en.json:
{
"home": {
"title": "Home"
},
"profile": {
"settings": "Settings",
"logout": "Logout"
}
}
Generated untranslated.json:
{
"missing_in_en": ["home.welcome"],
"missing_in_ar": ["profile.logout"]
}