Cldr v1.5.1 Cldr.Gettext.Plural View Source
Defines a Plural module for Gettext that uses the Cldr
plural rules.
Link to this section Summary
Functions
Returns how many plural forms exist for a given locale
Returns to what plural form a given number belongs to in a given locale
Link to this section Functions
Link to this function
nplurals(locale_name)
View Source
nplurals(Cldr.Locale.locale_name()) :: non_neg_integer()
Returns how many plural forms exist for a given locale.
locale
is either a locale name in the listCldr.known_locales/0
or a%LanguageTag{}
as returned byCldr.Locale.new/1
Examples
iex> Cldr.Gettext.Plural.nplurals("pl")
3
iex> Cldr.Gettext.Plural.nplurals("en")
2
Link to this function
plural(locale_name, n)
View Source
plural( Cldr.Locale.locale_name() | Cldr.LanguageTag.t(), Cldr.Math.number_or_decimal() ) :: non_neg_integer() | {:error, String.t()}
Returns to what plural form a given number belongs to in a given locale.
locale
is either a locale name in the listCldr.known_locales/0
or a%LanguageTag{}
as returned byCldr.Locale.new/1
Examples
iex> Cldr.Gettext.Plural.plural("pl", 1)
0
iex> Cldr.Gettext.Plural.plural("pl", 2)
1
iex> Cldr.Gettext.Plural.plural("pl", 5)
2
iex> Cldr.Gettext.Plural.plural("pl", 112)
2
iex> Cldr.Gettext.Plural.plural("en", 1)
0
iex> Cldr.Gettext.Plural.plural("en", 2)
1
iex> Cldr.Gettext.Plural.plural("en", 112)
1