flutter_hardcode_localizer 1.0.1
flutter_hardcode_localizer: ^1.0.1 copied to clipboard
A Dart plugin that finds hardcoded strings in Flutter projects and provides quick-fix to move them to localization files for easy_localization.
Changelog #
1.0.1 - 2025-08-14 #
🚀 Enhanced for easy_localization Integration #
New Features
- ✅ LocaleKeys.key.tr() Format: Changed replacement format from
Locale.$keytoLocaleKeys.$key.tr() - ✅ easy_localization Workflow: Perfect integration with the popular easy_localization package
- ✅ Automated JSON Key-Value Creation: Eliminates manual process of adding translations
- ✅ Standard Directory Structure: Uses
assets/languages/following easy_localization conventions - ✅ Enhanced Documentation: Added specific command for LocaleKeys generation with correct parameters
Technical Changes
- JsonManager: Updated to use
assets/languages/en.jsoninstead oflang/en.json - Path Standardization: Follows easy_localization standard directory structure
- pubspec.yaml Integration: Clear instructions for adding assets directory
Enhanced Command Reference
The README now includes the specific command for generating LocaleKeys:
dart run easy_localization:generate --source-dir assets/languages/ -f keys -O lib/ui/theme -o codegen_key.g.dart
Important Setup Note
Added crucial pubspec.yaml configuration requirement:
flutter:
assets:
- assets/languages/
Why This Update?
This version specifically addresses the tedious manual process of setting up easy_localization:
Before v1.0.1 (Manual Process):
- ❌ Manually find all hardcoded strings
- ❌ Manually add each to assets/languages/en.json
- ❌ Manually replace each in code with LocaleKeys.key.tr()
- ❌ Manually run code generation with correct parameters
- ❌ Manually configure pubspec.yaml
After v1.0.1 (Automated):
- ✅ Add
assets/languages/to pubspec.yaml - ✅ Run:
dart run flutter_hardcode_localizer:localize - ✅ Run:
dart run easy_localization:generate --source-dir assets/languages/ -f keys -O lib/ui/theme -o codegen_key.g.dart - ✅ Add import and test!