Cldr.Locale.canonical_language_tag
You're seeing just the function
canonical_language_tag
, go back to Cldr.Locale module for more information.
Parses a locale name and returns a Cldr.LanguageTag
struct
that represents a locale.
Arguments
language_tag
is any language tag returned byCldr.Locale.new/2
or anylocale_name
returned byCldr.known_locale_names/1
backend
is any module that includesuse Cldr
and therefore is aCldr
backend module
Returns
{:ok, language_tag}
or{:eror, reason}
Method
The language tag is parsed in accordance with RFC5646
Any language, script or region aliases are replaced. This will replace any obsolete elements with current versions
If a territory or script is not specified, a default is provided using the CLDR information returned by
Cldr.Locale.likely_subtags/1
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
}
}