ds_i18n 0.2.0
ds_i18n: ^0.2.0 copied to clipboard
Lightweight, JSON-based localization for Flutter. Drop translation files into assets/i18n/, call I18n.t('key'), switch languages at runtime. No codegen.
0.2.0 #
Changed #
- BREAKING:
LocaleChangeextension methods (changeToFirstLocale,changeToNextLocale,changeToLocale) now returnFuture<void>instead ofvoid, so callers can await the locale switch and the reloaded translations. Fire-and-forget call sites keep working; only tear-offs typed asvoid Function()need updating.
Added #
init()gained an optionalforceparameter to force a full re-initialization (e.g. in tests).
Fixed #
init()now validatesinitialLocaleagainst the supported locales and falls back to the default locale instead of reporting an unsupported locale.init()is now idempotent and concurrency-safe: the load runs only once, and concurrent or repeated calls await the same in-flight result.I18nConfig.fromJsonno longer discards the entire configuration when a single field is missing or malformed; fields are parsed defensively, anddefaultLocale/fallbackLocaleare validated againstsupportedLocales.- Argument substitution now resolves each placeholder exactly once in a single pass, so inserted values are never re-scanned and unknown placeholders are left intact.
ds_i18n:initscaffolding now reports created, overwritten, and skipped files separately instead of conflating them.ds_i18n:initno longer reports a false "already registered" whenassets/i18nappears only in a commented-out line ofpubspec.yaml.
0.1.0 #
- Renamed package from
i18ntods_i18n. The import is nowpackage:ds_i18n/ds_i18n.dart. The public API is unchanged — you still callI18n.t('key'). - BREAKING (config): the config key
supportedLocalswas renamed to the correctly spelledsupportedLocales. Update yourassets/i18n/config.jsonaccordingly. - Restructured into a single public barrel (
lib/ds_i18n.dart) with the implementation moved underlib/src/. - Fixed: config parsing crashed because
fromJsonread the misspelled keyfallbacklocaleinstead offallbackLocale. - Fixed:
translate()threw a runtime type error when a non-String argument (e.g. anintcount) was passed viaargs. Values are now converted withtoString(). - Fixed: the configured
fallbackLocalewas ignored — the translation fallback was hard-coded toen.json. It now uses the configured fallback. - Raised minimum Flutter constraint to
>=3.35.1. - Relicensed from GPL-3.0 to BSD-3-Clause.
- Added
dart run ds_i18n:initto scaffoldassets/i18n/base files in a consuming project. - Added a runnable
example/app.
0.0.1 #
- Initial release: JSON-based localization with runtime locale switching, nested keys, argument substitution, RTL detection, and persistence via shared_preferences.