Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #80 from FrankYFTang/CheckIsStructurallyValidLangu…
Browse files Browse the repository at this point in the history
…ageTag

Check code also match IsStructurallyValidLanguageTag
  • Loading branch information
FrankYFTang committed Jul 9, 2020
2 parents e772fc7 + f9036b1 commit 166859e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions biblio.json
Expand Up @@ -25,6 +25,11 @@
"aoid": "CanonicalizeUnicodeLocaleId",
"id": "sec-canonicalizeunicodelocaleid"
},
{
"type": "op",
"aoid": "IsStructurallyValidLanguageTag",
"id": "sec-isstructurallyvalidlanguagetag"
},
{
"type": "op",
"aoid": "SupportedLocales",
Expand Down
4 changes: 2 additions & 2 deletions index.html
Expand Up @@ -1805,7 +1805,7 @@
display: none;
}
}
</style></head><body><div id="menu-toggle"></div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle"></span><a href="#intl-displaynames-objects" title="DisplayNames Objects"><span class="secnum">1</span> DisplayNames Objects</a><ol class="toc"><li><span class="item-toggle"></span><a href="#sec-intl-displaynames-abstracts" title="Abstract Operations for DisplayNames Objects"><span class="secnum">1.1</span> Abstract Operations for DisplayNames Objects</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-canonicalcodefordisplaynames" title="CanonicalCodeForDisplayNames ( type, code )"><span class="secnum">1.1.1</span> CanonicalCodeForDisplayNames ( <var>type</var>, <var>code</var> )</a></li></ol></li><li><span class="item-toggle"></span><a href="#sec-intl-displaynames-constructor" title="The Intl.DisplayNames Constructor"><span class="secnum">1.2</span> The Intl.DisplayNames Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames" title="Intl.DisplayNames ([ locales [ , options ]])"><span class="secnum">1.2.1</span> Intl.DisplayNames ([ <var>locales</var> [ , <var>options</var> ]])</a></li></ol></li><li><span class="item-toggle"></span><a href="#sec-properties-of-intl-displaynames-constructor" title="Properties of the Intl.DisplayNames Constructor"><span class="secnum">1.3</span> Properties of the Intl.DisplayNames Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames.prototype" title="Intl.DisplayNames.prototype"><span class="secnum">1.3.1</span> Intl.DisplayNames.prototype</a></li><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames.supportedLocalesOf" title="Intl.DisplayNames.supportedLocalesOf ( locales [, options ])"><span class="secnum">1.3.2</span> Intl.DisplayNames.supportedLocalesOf ( <var>locales</var> [, <var>options</var> ])</a></li><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames-internal-slots" title="Internal slots"><span class="secnum">1.3.3</span> Internal slots</a></li></ol></li><li><span class="item-toggle"></span><a href="#sec-properties-of-intl-displaynames-prototype-object" title="Properties of the Intl.DisplayNames Prototype Object"><span class="secnum">1.4</span> Properties of the Intl.DisplayNames Prototype Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames.prototype.constructor" title="Intl.DisplayNames.prototype.constructor"><span class="secnum">1.4.1</span> Intl.DisplayNames.prototype.constructor</a></li><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames.prototype-@@tostringtag" title="Intl.DisplayNames.prototype[ @@toStringTag ]"><span class="secnum">1.4.2</span> Intl.DisplayNames.prototype[ @@toStringTag ]</a></li><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames.prototype.of" title="Intl.DisplayNames.prototype.of( code )"><span class="secnum">1.4.3</span> Intl.DisplayNames.prototype.of( <var>code</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames.prototype.resolvedOptions" title="Intl.DisplayNames.prototype.resolvedOptions ()"><span class="secnum">1.4.4</span> Intl.DisplayNames.prototype.resolvedOptions ()</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-properties-of-intl-displaynames-instances" title="Properties of Intl.DisplayNames Instances"><span class="secnum">1.5</span> Properties of Intl.DisplayNames Instances</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version first">Stage 3 Draft / June 19, 2020</h1><h1 class="title">Intl.DisplayNames Proposal</h1>
</style></head><body><div id="menu-toggle"></div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle"></span><a href="#intl-displaynames-objects" title="DisplayNames Objects"><span class="secnum">1</span> DisplayNames Objects</a><ol class="toc"><li><span class="item-toggle"></span><a href="#sec-intl-displaynames-abstracts" title="Abstract Operations for DisplayNames Objects"><span class="secnum">1.1</span> Abstract Operations for DisplayNames Objects</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-canonicalcodefordisplaynames" title="CanonicalCodeForDisplayNames ( type, code )"><span class="secnum">1.1.1</span> CanonicalCodeForDisplayNames ( <var>type</var>, <var>code</var> )</a></li></ol></li><li><span class="item-toggle"></span><a href="#sec-intl-displaynames-constructor" title="The Intl.DisplayNames Constructor"><span class="secnum">1.2</span> The Intl.DisplayNames Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames" title="Intl.DisplayNames ([ locales [ , options ]])"><span class="secnum">1.2.1</span> Intl.DisplayNames ([ <var>locales</var> [ , <var>options</var> ]])</a></li></ol></li><li><span class="item-toggle"></span><a href="#sec-properties-of-intl-displaynames-constructor" title="Properties of the Intl.DisplayNames Constructor"><span class="secnum">1.3</span> Properties of the Intl.DisplayNames Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames.prototype" title="Intl.DisplayNames.prototype"><span class="secnum">1.3.1</span> Intl.DisplayNames.prototype</a></li><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames.supportedLocalesOf" title="Intl.DisplayNames.supportedLocalesOf ( locales [, options ])"><span class="secnum">1.3.2</span> Intl.DisplayNames.supportedLocalesOf ( <var>locales</var> [, <var>options</var> ])</a></li><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames-internal-slots" title="Internal slots"><span class="secnum">1.3.3</span> Internal slots</a></li></ol></li><li><span class="item-toggle"></span><a href="#sec-properties-of-intl-displaynames-prototype-object" title="Properties of the Intl.DisplayNames Prototype Object"><span class="secnum">1.4</span> Properties of the Intl.DisplayNames Prototype Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames.prototype.constructor" title="Intl.DisplayNames.prototype.constructor"><span class="secnum">1.4.1</span> Intl.DisplayNames.prototype.constructor</a></li><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames.prototype-@@tostringtag" title="Intl.DisplayNames.prototype[ @@toStringTag ]"><span class="secnum">1.4.2</span> Intl.DisplayNames.prototype[ @@toStringTag ]</a></li><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames.prototype.of" title="Intl.DisplayNames.prototype.of( code )"><span class="secnum">1.4.3</span> Intl.DisplayNames.prototype.of( <var>code</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-Intl.DisplayNames.prototype.resolvedOptions" title="Intl.DisplayNames.prototype.resolvedOptions ()"><span class="secnum">1.4.4</span> Intl.DisplayNames.prototype.resolvedOptions ()</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-properties-of-intl-displaynames-instances" title="Properties of Intl.DisplayNames Instances"><span class="secnum">1.5</span> Properties of Intl.DisplayNames Instances</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version first">Stage 3 Draft / July 9, 2020</h1><h1 class="title">Intl.DisplayNames Proposal</h1>
<emu-biblio href="./biblio.json"></emu-biblio>
<emu-clause id="intl-displaynames-objects">
<h1><span class="secnum">1</span>DisplayNames Objects</h1>
Expand Down Expand Up @@ -1878,7 +1878,7 @@ <h1><span class="secnum">1.1.1</span>CanonicalCodeForDisplayNames ( <var>type</v
The CanonicalCodeForDisplayNames abstract operation is called with arguments <var>type</var>, and <var>code</var>. It verifies that the <var>code</var> argument represents a well-formed code according to the <var>type</var> argument and returns the case-regularized form of the <var>code</var>. The algorithm refers to <a href="https://www.unicode.org/reports/tr35/#Identifiers">UTS 35's Unicode Language and Locale Identifiers grammar</a>. The following steps are taken:

</p>
<emu-alg><ol><li>If <var>type</var> is <code>"language"</code>, then<ol><li>If <var>code</var> does not matches the <code>unicode_language_id</code> production, throw a <emu-val>RangeError</emu-val> exceptipon.</li><li>Set <var>code</var> to <emu-xref aoid="CanonicalizeUnicodeLocaleId"><a href="https://tc39.github.io/ecma402/#sec-canonicalizeunicodelocaleid">CanonicalizeUnicodeLocaleId</a></emu-xref>(<var>code</var>).</li><li>Return <var>code</var>.</li></ol></li><li>If <var>type</var> is <code>"region"</code>, then<ol><li>If <var>code</var> does not matches the <code>unicode_region_subtag</code> production, throw a <emu-val>RangeError</emu-val> exceptipon.</li><li>Let <var>code</var> be the result of mapping <var>code</var> to upper case as described in <emu-xref href="#sec-case-sensitivity-and-case-mapping"><a href="https://tc39.github.io/ecma402/#sec-case-sensitivity-and-case-mapping">6.1</a></emu-xref>.</li><li>Return <var>code</var>.</li></ol></li><li>If <var>type</var> is <code>"script"</code>, then<ol><li>If <var>code</var> does not matches the <code>unicode_script_subtag</code> production, throw a <emu-val>RangeError</emu-val> exceptipon.</li><li>Let <var>code</var> be the result of mapping the first character in <var>code</var> to upper case, and mapping the second, third and fourth character in <var>code</var> to lower case, as described in <emu-xref href="#sec-case-sensitivity-and-case-mapping"><a href="https://tc39.github.io/ecma402/#sec-case-sensitivity-and-case-mapping">6.1</a></emu-xref>.</li><li>Return <var>code</var>.</li></ol></li><li>Assert: <var>type</var> is <code>"currency"</code></li><li>If !&nbsp;<emu-xref aoid="IsWellFormedCurrencyCode"><a href="https://tc39.github.io/ecma402/#sec-iswellformedcurrencycode">IsWellFormedCurrencyCode</a></emu-xref>(<var>code</var>) is <emu-val>false</emu-val>, throw a <emu-val>RangeError</emu-val> exceptipon.</li><li>Let <var>code</var> be the result of mapping <var>code</var> to upper case as described in <emu-xref href="#sec-case-sensitivity-and-case-mapping"><a href="https://tc39.github.io/ecma402/#sec-case-sensitivity-and-case-mapping">6.1</a></emu-xref>.</li><li>Return <var>code</var>.
<emu-alg><ol><li>If <var>type</var> is <code>"language"</code>, then<ol><li>If <var>code</var> does not matches the <code>unicode_language_id</code> production, throw a <emu-val>RangeError</emu-val> exceptipon.</li><li>If <emu-xref aoid="IsStructurallyValidLanguageTag"><a href="https://tc39.github.io/ecma402/#sec-isstructurallyvalidlanguagetag">IsStructurallyValidLanguageTag</a></emu-xref>(<var>code</var>) is <emu-val>false</emu-val>, throw a <emu-val>RangeError</emu-val> exception.</li><li>Set <var>code</var> to <emu-xref aoid="CanonicalizeUnicodeLocaleId"><a href="https://tc39.github.io/ecma402/#sec-canonicalizeunicodelocaleid">CanonicalizeUnicodeLocaleId</a></emu-xref>(<var>code</var>).</li><li>Return <var>code</var>.</li></ol></li><li>If <var>type</var> is <code>"region"</code>, then<ol><li>If <var>code</var> does not matches the <code>unicode_region_subtag</code> production, throw a <emu-val>RangeError</emu-val> exceptipon.</li><li>Let <var>code</var> be the result of mapping <var>code</var> to upper case as described in <emu-xref href="#sec-case-sensitivity-and-case-mapping"><a href="https://tc39.github.io/ecma402/#sec-case-sensitivity-and-case-mapping">6.1</a></emu-xref>.</li><li>Return <var>code</var>.</li></ol></li><li>If <var>type</var> is <code>"script"</code>, then<ol><li>If <var>code</var> does not matches the <code>unicode_script_subtag</code> production, throw a <emu-val>RangeError</emu-val> exceptipon.</li><li>Let <var>code</var> be the result of mapping the first character in <var>code</var> to upper case, and mapping the second, third and fourth character in <var>code</var> to lower case, as described in <emu-xref href="#sec-case-sensitivity-and-case-mapping"><a href="https://tc39.github.io/ecma402/#sec-case-sensitivity-and-case-mapping">6.1</a></emu-xref>.</li><li>Return <var>code</var>.</li></ol></li><li>Assert: <var>type</var> is <code>"currency"</code></li><li>If !&nbsp;<emu-xref aoid="IsWellFormedCurrencyCode"><a href="https://tc39.github.io/ecma402/#sec-iswellformedcurrencycode">IsWellFormedCurrencyCode</a></emu-xref>(<var>code</var>) is <emu-val>false</emu-val>, throw a <emu-val>RangeError</emu-val> exceptipon.</li><li>Let <var>code</var> be the result of mapping <var>code</var> to upper case as described in <emu-xref href="#sec-case-sensitivity-and-case-mapping"><a href="https://tc39.github.io/ecma402/#sec-case-sensitivity-and-case-mapping">6.1</a></emu-xref>.</li><li>Return <var>code</var>.
</li></ol></emu-alg>
</emu-clause>

Expand Down
1 change: 1 addition & 0 deletions spec.emu
Expand Up @@ -71,6 +71,7 @@ contributors: Google, Ecma International
<emu-alg>
1. If _type_ is `"language"`, then
1. If _code_ does not matches the `unicode_language_id` production, throw a *RangeError* exceptipon.
1. If IsStructurallyValidLanguageTag(_code_) is *false*, throw a *RangeError* exception.
1. Set _code_ to CanonicalizeUnicodeLocaleId(_code_).
1. Return _code_.
1. If _type_ is `"region"`, then
Expand Down

0 comments on commit 166859e

Please sign in to comment.