Cldr v2.20.0-rc.0 MyApp.Cldr.Locale View Source

Backend module that provides functions to define new locales.

Link to this section Summary

Functions

Returns the territory from a language tag or locale name.

Returns the time zone from a language tag or locale name.

Link to this section Functions

Link to this function

territory_from_locale(locale)

View Source (since 2.18.2)

Specs

territory_from_locale(Cldr.LanguageTag.t() | Cldr.Locale.locale_name()) ::
  Cldr.territory()

Returns the territory from a language tag or locale name.

Arguments

Returns

  • A territory code as an atom

Examples

iex> MyApp.Cldr.Locale.territory_from_locale "en-US"
:US

iex> MyApp.Cldr.Locale.territory_from_locale "en-US-u-rg-GBzzzz"
:GB
Link to this function

timezone_from_locale(locale)

View Source (since 2.19.0)

Specs

timezone_from_locale(Cldr.LanguageTag.t() | Cldr.Locale.locale_name()) ::
  String.t() | {:error, {module(), String.t()}}

Returns the time zone from a language tag or locale name.

Arguments

Returns

  • A time zone ID as a string or

  • :error if no time zone can be determined

Examples

iex> MyApp.Cldr.Locale.timezone_from_locale "en-US-u-tz-ausyd"
"Australia/Sydney"