get static method
Get translated text.
Get the translation by specifying the key
.
By specifying defaultValue
,
you can determine the value if key
is not found.
By specifying language
, you can translate in a specific language.
If language
is specified and the specified language is not available,
the translation will be performed in English.
Implementation
static String get(String key, {String? defaultValue, String? language}) {
if (language.isNotEmpty) {
final document =
_collection[language] ?? _collection[_defaultLoacle.split("_").first];
if (!(document?.containsKey(key) ?? false)) {
return defaultValue ?? key;
}
return document?[key] ?? defaultValue ?? key;
} else {
if (!(_document?.containsKey(key) ?? false)) {
return defaultValue ?? key;
}
return _document?[key] ?? defaultValue ?? key;
}
}