signals_translator 0.0.7
signals_translator: ^0.0.7 copied to clipboard
Translate your project 100% using signals
0.0.7 #
Hotfix for 0.0.6: currentLocale now defaults to the 'sys' sentinel
instead of the device's regional locale string. The 0.0.6 default
(composeDeviceLocale(), e.g. 'en_US') silently broke any caller
binding a dropdown's value: to currentLocale against bare-language
items — 'en_US' doesn't match 'en', so the dropdown asserted and
the page failed to render.
_chosenLocaleinitialises to'sys'until a concrete locale is chosen vialoadLocaleor rehydrated from storage. Regional asset auto-pickup still works through the'sys'path (resolvedLocalereturns the regional code from_deviceLocale).- Stored locale preferences from earlier versions continue to load unchanged.
- Apps that want the previous "pick the device's regional locale at
startup" behaviour can call
await loadLocale('sys')(or any explicit locale) during initialisation.
0.0.1 #
0.0.1+1 #
0.0.1+2 #
- edited and clarified the documentation
0.0.2 #
- remove the reset function
0.0.3 #
- add support for (basic) pluralization
0.0.5 #
-
loadLocaleno longer throws when the resolved translation asset is missing or malformed. It now falls back tofallbackLocale(defaults to'en', configurable viaSignalTranslator().fallbackLocale). -
The user's chosen locale (including
'sys') is persisted even when its asset cannot be loaded, so the preference survives across restarts. -
Missing/malformed asset errors are now logged via
debugPrintinstead of silently swallowed. -
Added
SignalTranslator.debugReset()static method for test isolation (replaces the oldresetForTesting()instance method). -
Removed unused
decodedJsoncomputed field. -
Wire up automated publishing from GitHub Actions: explicitly request a pub.dev OIDC token and configure pub credentials so the workflow no longer falls back to interactive OAuth.
Note: 0.0.4 was tagged but never successfully published to pub.dev (the GA workflow's auth handshake failed), so 0.0.5 is the first release with these changes.
0.0.6 #
Region- and script-aware locales — without losing the simple flow. Ship
en_GB, en_US, or zh_Hans_CN translation files and they're picked
up automatically. Skip them and the existing single-language usage keeps
working exactly as before; no migration, no API churn.
- Translation files at
assets/translations/<lang>[_<Script>][_<REGION>].jsonare now discovered. Common shapes:en.json,en_GB.json,zh_Hans_CN.json. loadLocaleaccepts any case or separator —en_GB,en-gb,EN_gB,zh-hans-cnall normalize to canonical form. Non-canonical input logs a one-linedebugPrintwarning so misnamed files surface quickly.'sys'mode now readsscriptCodeandcountryCodefrom the device locale, resolving to the most specific file the app ships. OS locale changes are tracked reactively viaWidgetsBindingObserver.didChangeLocales— anyWatchreading translations rebuilds automatically.- Fallback chain: a missing regional asset falls through to its bare
language before reaching
fallbackLocale(e.g.en_GB → en → fallback), deduplicated. - New
resolvedLocalegetter returns a concrete locale string suitable forintl/DateFormatand other APIs that don't understand the'sys'sentinel. - Missing-asset
debugPrintnow mentions the canonical filename form to help diagnose misnamed regional files. - Concurrent reloads are serialized via a monotonic token, so an OS
locale change racing with an explicit
loadLocalecan't let a slow stale asset overwrite a newer one. WidgetsBindingObserverregistration is retried lazily on eachloadLocalecall — aSignalTranslatorconstructed beforeWidgetsFlutterBinding.ensureInitialized()self-heals on the next call.- Malformed translation assets (root not a JSON object,
translationsnot a map) degrade to the next fallback candidate instead of throwing. - Fully backwards compatible: bare-language usage (
en,nl,es) works unchanged, and apps that shipped legacy hyphen-separated assets (e.g.en-gb.json) keep loading them — the raw input is probed as a fallback candidate before the bare-language fallback, and stored prefs preserve the caller's original form so cross-restart lookups don't drift.