t method

String t(
  1. DVTranslationKey key, {
  2. Map<String, String> args = const <String, String>{},
  3. LocaleTag? locale,
  4. bool strict = false,
})

Implementation

String t(
  DVTranslationKey key, {
  Map<String, String> args = const <String, String>{},
  LocaleTag? locale,
  bool strict = false,
}) {
  final selected = locale ?? _currentLocale;
  final catalog = _catalogs[selected.value];
  final template = catalog?.messages[key];
  if (template == null) {
    if (strict) {
      throw StateError(
        'Missing Dartvel translation "${key.value}" for ${selected.value}.',
      );
    }
    return key.value;
  }
  return _interpolate(template, args);
}