Cldr v0.8.3 Cldr.Locale View Source

Parse and process locale json as defined by Unicode

Link to this section Summary

Types

The name of a locale in a string format

Link to this section Types

The name of a locale in a string format

Link to this section Functions

Link to this function add_likely_subtags(language_tag) View Source

Given a source locale X, to return a locale Y where the empty subtags have been filled in by the most likely subtags.

This is written as X ⇒ Y (“X maximizes to Y”).

A subtag is called empty if it is a missing script or region subtag, or it is a base language subtag with the value und. In the description below, a subscript on a subtag x indicates which tag it is from: xs is in the source, xm is in a match, and xr is in the final result.

This operation is performed in the following way:

Lookup

Lookup each of the following in order, and stop on the first match:

  • languages-scripts-regions
  • languages-regions
  • languages-scripts
  • languages
  • und-scripts

Return

  • If there is no match,either return

    • an error value, or
    • the match for und
  • Otherwise there is a match = languagem-scriptm-regionm

  • Let xr = xs if xs is not empty, and xm otherwise.

  • Return the language tag composed of languager-scriptr-regionr + variants + extensions .

Example

iex> Cldr.Locale.add_likely_subtags Cldr.LanguageTag.parse!("zh-SG")
%Cldr.LanguageTag{extensions: %{}, language: "zh", locale: [], private_use: [],
 region: "SG", script: "Hans", transform: %{}, variant: nil}
Link to this function alias_error(locale_name, alias_name) View Source
Link to this function canonical_language_tag(locale_name) View Source
Link to this function canonical_language_tag!(language_tag) View Source
Link to this function cldr_locale_name(language_tag) View Source
Link to this function likely_subtags(locale_string) View Source
Link to this function locale_error(locale_name) View Source
Link to this function locale_name_from(language_tag) View Source
Link to this function locale_name_from(language, script, region, variant) View Source
Link to this function normalize_locale_name(name) View Source
normalize_locale_name(name()) :: name()
Link to this function rbnf_locale_name(language_tag) View Source
Link to this function substitute_aliases(language_tag) View Source

Given a source locale X, to return a locale Y where the aliases have been substituted with their non-deprecated alternatives.

  • Replace any deprecated subtags with their canonical values using the alias data. Use the first value in the replacement list, if it exists. Language tag replacements may have multiple parts, such as shsr_Latn or moro_MD. In such a case, the original script and/or region are retained if there is one. Thus sh_Arab_AQsr_Arab_AQ, not sr_Latn_AQ.

  • Remove the script code ‘Zzzz’ and the region code ‘ZZ’ if they occur.

  • Get the components of the cleaned-up source tag (languages, scripts, and regions), plus any variants and extensions.

Examples

iex> Cldr.Locale.substitute_aliases Cldr.LanguageTag.Parser.parse!("en-US")
%Cldr.LanguageTag{extensions: %{}, language: "en", locale: %{}, private_use: [],
 region: "US", script: nil, transform: %{}, variant: nil}

iex> Cldr.Locale.substitute_aliases Cldr.LanguageTag.Parser.parse!("sh_Arab_AQ")
%Cldr.LanguageTag{extensions: %{}, language: "sr", locale: [], private_use: [],
 region: "AQ", script: "Arab", transform: %{}, variant: nil}

iex> Cldr.Locale.substitute_aliases Cldr.LanguageTag.Parser.parse!("sh_AQ")
%Cldr.LanguageTag{extensions: %{}, language: "sr", locale: [], private_use: [],
 region: "AQ", script: "Latn", transform: %{}, variant: nil}

iex> Cldr.Locale.substitute_aliases Cldr.LanguageTag.Parser.parse!("mo")
%Cldr.LanguageTag{extensions: %{}, language: "ro", locale: [], private_use: [],
 region: "MD", script: nil, transform: %{}, variant: nil}