auto_l10n 0.3.0
auto_l10n: ^0.3.0 copied to clipboard
Automatic Flutter app translation with zero code changes. One line in main.dart. Supports DeepL, MyMemory, Lingva, Google Translate, and custom translators.
0.3.0 #
- Added
layoutPolicytoautoL10n()/AutoL10nBinding.ensureInitialized():AutoL10nLayoutPolicy.offAutoL10nLayoutPolicy.safeFallbackAutoL10nLayoutPolicy.safeEllipsisCurrent
- Added layout-safe runtime handling for tight horizontal
Row/Flexlabels:- optional fallback to source text
- optional translated ellipsis trimming (
...) in conservative mode
- Runtime bootstrap made deterministic:
SharedPreferences cache -> ARB preload -> API fallback. - ARB-only mode no longer uses
NoOpTranslatorin runtime pipeline; API queue/flush is skipped when no translator is configured. - Unified cache key namespace by language:
auto_l10n_<lang>(instead of translator-scoped keys). - Runtime cache no longer stores unchanged entries (
translated == original). - Runtime translation patching now also handles
Text.textSpan(in addition toText.dataandRichText). - Runtime lookup improved for case/whitespace mismatches (case-insensitive matching with preserved case pattern and trimmed lookup with preserved outer whitespace).
- Retry behavior for failed API batches: up to 3 retry attempts, then stop until new input arrives.
- DeepL XML mode fixes: safe XML escaping around placeholders and entity decode after translation.
- CLI extraction upgraded to AST-first scanning and expanded to capture real-world UI patterns.
- CLI now captures fallback literals in mixed expressions (e.g. ternary with one non-literal branch).
- CLI now captures string arguments from mixed-signature calls (e.g. string + enum arguments in one call).
- CLI now resolves
constreferences (including qualified static const values) when extracting strings. - CLI keys are normalized with trim by default (cleaner ARB keys).
- README updated with layout policy documentation and usage examples.
0.2.0 #
- Generate CLI (
dart run auto_l10n): from-code (scanText('...')/Text("...")) or from-arb; optional--service(deepl, google, mymemory, lingva, mock) with--api-keyfor deepl/google. Output toassets/auto_l10nby default. - Pre-generated ARB only:
autoL10n()with no provider loads fromtranslationsPath(defaultassets/auto_l10n); no API key required. - Pre-generated + API:
autoL10n(provider: ..., apiKey: ...)loads ARB first, translates missing strings via API. - API only:
autoL10n(provider: ..., loadPregenerated: false). autoL10n()top-level helper;translationsPathandloadPregeneratedparameters on binding.- TranslationCache: optional preloaded map;
addPreloaded()for async ARB load and persist. - NoOpTranslator when only pre-generated ARB is used.
- RichText widgets are now patched and restored: translated text is shown in
RichText/ nestedTextSpans, not only inText. - Example app: user-generated content (text field → translated output), locale picker (device locale on launch with fallback to en), in-app copy about API key vs free providers, pre-generated ARB.
0.1.0 #
- Initial release.
- Runtime translation for Flutter
TextandRichTextviaAutoL10nBinding. - Built-in providers: DeepL, MyMemory, Lingva, Google Translate, Mock.
- Optional
targetLocale(defaults to device locale). - Custom translators via
AbstractTranslator. - Per-language cache in memory and SharedPreferences.
- Static ARB generation:
dart run auto_l10n:generate.