Cldr v2.20.0 MyApp.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

Specs

Returns how many plural forms exist for a given locale.

Examples

iex> MyApp.Cldr.Gettext.Plural.nplurals("pl")
4

iex> MyApp.Cldr.Gettext.Plural.nplurals("en")
2

Specs

Returns to what plural form a given number belongs to in a given locale.

Examples

iex> MyApp.Cldr.Gettext.Plural.plural("pl", 1)
0

iex> MyApp.Cldr.Gettext.Plural.plural("pl", 2)
1

iex> MyApp.Cldr.Gettext.Plural.plural("pl", 5)
2

iex> MyApp.Cldr.Gettext.Plural.plural("pl", 112)
2

iex> MyApp.Cldr.Gettext.Plural.plural("en", 1)
0

iex> MyApp.Cldr.Gettext.Plural.plural("en", 2)
1

iex> MyApp.Cldr.Gettext.Plural.plural("en", 112)
1