Cldr.Locale.put_likely_subtags
put_likely_subtags
, go back to Cldr.Locale module for more information.
Replace empty subtags within a Cldr.LanguageTag.t/0
with the most likely
subtag.
Arguments
language_tag
is any language tag returned byCldr.Locale.new/2
options
is a keyword list of options
Options
:add_likely
is a boolean indicating whether to add likely subtags. The default istrue
.
Notes
A subtag is called empty if it has a missing script or territory 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: x<sub>s</sub> is in the
source, x<sub>m</sub> is in a match, and x<sub>r</sub> is in the final result.
Lookup
Lookup each of the following in order, and stops on the first match:
- language<sub>s</sub>-script<sub>s</sub>-region<sub>s</sub>
- language<sub>s</sub>-region<sub>s</sub>
- language<sub>s</sub>-script<sub>s</sub>
- language<sub>s</sub>
- und-script<sub>s</sub>
Returns
If there is no match,either return
- an error value, or
- the match for
und
Otherwise there is a match = language<sub>m</sub>-script<sub>m</sub>-region<sub>m</sub>
Let x<sub>r</sub> = x<sub>s</sub> if x<sub>s</sub> is not empty, and x<sub>m</sub> otherwise.
Return the language tag composed of language<sub>r</sub>-script<sub>r</sub>-region<sub>r</sub> + variants + extensions .
Example
iex> Cldr.Locale.put_likely_subtags Cldr.LanguageTag.parse!("zh-SG")
%Cldr.LanguageTag{
backend: nil,
canonical_locale_name: nil,
cldr_locale_name: nil,
language_subtags: [],
extensions: %{},
gettext_locale_name: nil,
language: "zh",
locale: %{},
private_use: [],
rbnf_locale_name: nil,
requested_locale_name: "zh-SG",
script: :Hans,
territory: "SG",
transform: %{},
language_variants: []
}