Cldr.territory_chain
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 at:Cldr.LanguageTag
Returns
{:ok, list}
wherelist
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"]}
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 namebackend
is any module that includesuse Cldr
and therefore is aCldr
backend module.
Returns
{:ok, list}
wherelist
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"]}