get method
Get the right translated string variant depending on a gender and a count
Implementation
String? get(
JsonIntlGender? gender,
JsonIntlPlural plural,
JsonIntlPlural? direct,
) {
final p = _messages[gender] ??
_messages[JsonIntlGender.neutral] ??
_messages[JsonIntlGender.male] ??
_messages[JsonIntlGender.female];
if (p == null) {
return null;
}
if (direct != null && p.containsKey(direct)) {
return p[direct];
}
if (p.containsKey(plural)) {
return p[plural];
}
switch (plural) {
case JsonIntlPlural.zero:
return p[JsonIntlPlural.few] ??
p[JsonIntlPlural.many] ??
p[JsonIntlPlural.other];
case JsonIntlPlural.one:
return p[JsonIntlPlural.other];
case JsonIntlPlural.two:
return p[JsonIntlPlural.few] ??
p[JsonIntlPlural.many] ??
p[JsonIntlPlural.other];
case JsonIntlPlural.many:
return p[JsonIntlPlural.other];
case JsonIntlPlural.few:
return p[JsonIntlPlural.many] ?? p[JsonIntlPlural.other];
default:
return p[JsonIntlPlural.few] ?? p[JsonIntlPlural.many];
}
}