quantitiesLogic method

LocalisonPlural quantitiesLogic(
  1. num count,
  2. Locale locale,
  3. Map<LocalisonQuantity, int> quantities
)

Implements the quantities logic.

Implementation

static LocalisonPlural quantitiesLogic(
  num count,
  Locale locale,
  Map<LocalisonQuantity, int> quantities,
) {
  assert(null != count);
  assert(null != locale);
  assert(null != quantities);

  if (0 == count) {
    return LocalisonPlural.zero;
  }
  if (1 == count) {
    return LocalisonPlural.one;
  }
  if (2 == count) {
    return LocalisonPlural.two;
  }
  if ((quantities[LocalisonQuantity.few] ?? 0) >= count) {
    return LocalisonPlural.few;
  }
  if ((quantities[LocalisonQuantity.many] ?? 0) >= count) {
    return LocalisonPlural.many;
  }
  return LocalisonPlural.other;
}