setPluralResolver method

void setPluralResolver({
  1. String? language,
  2. E? locale,
  3. PluralResolver? cardinalResolver,
  4. PluralResolver? ordinalResolver,
})

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;
  }
}