Cldr.territory_chain

You're seeing just the function territory_chain, go back to Cldr module for more information.

Return the territory fallback chain based upon a locales territory (including u extension) and territory containment definitions.

While CLDR also includes subdivisions in the territory chain, this implementation does not consider them.

Arguments

  • territory is either a binary or atom territory code or a t:Cldr.LanguageTag

Returns

  • {:ok, list} where list is a list of territories in decreasing order of containment (ie larger enclosing areas) or

  • {:error, {exception, reason}} indicating an error

Examples

iex> Cldr.territory_chain "US"
{:ok, [:US, :"021", :"019", :"001"]}

iex> Cldr.territory_chain :AU
{:ok, [:AU, :"053", :"009", :"001"]}

iex> {:ok, locale} = Cldr.validate_locale("en-US-u-rg-CAzzzz", MyApp.Cldr)
iex> Cldr.territory_chain locale
{:ok, [:CA, :"021", :"019", :"001"]}

iex> Cldr.territory_chain :"001"
{:ok, [:"001"]}
Link to this function

territory_chain(locale_name, backend)

View Source

Return the territory fallback chain based upon a locales territory (including u extension) and territory containment definitions.

While CLDR also includes subdivisions in the territory chain, this implementation does not consider them.

Arguments

  • locale is a binary locale name

  • backend is any module that includes use Cldr and therefore is a Cldr backend module.

Returns

  • {:ok, list} where list is a list of territories in decreasing order of containment (ie larger enclosing areas) or

  • {:error, {exception, reason}} indicating an error

Examples

iex> Cldr.territory_chain "en-US-u-rg-CAzzzz", MyApp.Cldr
{:ok, [:CA, :"021", :"019", :"001"]}