@@ -10,18 +10,70 @@ info: |
1010 3. Return loc.[[Locale]].
1111
1212 get Intl.Locale.prototype.baseName
13- 5. Return the substring of locale corresponding to the
14- language ["-" script] ["-" region] *("-" variant)
15- subsequence of the langtag grammar.
13+ 3. Return GetLocaleBaseName(_loc_.[[Locale]]).
14+
15+ GetLocaleBaseName
16+ 2. Return the longest prefix of _locale_ matched by the
17+ <code>unicode_language_id</code> Unicode locale nonterminal.
1618
1719 get Intl.Locale.prototype.language
18- 4. Return the substring of locale corresponding to the language production.
20+ 3. Return GetLocaleLanguage(_loc_.[[Locale]]).
21+
22+ GetLocaleLanguage
23+ 1. Let _baseName_ be GetLocaleBaseName(_locale_).
24+ 2. Assert: The first subtag of _baseName_ can be matched by the
25+ <code>unicode_language_subtag</code> Unicode locale nonterminal.
26+ 3. Return the first subtag of _baseName_.
1927
2028 get Intl.Locale.prototype.script
21- 7. Return the substring of locale corresponding to the script production.
29+ 3. Return GetLocaleScript(_loc_.[[Locale]]).
30+
31+ GetLocaleScript
32+ 1. Let _baseName_ be GetLocaleBaseName(_locale_).
33+ 2. Assert: _baseName_ contains at most one subtag that can be matched by the
34+ <code>unicode_script_subtag</code> Unicode locale nonterminal.
35+ 3. If _baseName_ contains a subtag matched by the
36+ <code>unicode_script_subtag</code> Unicode locale nonterminal, return
37+ that subtag.
38+ 4. Return *undefined*.
2239
2340 get Intl.Locale.prototype.region
24- 7. Return the substring of locale corresponding to the region production.
41+ 3. Return GetLocaleRegion(_loc_.[[Locale]]).
42+
43+ GetLocaleRegion
44+ 1. Let _baseName_ be GetLocaleBaseName(_locale_).
45+ 2. NOTE: A <code>unicode_region_subtag</code> subtag is only valid
46+ immediately after an initial <code>unicode_language_subtag</code> subtag,
47+ optionally with a single <code>unicode_script_subtag</code> subtag
48+ between them. In that position, <code>unicode_region_subtag</code> cannot
49+ be confused with any other valid subtag because all their productions are
50+ disjoint.
51+ 3. Assert: The first subtag of _baseName_ can be matched by the
52+ <code>unicode_language_subtag</code> Unicode locale nonterminal.
53+ 4. Let _baseNameTail_ be the suffix of _baseName_ following the first
54+ subtag.
55+ 5. Assert: _baseNameTail_ contains at most one subtag that can be matched by
56+ the <code>unicode_region_subtag</code> Unicode locale nonterminal.
57+ 6. If _baseNameTail_ contains a subtag matched by the
58+ <code>unicode_region_subtag</code> Unicode locale nonterminal, return
59+ that subtag.
60+ 7. Return *undefined*.
61+
62+ get Intl.Locale.prototype.variants
63+ 3. Return GetLocaleVariants(_loc_.[[Locale]]).
64+
65+ GetLocaleVariants
66+ 1. Let _baseName_ be GetLocaleBaseName(_locale_).
67+ 2. NOTE: Each subtag in _baseName_ that is preceded by *"-"* is either a
68+ <code>unicode_script_subtag</code>, <code>unicode_region_subtag</code>,
69+ or <code>unicode_variant_subtag</code>, but any substring matched by
70+ <code>unicode_variant_subtag</code> is strictly longer than any prefix
71+ thereof which could also be matched by one of the other productions.
72+ 3. Let _variants_ be the longest suffix of _baseName_ that starts with a
73+ *"-"* followed by a <emu-not-ref>substring</emu-not-ref> that is matched
74+ by the <code>unicode_variant_subtag</code> Unicode locale nonterminal. If
75+ there is no such suffix, return *undefined*.
76+ 4. Return the substring of _variants_ from 1.
2577
2678 get Intl.Locale.prototype.calendar
2779 3. Return loc.[[Calendar]].
@@ -47,14 +99,15 @@ features: [Intl.Locale]
4799---*/
48100
49101// Test all getters return the expected results.
50- var langtag = "de-latn-de-u-ca-gregory-co-phonebk-hc-h23-kf-true-kn-false-nu-latn" ;
102+ var langtag = "de-latn-de-fonipa-1996- u-ca-gregory-co-phonebk-hc-h23-kf-true-kn-false-nu-latn" ;
51103var loc = new Intl . Locale ( langtag ) ;
52104
53- assert . sameValue ( loc . toString ( ) , "de-Latn-DE-u-ca-gregory-co-phonebk-hc-h23-kf-kn-false-nu-latn" ) ;
54- assert . sameValue ( loc . baseName , "de-Latn-DE" ) ;
105+ assert . sameValue ( loc . toString ( ) , "de-Latn-DE-1996-fonipa- u-ca-gregory-co-phonebk-hc-h23-kf-kn-false-nu-latn" ) ;
106+ assert . sameValue ( loc . baseName , "de-Latn-DE-1996-fonipa " ) ;
55107assert . sameValue ( loc . language , "de" ) ;
56108assert . sameValue ( loc . script , "Latn" ) ;
57109assert . sameValue ( loc . region , "DE" ) ;
110+ assert . sameValue ( loc . variants , "1996-fonipa" ) ;
58111assert . sameValue ( loc . calendar , "gregory" ) ;
59112assert . sameValue ( loc . collation , "phonebk" ) ;
60113assert . sameValue ( loc . hourCycle , "h23" ) ;
@@ -72,6 +125,7 @@ var loc = new Intl.Locale(langtag, {
72125 language : "ja" ,
73126 script : "jpan" ,
74127 region : "jp" ,
128+ variants : "Hepburn" ,
75129 calendar : "japanese" ,
76130 collation : "search" ,
77131 hourCycle : "h24" ,
@@ -80,11 +134,12 @@ var loc = new Intl.Locale(langtag, {
80134 numberingSystem : "jpanfin" ,
81135} ) ;
82136
83- assert . sameValue ( loc . toString ( ) , "ja-Jpan-JP-u-ca-japanese-co-search-hc-h24-kf-false-kn-nu-jpanfin" ) ;
84- assert . sameValue ( loc . baseName , "ja-Jpan-JP" ) ;
137+ assert . sameValue ( loc . toString ( ) , "ja-Jpan-JP-hepburn- u-ca-japanese-co-search-hc-h24-kf-false-kn-nu-jpanfin" ) ;
138+ assert . sameValue ( loc . baseName , "ja-Jpan-JP-hepburn " ) ;
85139assert . sameValue ( loc . language , "ja" ) ;
86140assert . sameValue ( loc . script , "Jpan" ) ;
87141assert . sameValue ( loc . region , "JP" ) ;
142+ assert . sameValue ( loc . variants , "hepburn" ) ;
88143assert . sameValue ( loc . calendar , "japanese" ) ;
89144assert . sameValue ( loc . collation , "search" ) ;
90145assert . sameValue ( loc . hourCycle , "h24" ) ;
@@ -105,11 +160,12 @@ var loc = new Intl.Locale(langtag, {
105160 hourCycle : "h11" ,
106161} ) ;
107162
108- assert . sameValue ( loc . toString ( ) , "fr-Latn-CA-u-ca-gregory-co-standard-hc-h11-kf-kn-false-nu-latn" ) ;
109- assert . sameValue ( loc . baseName , "fr-Latn-CA" ) ;
163+ assert . sameValue ( loc . toString ( ) , "fr-Latn-CA-1996-fonipa- u-ca-gregory-co-standard-hc-h11-kf-kn-false-nu-latn" ) ;
164+ assert . sameValue ( loc . baseName , "fr-Latn-CA-1996-fonipa " ) ;
110165assert . sameValue ( loc . language , "fr" ) ;
111166assert . sameValue ( loc . script , "Latn" ) ;
112167assert . sameValue ( loc . region , "CA" ) ;
168+ assert . sameValue ( loc . variants , "1996-fonipa" ) ;
113169assert . sameValue ( loc . calendar , "gregory" ) ;
114170assert . sameValue ( loc . collation , "standard" ) ;
115171assert . sameValue ( loc . hourCycle , "h11" ) ;
@@ -129,6 +185,7 @@ assert.sameValue(loc.baseName, "und");
129185assert . sameValue ( loc . language , "und" ) ;
130186assert . sameValue ( loc . script , undefined ) ;
131187assert . sameValue ( loc . region , undefined ) ;
188+ assert . sameValue ( loc . variants , undefined ) ;
132189
133190var loc = new Intl . Locale ( "und-US-u-co-emoji" ) ;
134191
@@ -137,6 +194,7 @@ assert.sameValue(loc.baseName, "und-US");
137194assert . sameValue ( loc . language , "und" ) ;
138195assert . sameValue ( loc . script , undefined ) ;
139196assert . sameValue ( loc . region , "US" ) ;
197+ assert . sameValue ( loc . variants , undefined ) ;
140198if ( "collation" in loc ) {
141199 assert . sameValue ( loc . collation , "emoji" ) ;
142200}
0 commit comments