MyApp.Cldr.Territory.translate_territory
You're seeing just the function
translate_territory
, go back to MyApp.Cldr.Territory module for more information.
Link to this function
translate_territory(localized_string, from_locale, to_locale, style)
View SourceSpecs
translate_territory( binary(), Cldr.Territory.binary_tag(), Cldr.Territory.binary_tag(), atom() ) :: {:ok, binary()} | {:error, Cldr.Territory.error()}
Translate a localized string from one locale to another.
Returns {:ok, result}
if successful, otherwise {:error, reason}
.
to_locale
is any configured locale. SeeMyApp.Cldr.Territory.known_locale_names/0
. The default isCldr.get_locale/0
Example
iex> MyApp.Cldr.Territory.translate_territory("Reino Unido", "pt")
{:ok, "United Kingdom"}
iex> MyApp.Cldr.Territory.translate_territory("United Kingdom", "en", "pt")
{:ok, "Reino Unido"}
iex> MyApp.Cldr.Territory.translate_territory("Reino Unido", :zzz)
{:error, {Cldr.UnknownLocaleError, "The locale :zzz is not known."}}
iex> MyApp.Cldr.Territory.translate_territory("United Kingdom", "en", "zzz")
{:error, {Cldr.UnknownLocaleError, "The locale \"zzz\" is not known."}}
iex> MyApp.Cldr.Territory.translate_territory("Westworld", "en", "pt")
{:error, {Cldr.UnknownTerritoryError, "No territory translation for \"Westworld\" could be found in locale \"en\""}}