motrgem 1.3.0
motrgem: ^1.3.0 copied to clipboard
A Flutter localization tool that automatically extracts hardcoded texts from widgets and converts them to l10n format.
1.3.0 #
- Fixed:
--replaceno longer emitsAppLocalizations.of(context)!...inside a callback/method with noBuildContextactually resolvable in scope (e.g. anfl_chart-stylegetTitlesWidgetcallback, or a helper method that isn'tbuild(BuildContext context)), which previously producedUndefined name 'context'. The call site now uses whichever BuildContext-typed identifier is genuinely in lexical scope (respecting closure capture — an inline closure insidebuildstill resolves correctly — and using the parameter's real name, e.g.ctx, not a hardcodedcontext). Text with no BuildContext resolvable is reported instead of silently dropped or turned into broken code. - Added: string interpolations with a nullable static type (e.g.
Text('Error: ${snapshot.error}')) are now coerced to a non-nullObjectat the call site by default (expr?.toString() ?? ''), fixingflutter analyzefailures likeThe argument type 'X?' can't be assigned to the parameter type 'Object'. Pass--strict-null-handlingto skip-and-report these instead of applying the default coercion. - Improved: the possible-hardcoded-text scan now skips named arguments that look like non-display data (
key,id,value,color,url,icon,route,type,code,tag,asset,path) instead of flagging every string literal regardless of parameter name - Fixed: two remaining
--replaceprogress lines (Added import to X.dart,Removed N const keyword(s)...) are now flushed immediately like the rest, so long runs redirected to a file don't appear to hang between them
1.2.0 #
- Added: motrgem now scans for hardcoded-looking text it can't safely auto-fix — string args passed to your own custom widget/exception classes (e.g.
MyStatCard(label: ...),throw AuthError(message: ...)), strings insidevalidator:closures, and elements ofconst/plainList<String>variables — and reports them (console summary +lib/l10n/possible_hardcoded_texts.txt) on every--dry-run/--replacerun instead of silently skipping them. Fixes the "clean run but the app isn't actually fully localized" false-completion problem. - Added: optional
motrgem.yamlconfig (extra_widgets,extra_text_params) lets a team opt their own design-system components into full auto-extraction + replacement, the same way built-in widgets likeTextwork
1.1.2 #
- Fixed: generated ARB/AppLocalizations ids that collided with Dart reserved words (e.g.
continue,new,default) now get a safe suffix (continueLabel) instead of producing invalid Dart - Fixed: strings with multiple
${...}interpolations now get uniquely-named placeholders (value1,value2, ...) instead of all colliding on the same name, and the ARB entry now includes a matchingplaceholdersmetadata block - Fixed: interpolated expressions spread across adjacent string-literal parts (e.g. multi-line concatenated strings) are no longer dropped — every argument is now collected and passed at the call site
- Fixed:
--replacenow createslib/l10n/automatically if it doesn't exist yet, instead of crashing when the project hasn't been initialized withstartfirst - Improved: the
AppLocalizationsimport inserter now recognizes imports withas/show/hidecombinators and both quote styles, and correctly respects the actually-modified file set - Improved:
constkeyword removal now also coversconst [...]andconst {...}collection literals (e.g.items: const [DropdownMenuItem(...)]), not just widget constructors - Improved: progress output during
--replaceand--add-localeis now flushed immediately so long runs don't appear to hang when output is redirected to a file or pipe - Added a
test/suite covering the extraction, ARB, orchestration, and project-init code paths
1.0.6 #
- Fixed duplicate text entries in ARB files
- Now reuses existing IDs for the same text instead of creating duplicates
- Improved text-to-ID mapping for better deduplication
- Added visual feedback when reusing IDs
1.0.4 #
- Updated README with improved installation instructions
- Added comprehensive guide for changing language at runtime
- Improved documentation for const keyword handling
- Enhanced examples and usage documentation
1.0.3 #
- Documentation improvements and bug fixes
- Updated example code
1.0.2 #
- Added automatic MaterialApp configuration with localization delegates
- Automatically configures
localizationsDelegatesandsupportedLocalesin MaterialApp - Added automatic translation when creating new locale files using
--add-locale - Automatically translates all texts using Google Translate
- Fixed import statement to use correct package name format:
package:[PackageName]/l10n/app_localizations.dart - Added automatic execution of Flutter commands after code replacement
- Automatically runs
flutter clean,flutter pub get, andflutter gen-l10nafter replacing texts - Improved user experience with automatic localization file generation
1.0.1 #
- Fixed bug in
startcommand that was malforming pubspec.yaml when adding dependencies - Improved dependency insertion to properly format YAML structure
- Added duplicate dependency check to prevent adding same dependency twice
1.0.0 #
- Initial release
- Extract hardcoded text strings from Flutter widgets
- Generate unique IDs in camelCase format
- Update ARB files with extracted texts
- Replace hardcoded strings with AppLocalizations calls
- Support for multiple locales
- Initialize projects with
startcommand - Support for common Flutter widgets (Text, Button, AppBar, etc.)