howdy/i18n/plural

Plural categories: which form of a word a number takes.

English has two cardinal forms, “1 day” and “2 days”; Polish has four, Arabic six. cardinal picks the category for a count, and ordinal the one for a position, as in “1st” and “2nd”.

Rules come from CLDR 48.0.0 and cover whole numbers. A tag that has no rules of its own uses its language’s; a language with no rules at all uses Other for everything.

Types

pub type Category {
  Zero
  One
  Two
  Few
  Many
  Other
}

Constructors

  • Zero
  • One
  • Two
  • Few
  • Many
  • Other

Values

pub fn cardinal(locale: String, count: Int) -> Category

The category for a count, such as One for 1 in English.

pub fn cardinal_categories(locale: String) -> List(Category)

The cardinal categories a locale uses, in the order Zero to Other.

pub fn from_string(name: String) -> Result(Category, Nil)
pub fn ordinal(locale: String, position: Int) -> Category

The category for a position, such as Two for 2 (“2nd”) in English.

pub fn ordinal_categories(locale: String) -> List(Category)

The ordinal categories a locale uses, in the order Zero to Other.

pub fn to_string(category: Category) -> String

The category’s name in ICU messages: one, few and so on.

✨ Search Document