Cldr.Locale.canonical_language_tag

You're seeing just the function canonical_language_tag, go back to Cldr.Locale module for more information.
Link to this function

canonical_language_tag(locale_name, backend)

View Source

Parses a locale name and returns a Cldr.LanguageTag struct that represents a locale.

Arguments

Returns

  • {:ok, language_tag} or

  • {:eror, reason}

Method

  1. The language tag is parsed in accordance with RFC5646

  2. Any language, script or region aliases are replaced. This will replace any obsolete elements with current versions

  3. If a territory or script is not specified, a default is provided using the CLDR information returned by Cldr.Locale.likely_subtags/1

  4. A Cldr locale name is selected that is the nearest fit to the requested locale.

Example

iex> Cldr.Locale.canonical_language_tag("en", TestBackend.Cldr)
{
  :ok,
  %Cldr.LanguageTag{
    backend: TestBackend.Cldr,
    canonical_locale_name: "en-Latn-US",
    cldr_locale_name: "en",
    extensions: %{},
    gettext_locale_name: "en",
    language: "en",
    locale: %{},
    private_use: [],
    rbnf_locale_name: "en",
    requested_locale_name: "en",
    script: "Latn",
    territory: :US,
    transform: %{},
    language_variant: nil
  }
}