PluralCategoryUtils
CLDR cardinal plural rules: which form of a word (one, few, many, other, …) a number takes in a language.
Nothing here is specific to units; MetricUnitFormatUtils uses it to pick a translated unit name's form.
Types
PluralCategory
type PluralCategory = "zero" | "one" | "two" | "few" | "many" | "other"A CLDR plural category. A translated name has a key for each category its language uses.
Functions
getPluralCategory
PluralCategoryUtils.getPluralCategory(locale: string?,amount: number,fraction: string?--
the decimals written, if any
) → PluralCategory
The CLDR plural category of a number as written in locale, from CLDR's cardinal plural rules for every language
MetricUnitTranslator ships. amount is the rounded value shown and fraction the decimals written after the
decimal mark ("50" for "1.50"), since English writes "1 meter" but "1.0 meters".
oneonly: English, German (i = 1 and v = 0); Spanish and Turkish (n = 1); Vietnamese (i = 0 or n = 1).-
oneandmany: French and Portuguese (onefori = 0..1), Italian (onefori = 1 and v = 0);manyis a whole multiple of a million, as Spanish also has. one,few,many: Russian and Polish, for whole numbers; their fractions areother.zero,one,two,few,many: Arabic.otheronly: Chinese, Japanese, Korean, Thai and Indonesian.
PluralCategoryUtils.getPluralCategory("en-us", 1) -- "one"
PluralCategoryUtils.getPluralCategory("en-us", 1, "0") -- "other", as in "1.0 meters"
PluralCategoryUtils.getPluralCategory("fr-fr", 1.5, "5") -- "one"
PluralCategoryUtils.getPluralCategory("ru-ru", 3) -- "few"
PluralCategoryUtils.getPluralCategory("ar", 11) -- "many"