flutter library

stringlocale for Flutter — re-exports the core plus the widgets.

Classes

AsyncTr
Bundle
A resolved locale bundle.
Param
Describes how a single placeholder in a StringLocale string behaves — how it is formatted, whether it drives axis selection, and whether it is resolved offline or requires an LLM adapter at runtime.
StringLocale
A localizable string with typed parameter descriptors.
StringLocaleScope
Provides the active locale + bundle to the tree. Wrap your app in it.
Tr
Renders a sl.StringLocale in the scope's current locale. Resolution is synchronous (offline lookup), so unlike the old render-time-LLM widget this needs no FutureBuilder.

Constants

pluralToken → const String

Functions

clearRegistry() → void
Clear the global registry. Useful in tests to reset state between runs.
convertDigits(String text, String localeCode) String
currentBundle() Bundle?
The currently active Bundle, or null if none has been set.
formatCurrencyValue(Object value, String localeCode, [String? currency]) String
formatDateValue(Object value, String localeCode, [String? fmt]) String
formatRelativeValue(Object value, String localeCode) String
getLocale() String
The currently active locale tag (e.g. 'en-US', 'fr-FR').
getRegistry() Map<String, StringLocale>
All StringLocale instances that have been constructed and auto-registered, keyed by their id.
ioFileReader(String path) String?
Read a file with dart:io (VM / Flutter mobile+desktop). On web, pass your own FileReader (e.g. backed by rootBundle) to Bundle.fromDir.
load(String directory, {String? locale, AsyncAdapter? asyncAdapter, UserAdaptedMode userAdaptedMode = UserAdaptedMode.cached, Map<String, List<String>>? fallbacks, Adapter? adapter}) Bundle
Convenience: load a compiled bundle directory using dart:io and make it the active bundle. Mirrors the Python load("dist").
pluralCategories(String localeCode) List<String>
pluralCategory(String localeCode, Object? value) String
setLocale(String locale) → void
Set the active locale for library-level StringLocale.resolve() calls.
tr(BuildContext context, StringLocale string, {Map<String, Object?> args = const {}}) String
Imperative resolve from a context (for snackbars/dialogs).
trAsync(BuildContext context, StringLocale string, {Map<String, Object?> args = const {}}) Future<String>
useBundle(Bundle? bundle, {String? locale}) → void
Attach an already-constructed Bundle as the active one and (optionally) set the current locale. (Dart can't read files portably from this layer, so the caller builds the Bundle via Bundle.fromDir(reader) or fromJsonString.)

Typedefs

Adapter = String Function(String value, String locale, String? context)
adapter(value, locale, context) -> reformatted string (userAdapted hatch).
AsyncAdapter = Future<String> Function(String value, String locale, String? context)
FileReader = String? Function(String path)
A function that reads a file's contents, injected so the runtime stays platform-agnostic (dart:io on VM, asset bundle on Flutter, etc.).

Exceptions / Errors

MissingRequiredAxis
StringNotFound