MyApp.Cldr.Territory.translate_subdivision

You're seeing just the function translate_subdivision, go back to MyApp.Cldr.Territory module for more information.
Link to this function

translate_subdivision(localized_string, from_locale, to_locale \\ MyApp.Cldr.get_locale())

View Source

Specs

translate_subdivision(
  binary(),
  Cldr.Territory.binary_tag(),
  Cldr.Territory.binary_tag()
) :: {: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. See MyApp.Cldr.Territory.known_locale_names/0. The default is Cldr.get_locale/0

Example

iex> MyApp.Cldr.Territory.translate_subdivision("Cumbria", "en", "pl")
{:ok, "Kumbria"}

iex> MyApp.Cldr.Territory.translate_subdivision("Cumbria", "en", "bs")
{:error, {Cldr.UnknownSubdivisionError, "The locale \"bs\" has no translation for \"gbcma\"."}}

iex> MyApp.Cldr.Territory.translate_subdivision("Cumbria", :zzz)
{:error, {Cldr.UnknownLocaleError, "The locale :zzz is not known."}}

iex> MyApp.Cldr.Territory.translate_subdivision("Cumbria", "en", "zzz")
{:error, {Cldr.UnknownLocaleError, "The locale \"zzz\" is not known."}}