View Source MyApp.Gettext.Plural (Cldr v2.39.2)

Summary

Functions

Returns the number of plural forms for a given locale.

Returns the plural form of a number for a given locale.

Functions

@spec nplurals(Cldr.Locale.locale_name() | String.t()) :: pos_integer() | no_return()

Returns the number of plural forms for a given locale.

  • locale is either a locale name in the list {:__aliases__, [counter: {MyApp.Gettext.Plural, 1}, line: 4, column: 42], [:MyApp, :Cldr]}.known_locale_names/0 or a %LanguageTag{} as returned by Cldr.Locale.new/2

Examples

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

iex> MyApp.Gettext.Plural.nplurals("en")
2
@spec plural(String.t() | Cldr.LanguageTag.t(), number()) ::
  0 | pos_integer() | no_return()

Returns the plural form of a number for a given locale.

  • locale is either a locale name in the list {:__aliases__, [counter: {MyApp.Gettext.Plural, 1}, line: 4, column: 42], [:MyApp, :Cldr]}.known_locale_names/0 or a %LanguageTag{} as returned by Cldr.Locale.new/2

Examples

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

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

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

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

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

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

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

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