View Source Cldr.Number.PluralRule (Cldr v2.33.1)

Defines the plural rule implementation modules. The functions in this module generates code to implement the plural rules of CLDR.

Link to this section Summary

Types

Defines the plural types into which a number can be categorised.

Functions

Returns a list of the possible pluralization types

Returns the plural type for a given number.

Link to this section Types

@type operand() :: any()
@type plural_type() :: :zero | :one | :two | :few | :many | :other

Defines the plural types into which a number can be categorised.

Link to this section Functions

@spec known_plural_types() :: [plural_type()]

Returns a list of the possible pluralization types

Link to this function

plural_type(number, backend \\ nil, options \\ [])

View Source

Returns the plural type for a given number.

arguments

Arguments

  • number is an integer, float or Decimal number

  • backend is any module that includes use Cldr and therefore is a Cldr backend module. The default is Cldr.default_backend!/0.

  • options is a keyword list of options

options

Options

examples

Examples

iex> Cldr.Number.PluralRule.plural_type(123)
:other

iex> Cldr.Number.PluralRule.plural_type(123, type: Ordinal)
:few

iex> Cldr.Number.PluralRule.plural_type(123, type: Cardinal)
:other

iex> Cldr.Number.PluralRule.plural_type(2, locale: "de")
:other