intl_usage 1.2.0
A Dart package to analyze and validate internationalization (i18n) resources, ensuring consistency and completeness across different locales.
Find Unused Translations in Flutter Projects
This package is used to find unused keys inside your easy_localization files.
Managing translations in Flutter projects can become messy over time. Unused keys accumulate,
cluttering your translation files and making maintenance a headache. This package helps you
effortlessly identify and remove unused translation keys specifically in projects using
the easy_localization package, keeping your project clean and efficient.
Features
- Effortlessly identify and remove unused translation keys, reducing clutter and improving project maintainability.
- Ensure consistency across all your translation files by detecting missing keys.
Installation
Add this to your pubspec.yaml file as a dev dependency:
dev_dependencies:
intl_usage: ^1.2.0
Make sure you also have easy_localization installed in your project:
dependencies:
easy_localization: ^latest_version
flutter pub get
Usage
Find Unused Keys:
dart run intl_usage:find_usages
This command scans your project and prints a list of unused translation keys, as well as keys whose usage is uncertain (e.g., due to dynamic string concatenation).
** Find Missing Keys:**
dart run intl_usage:check_translations
This command checks your translation files for consistency and reports any keys that are missing in one or more files.
Customization Options:
--path: Specifies the path to your translation files. If not provided, the package defaults to searching inassets/translations. You can also define this path in a YAML configuration file (see below).--known_used_keys: Specifies the translations keys you are sure of being used. Either because these are used in a separate package, created dynamically or defined in a separate json file that the system loads at runtime.
Using a YAML Configuration File:
You can create a intl_usage.yaml file in the root of your project to define the translation path:
path: your/translation/path
known_used_keys:
- key1
- key2
- ...
This eliminates the need to specify the --path or the --known_used_keys option every time you
run the commands.
Limitations
Currently, this package only supports translations generated with the easy_localization
package.Support for other translation solutions may be added in future releases.
License
This project is licensed under the MIT License.