You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Normative: Align RegionPreference and CanonicalUnicodeSubdivision with UTS 35
Changes in `CanonicalUnicodeSubdivision`:
- Don't canonicalize region subtags to replace aliases.
- Only allow valid regular region codes using validity data defined in
UTS 35.
Changes in `RegionPreference`:
- Return the first region which can be matched, using the following
preference order:
1. Region override Unicode extension key `rg`.
2. Region subtag in locale.
3. Subdivision Unicode extenion key `sd`.
4. Region subtag added through likely subtags.
5. Fallback to region code `001`.
Fixestc39#1058
Copy file name to clipboardExpand all lines: spec/locale.html
+21-31Lines changed: 21 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -575,38 +575,40 @@ <h1>
575
575
): a String or *undefined*
576
576
</h1>
577
577
<dlclass="header">
578
+
<dt>description</dt>
579
+
<dd>The following algorithm refers to Region validity data specified in <ahref="https://unicode.org/reports/tr35/#unicode_region_subtag_validity">Unicode Technical Standard #35 Part 1 Core, Language Identifier Field Definitions</a>.</dd>
578
580
</dl>
579
581
<emu-alg>
580
582
1. Let _subdivision_ be UnicodeExtensionValue(_locale_, _key_).
581
583
1. If _subdivision_ is ~empty~, return *undefined*.
582
584
1. If _subdivision_ cannot be matched by the `unicode_subdivision_id` Unicode locale nonterminal, return *undefined*.
583
585
1. Let _region_ be the longest prefix of _subdivision_ matched by the `unicode_region_subtag` Unicode locale nonterminal.
584
-
1.Let _regionLocale_ be the string-concatenation of*"und-"* and_region_.
585
-
1.Set _regionLocale_ to CanonicalizeUnicodeLocaleId(_regionLocale_).
586
-
1. Return GetLocaleRegion(_regionLocale_).
586
+
1.Set _region_ to the ASCII-uppercase of _region_.
587
+
1.If _region_ is not a valid regular region code, return *undefined*.
_locale_: a Unicode canonicalized locale identifier,
594
-
): a Record with fields [[Region]] (a String) and [[RegionOverride]] (a String or *undefined*)
596
+
): a String
595
597
</h1>
596
598
<dlclass="header">
597
599
</dl>
598
600
<emu-alg>
599
-
1. Let _region_ be GetLocaleRegion(_locale_).
600
-
1. If _region_ is *undefined*, then
601
-
1. Set _region_ to CanonicalUnicodeSubdivision(_locale_, *"sd"*).
602
-
1. If _region_ is *undefined*, then
603
-
1.Let _maximal_ be the result of the <ahref="https://unicode.org/reports/tr35/#Likely_Subtags">Add Likely Subtags</a> algorithm applied to _locale_. If an error is signaled, set _maximal_ to _locale_.
604
-
1. Set _maximal_ to CanonicalizeUnicodeLocaleId(_maximal_).
605
-
1. Set _region_to GetLocaleRegion(_maximal_).
606
-
1.If _region_ is *undefined*, then
607
-
1. Set _region_ to *"001"*.
608
-
1.Let _regionOverride_ be CanonicalUnicodeSubdivision(_locale_, *"rg"*).
1. If _region_ is not *undefined*, return _region_.
607
+
1. Let _maximal_ be the result of the <ahref="https://unicode.org/reports/tr35/#Likely_Subtags">Add Likely Subtags</a> algorithm applied to _locale_. If an error is signaled, set _maximal_ to _locale_.
608
+
1.Set _maximal_ to CanonicalizeUnicodeLocaleId(_maximal_).
609
+
1. Set _region_ to GetLocaleRegion(_maximal_).
610
+
1.If _region_ is not *undefined*, return _region_.
1. Let _preference_ be RegionPreference(_loc_.[[Locale]]).
627
-
1. Let _region_ be _preference_.[[Region]].
628
-
1. Let _regionOverride_ be _preference_.[[RegionOverride]].
629
-
1. If _regionOverride_ is not *undefined* and calendar preference data for _regionOverride_ are available, then
630
-
1. Let _lookupRegion_ be _regionOverride_.
631
-
1. Else,
632
-
1. Let _lookupRegion_ be _region_.
633
-
1. Let _list_ be a List of unique calendar types in canonical form (<emu-xrefhref="#sec-calendar-types"></emu-xref>), sorted in descending preference of those in common use for date and time formatting in _lookupRegion_. The list is empty if no calendar preference data for _lookupRegion_ is available.
628
+
1. Let _region_ be RegionPreference(_loc_.[[Locale]]).
629
+
1. Let _list_ be a List of unique calendar types in canonical form (<emu-xrefhref="#sec-calendar-types"></emu-xref>), sorted in descending preference of those in common use for date and time formatting in _region_. The list is empty if no calendar preference data for _region_ is available.
634
630
1. If _list_ is empty, set _list_ to « *"gregory"* ».
635
631
1. Return CreateArrayFromList(_list_).
636
632
</emu-alg>
@@ -678,14 +674,8 @@ <h1>
678
674
<emu-alg>
679
675
1. If _loc_.[[HourCycle]] is not *undefined*, then
1. Let _preference_ be RegionPreference(_loc_.[[Locale]]).
682
-
1. Let _region_ be _preference_.[[Region]].
683
-
1. Let _regionOverride_ be _preference_.[[RegionOverride]].
684
-
1. If _regionOverride_ is not *undefined* and time data for _regionOverride_ are available, then
685
-
1. Let _lookupRegion_ be _regionOverride_.
686
-
1. Else,
687
-
1. Let _lookupRegion_ be _region_.
688
-
1. Let _list_ be a List of unique hour cycle identifiers, which must be lower case String values indicating either the 12-hour format (*"h11"*, *"h12"*) or the 24-hour format (*"h23"*, *"h24"*), sorted in descending preference of those in common use for date and time formatting in _lookupRegion_. The list is empty if no time data for _lookupRegion_ is available.
677
+
1. Let _region_ be RegionPreference(_loc_.[[Locale]]).
678
+
1. Let _list_ be a List of unique hour cycle identifiers, which must be lower case String values indicating either the 12-hour format (*"h11"*, *"h12"*) or the 24-hour format (*"h23"*, *"h24"*), sorted in descending preference of those in common use for date and time formatting in _region_. The list is empty if no time data for _region_ is available.
0 commit comments