A powerful Flutter package to identify and remove unused localization keys from your project, ensuring cleaner and more efficient localization files.
✅ Scans your localization files and detects unused keys.
✅ Provides an interactive option to remove them automatically.
✅ Supports multiple language files.
✅ Keeps your project lightweight and optimized.
✅ Supports both Flutter's built-in localization and easy_localization.
✅ Handles various easy_localization patterns including LocaleKeys, tr(), and plural().
Add the package to dev_dependencies in pubspec.yaml:
dev_dependencies:
remove_unused_localizations_keys: latestThen, fetch dependencies:
flutter pub getRun the following command to analyze your project:
dart run remove_unused_localizations_keysRun with the --easy-loc flag:
dart run remove_unused_localizations_keys --easy-locYou can also specify a custom path for your translation files:
dart run remove_unused_localizations_keys --easy-loc path=assets/i18n| Option | Description |
|---|---|
--keep-unused |
Simulates the process without deleting any keys. |
--easy-loc |
Enables easy_localization mode. |
path= |
Specifies custom path for translation files (works with --easy-loc). |
-- |
Runs without requiring user confirmation. |
Examples:
# Keep unused keys in easy_localization mode
dart run remove_unused_localizations_keys --easy-loc --keep-unused
# Use custom path for translations
dart run remove_unused_localizations_keys --easy-loc path=assets/i18n🔍 Scanning localization files...
✅ Unused keys found:
- home.welcome_message
- settings.dark_mode
❓ Do you want to remove these keys? (y/N)
We tested against three real-world Flutter projects with known unused keys:
| Project | Total Keys | Known Unused | Language Files |
|---|---|---|---|
| 🛒 E-commerce | 1,242 | 87 | 4 (en, ar, fr, de) |
| 📱 Social App | 3,587 | 214 | 6 (en, es, pt, ru, ja, zh) |
| 🏢 Enterprise | 8,921 | 532 | 12 (multi-region) |
🚀 Upcoming Features:
- Seamless CI/CD integration
- Auto-fix feature to replace similar keys
- Support for more localization packages
Thanks goes to these wonderful people 💖
📩 Need help? Reach out at [AbdelrahmanTolba@protonmail.com] or open an issue on GitHub.
📄 This project is licensed under the MIT License.