MyApp.Cldr.Territory.from_territory_code
You're seeing just the function
from_territory_code
, go back to MyApp.Cldr.Territory module for more information.
Link to this function
from_territory_code(territory_code, options \\ [locale: MyApp.Cldr.get_locale(), style: :standard])
View SourceSpecs
from_territory_code(Cldr.Territory.atom_binary_tag(), Cldr.Territory.options()) :: {:ok, binary()} | {:error, Cldr.Territory.error()}
Localized string for the given territory code.
Returns {:ok, String.t}
if successful, otherwise {:error, reason}
.
options
are:locale
is any configured locale. SeeMyApp.Cldr.Territory.known_locale_names/0
. The default isCldr.get_locale/0
style
is one of those returned byMyApp.Cldr.Territory.available_styles/0
. The current styles are:short
,:standard
and:variant
. The default is:standard
Example
iex> MyApp.Cldr.Territory.from_territory_code(:GB)
{:ok, "United Kingdom"}
iex> MyApp.Cldr.Territory.from_territory_code(:GB, [style: :short])
{:ok, "UK"}
iex> MyApp.Cldr.Territory.from_territory_code(:GB, [style: :ZZZ])
{:error, {Cldr.UnknownStyleError, "The style :ZZZ is unknown"}}
iex> MyApp.Cldr.Territory.from_territory_code(:GB, [style: "ZZZ"])
{:error, {Cldr.UnknownStyleError, "The style \"ZZZ\" is unknown"}}
iex> MyApp.Cldr.Territory.from_territory_code(:GB, [locale: "pt"])
{:ok, "Reino Unido"}
iex> MyApp.Cldr.Territory.from_territory_code(:GB, [locale: :zzz])
{:error, {Cldr.UnknownLocaleError, "The locale :zzz is not known."}}
iex> MyApp.Cldr.Territory.from_territory_code(:GB, [locale: "zzz"])
{:error, {Cldr.UnknownLocaleError, "The locale \"zzz\" is not known."}}