trIn method
Translates this string in the given context.
The same base string can mean different things on different screens.
German 'Einladung' is the title of an invite screen and also an
occasion tag ("having guests over"), which English needs as two different
words. .trIn gives each place its own key, so each can get its own
translation, while the base language still shows the plain string:
'Einladung'.tr // "Invitation"
'Einladung'.trIn('Anlass') // "Having guests"
'Hallo {name}'.trIn('Push', {'name': username})
context must be a string literal, like the string itself, so
localize_it can find it. It is also passed to DeepL as context.
{name} placeholders are replaced with the values from args.
Implementation
String trIn(String context, [Map<String, Object?> args = const {}]) {
final key = LocalizeIt.contextKey(this, context);
final translated = LocalizeIt.translate(key);
// Not generated yet: show the plain string, never the internal key.
final text = translated == key ? this : translated;
return _interpolate(text, args);
}