df_localization 0.7.2
df_localization: ^0.7.2 copied to clipboard
A package that simplifies adding localization to your Flutter app.
Changelog #
0.7.2 #
- fix:
String.trIcunow guards theMessageFormatbuild/format in a try/catch. A malformed ICU template (a corrupt stored translation, or an author typo) previously threwmismatched { or }straight through to the host, greying every screen that rendered a plural. On failure it now forwards the error toTranslationManager.reportErrorand degrades gracefully: it formats the in-code source template (the part of the string before the||keydelimiter, which the developer wrote) with the same args, falling back to the raw source only if that fails too — so a corrupt stored translation renders the source-language plural instead of crashing or showing broken ICU syntax. This matchesdf_config's "a.tr()call must never crash the host" guarantee. - fix: Bump
df_configto^0.8.2, which stops the placeholder engine from corrupting inline ICU templates ({count, plural, …}}) during.tr()'s primary pass. Together these fix the greyed-screen crash when an ICU plural is rendered through a mapper-lessFileConfigor before the first config install.
0.7.1 #
- feat: Add source-text translation versioning to
AutoTranslationController(versionBySourceText, defaulttrue). Translations are stored under<key>@@<hash(sourceText)>, so rewording a string in a new release adds a new entry instead of overwriting the one already-deployed builds read — a one-string change costs one entry, not a database snapshot. Fixing a bad translation (same source) still propagates to all builds. Lookups fall back to legacy plain-key entries whose storedfrommatches, so pre-versioning databases keep resolving; runmigrateToVersionedKeys(locales)once to additively snapshot them.RemoteTranslationControllergets the same flag (defaultfalse) for servers that key their maps withversionedTranslationKey(key, sourceText). - feat: The versioning helpers (
versionedTranslationKey,translationSourceHash,kTranslationVersionSeparator) live indf_config≥ 0.8.1 (pure Dart) and are re-exported here — Dart backends producing translation maps server-side can depend ondf_configalone to key them. The hash is deterministic across platforms including web, and is pinned by a golden test. - chore: Remove the
df_logdependency — the runtime library never imported it, and thegen-translationsCLI now prints with self-contained ANSI colors. Its^0.5.1constraint previously conflicted with hosts pinning newerdf_logversions.
0.7.0 #
- Tagged but never published (pub.dev validation failure); all changes shipped in 0.7.1.
0.6.0 #
- breaking: Remove
ClaudeTranslatorBroker,GeminiTranslatorBroker,OpenAITranslatorBroker— replaced by the unifiedLlmTranslatorBrokerwith.claude()/.gemini()/.openai()factory constructors that drive anyAiBrokerfromai_broker. - breaking: Rename the
gen-translations-geminiCLI togen-translations. Adds a--provider claude|gemini|openaiflag and drops thegoogle_generative_aidependency in favour ofai_broker. - breaking: Bump
df_configto^0.8.0. Code that previously assignedTranslationManager.config = ...must switch toawait TranslationManager.setConfig(...). - feat: Add
RemoteTranslationControllerfor apps where translations are fetched from a backend via a singleFuture<Map<String, String>> Function(Locale)callback. Includes built-in stale-load protection for rapid locale switches. - feat: Add
.trIcu({args, preferKey, locale})extension — full ICU MessageFormat support (plural, select, gender,selectordinal) with CLDR rules per locale, backed byintl'sMessageFormat. - feat: Add
getSystemLocale()/getSystemLocales()/bestLocale(supported, {preferred})— cross-platform locale helpers (iOS, Android, macOS, Windows, Linux, Web).bestLocaleis a drop-in forMaterialApp.localeListResolutionCallback. - feat: Add
isRtlLocale(locale)/getTextDirection(locale)helpers for right-to-left languages. - feat: Add
ActiveLocale— process-wide active locale read by.trIcu()for plural rules and updated automatically by every controller'ssetLocale. - fix:
AutoTranslationControllerno longer poisons the new-locale cache or DB path when the user switches locale mid-translation. - fix: First auto-translation against an empty remote database no longer crashes with
Cannot modify unmodifiable map. - fix:
TranslationController.setLocalenow awaits the file read so.tr()calls fired immediately after are guaranteed to see the new translations. - fix:
TranslationController.createInstanceaccepts thefileTypeparameter documented in the README.