setPluralResolver method
void
setPluralResolver({
- String? language,
- E? locale,
- PluralResolver? cardinalResolver,
- PluralResolver? ordinalResolver,
Sets plural resolvers.
See https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_plural_rules.html
See https://github.com/Tienisto/flutter-fast-i18n/blob/master/lib/src/model/pluralization_resolvers.dart
Either specify language
, or locale
. Locale has precedence.
Implementation
void setPluralResolver({
String? language,
E? locale,
PluralResolver? cardinalResolver,
PluralResolver? ordinalResolver,
}) {
final List<E> targetLocales;
if (locale != null) {
// take only this locale
targetLocales = [locale];
} else if (language != null) {
// map to language
targetLocales = locales
.where((l) => mapper.toId(l).languageCode == language)
.toList();
} else {
throw 'Either language or locale must be specified';
}
// update translation instances
for (final curr in targetLocales) {
translationMap[curr] = translationMap[curr]!.copyWith(
cardinalResolver: cardinalResolver,
ordinalResolver: ordinalResolver,
) as T;
}
}