PluralRules

Small, allocation-free CLDR cardinal plural rule set covering the locales a game is likely to ship. Only the cardinal categories are modelled; ordinals are not.

Remarks

The rules are distilled from CLDR's plurals.xml rather than read from it, so a locale whose rules are absent falls back to the Germanic one/other split, which is at worst an imprecise translation and never a crash.

Public Methods

GetCategory

public static PluralCategory GetCategory(string? locale, decimal value)

The CLDR cardinal category a count falls into for a locale.

Parameters:

  • locale (string?): A BCP-47 locale such as pt-BR, or its language such as pt.
  • value (decimal): The count the message formats.

Returns: PluralCategory

  • The category whose variant the message should use.