tr function

String tr(
  1. BuildContext context,
  2. StringLocale string, {
  3. Map<String, Object?> args = const {},
})

Imperative resolve from a context (for snackbars/dialogs).

Implementation

String tr(BuildContext context, sl.StringLocale string,
    {Map<String, Object?> args = const {}}) {
  final scope = StringLocaleScope._inherited(context);
  return scope.bundle.has(string.id)
      ? scope.bundle.resolve(scope.locale, string.id, args)
      : string.resolve(locale: scope.locale, args: args);
}