t method
Attempts to retrieve a translation at key
.
- If
context
is given, then attempts to search for the key at 'key_context', before defaulting to thekey
itself. It is useful for selections like gender. - If
count
is given, then based onlocale
attempts to find the appropriate pluralized key, before defaulting to thekey
itself. Most languages likeen
have onlyone
andother
pluralization forms but some likear
require a more complex system. - If
variables
are given, they are used as a lookup table when a match has been found (delimited by I18NextOptions.interpolationPrefix and I18NextOptions.interpolationSuffix). Before the result is added to the final message, it first goes through I18NextOptions.formats. - If
locale
is given, it overrides the current locale value. - If
options
is given, it overrides any non-null property over current options.
The named parameters in this method that are also declared by
I18NextOptions supersede options
's values.
Keys that allow both contextualization and pluralization must be declared
in the order: key_context_plural
If a value for key
is not found, returns the key
itself.
Implementation
String t(
String key, {
Locale? locale,
String? context,
int? count,
Map<String, dynamic>? variables,
I18NextOptions? options,
String Function(String)? orElse,
}) {
return tOrNull(
key,
locale: locale,
context: context,
count: count,
variables: variables,
options: options,
) ??
orElse?.call(key) ??
key;
}