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

Change the ref grammar from RFC5646 to UTS35 #67

Merged
merged 4 commits into from
Jan 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 30 additions & 31 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,48 @@ <h1>The Intl.Locale Constructor</h1>
<emu-clause id="sec-apply-options-to-tag" aoid=ApplyOptionsToTag>
<h1>ApplyOptionsToTag( _tag_, _options_ )</h1>
<p>
The following algorithm refers to <a href="https://tools.ietf.org/html/rfc5646#section-2.1">RFC 5646's Language-Tag grammar</a>.
The following algorithm refers to <a href="https://www.unicode.org/reports/tr35/#Identifiers">UTS 35's Unicode Language and Locale Identifiers grammar</a>.
</p>

<emu-alg>
1. Assert: Type(_tag_) is String.
1. If IsStructurallyValidLanguageTag(_tag_) is *false*, throw a *RangeError* exception.
1. Let _language_ be ? GetOption(_options_, `"language"`, `"string"`, *undefined*, *undefined*).
1. If _language_ is not *undefined*, then
1. If _language_ does not match the `language` production, throw a *RangeError* exception.
1. If _language_ matches the `grandfathered` production, throw a *RangeError* exception.
1. Let _script_ be ? GetOption(_options_, `"script"`, `"string"`, *undefined*, *undefined*).
1. If _language_ does not match the `unicode_language_subtag` production, throw a *RangeError* exception.
1. Let _script_ be ? GetOption(_options_, `"unicode_script_subtag"`, `"string"`, *undefined*, *undefined*).
1. If _script_ is not *undefined*, then
1. If _script_ does not match the `script` production, throw a *RangeError* exception.
1. If _script_ does not match the `unicode_script_subtag` production, throw a *RangeError* exception.
1. Let _region_ be ? GetOption(_options_, `"region"`, `"string"`, *undefined*, *undefined*).
1. If _region_ is not *undefined*, then
1. If _region_ does not match the `region` production, throw a *RangeError* exception.
1. If _region_ does not match the `unicode_region_subtag` production, throw a *RangeError* exception.
1. Set _tag_ to CanonicalizeLanguageTag(_tag_).
1. If _language_ is not *undefined*,
1. Assert: _tag_ matches the `langtag` production.
1. Set _tag_ to _tag_ with the substring corresponding to the `language` production replaced by the string _language_.
1. Assert: _tag_ matches the `unicode_locale_id` production.
1. Set _tag_ to _tag_ with the substring corresponding to the `unicode_language_subtag` production replaced by the string _language_.
1. If _script_ is not *undefined*, then
1. If _tag_ does not contain a `script` production, then
1. Set _tag_ to the concatenation of the `language` production of _tag_, `"-"`, _script_, and the rest of _tag_.
1. If _tag_ does not contain a `unicode_script_subtag` production, then
1. Set _tag_ to the concatenation of the `unicode_language_subtag` production of _tag_, `"-"`, _script_, and the rest of _tag_.
1. Else,
1. Set _tag_ to _tag_ with the substring corresponding to the `script` production replaced by the string _script_.
1. Set _tag_ to _tag_ with the substring corresponding to the `unicode_script_subtag` production replaced by the string _script_.
1. If _region_ is not *undefined*, then
1. If _tag_ does not contain a `region` production, then
1. Set _tag_ to the concatenation of the `language` production of _tag_, the substring corresponding to the `"-" script` production if present, `"-"`, _region_, and the rest of _tag_.
1. If _tag_ does not contain a `unicode_region_subtag` production, then
1. Set _tag_ to the concatenation of the `unicode_language_subtag` production of _tag_, the substring corresponding to the `"-" unicode_script_subtag` production if present, `"-"`, _region_, and the rest of _tag_.
1. Else,
1. Set _tag_ to _tag_ with the substring corresponding to the `region` production replaced by the string _region_.
1. Set _tag_ to _tag_ with the substring corresponding to the `unicode_region_subtag` production replaced by the string _region_.
1. Return CanonicalizeLanguageTag(_tag_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-apply-unicode-extension-to-tag" aoid=ApplyUnicodeExtensionToTag>
<h1>ApplyUnicodeExtensionToTag( _tag_, _options_, _relevantExtensionKeys_ )</h1>
<p>
The following algorithm refers to <a href="https://tools.ietf.org/html/rfc5646#section-2.1">RFC 5646's Language-Tag grammar</a>.
The following algorithm refers to <a href="https://www.unicode.org/reports/tr35/#Identifiers">UTS 35's Unicode Language and Locale Identifiers grammar</a>.
</p>

<emu-alg>
1. Assert: Type(_tag_) is String.
1. Assert: _tag_ matches the `langtag` production.
1. Assert: _tag_ matches the `unicode_locale_id` production.
1. If _tag_ contains a substring that is a Unicode locale extension sequence, then
1. Let _extension_ be the String value consisting of the first substring of _tag_ that is a Unicode locale extension sequence.
1. Let _components_ be ! UnicodeExtensionComponents(_extension_).
Expand Down Expand Up @@ -142,13 +141,13 @@ <h1>InsertUnicodeExtension( _locale_, _extension_ )</h1>
The InsertUnicodeExtension abstract operation inserts _extension_, which must be a Unicode locale extension sequence, into _locale_, which must be a String value with a structurally valid and canonicalized BCP 47 language tag. The following steps are taken:
</p>
<p>
The following algorithm refers to <a href="https://tools.ietf.org/html/rfc5646#section-2.1">RFC 5646's Language-Tag grammar</a>.
The following algorithm refers to <a href="https://www.unicode.org/reports/tr35/#Identifiers">UTS 35's Unicode Language and Locale Identifiers grammar</a>.
</p>

<emu-alg>
1. Assert: _locale_ does not contain a substring that is a Unicode locale extension sequence.
1. Assert: _extension_ is a Unicode extension sequence.
1. Assert: _tag_ matches the `langtag` production.
1. Assert: _tag_ matches the `unicode_locale_id` production.
1. Let _privateIndex_ be ! Call(%StringProto_indexOf%, _locale_, &laquo; `"-x-"` &raquo;).
1. If _privateIndex_ = -1, then
1. Let _locale_ be the concatenation of _locale_ and _extension_.
Expand All @@ -165,7 +164,7 @@ <h1>InsertUnicodeExtension( _locale_, _extension_ )</h1>
<h1>Intl.Locale( _tag_ [, _options_] )</h1>

<p>
The following algorithm refers to <a href="https://tools.ietf.org/html/rfc5646#section-2.1">RFC 5646's Language-Tag grammar</a>.
The following algorithm refers to <a href="https://www.unicode.org/reports/tr35/#Identifiers">UTS 35's Unicode Language and Locale Identifiers grammar</a>.

When the *Intl.Locale* function is called with an argument _tag_ and an optional argument _options_, the following steps are taken:
</p>
Expand Down Expand Up @@ -315,14 +314,14 @@ <h1>Intl.Locale.prototype.toString ()</h1>

<emu-clause id="sec-Intl.Locale.prototype.baseName">
<h1>get Intl.Locale.prototype.baseName</h1>
<p>`Intl.Locale.prototype.baseName` is an accessor property whose set accessor function is *undefined*. The following algorithm refers to <a href="https://tools.ietf.org/html/rfc5646#section-2.1">RFC 5646's Language-Tag grammar</a>. Its get accessor function performs the following steps:</p>
<p>`Intl.Locale.prototype.baseName` is an accessor property whose set accessor function is *undefined*. The following algorithm refers to <a href="https://www.unicode.org/reports/tr35/#Identifiers">UTS 35's Unicode Language and Locale Identifiers grammar</a>. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _loc_ be the *this* value.
1. If Type(_loc_) is not Object or _loc_ does not have an [[InitializedLocale]] internal slot, then
1. Throw a *TypeError* exception.
1. Let _locale_ be _loc_.[[Locale]].
1. If _locale_ does not match the `langtag` production, return _locale_.
1. Return the substring of _locale_ corresponding to the `language ["-" script] ["-" region] *("-" variant)` subsequence of the `langtag` grammar.
1. If _locale_ does not match the `unicode_locale_id` production, return _locale_.
1. Return the substring of _locale_ corresponding to the `language ["-" script] ["-" region] *("-" variant)` subsequence of the `unicode_language_id` grammar.
</emu-clause>

<emu-clause id="sec-Intl.Locale.prototype.calendar">
Expand Down Expand Up @@ -395,42 +394,42 @@ <h1>get Intl.Locale.prototype.numberingSystem</h1>

<emu-clause id="sec-Intl.Locale.prototype.language">
<h1>get Intl.Locale.prototype.language</h1>
<p>`Intl.Locale.prototype.language` is an accessor property whose set accessor function is *undefined*. The following algorithm refers to <a href="https://tools.ietf.org/html/rfc5646#section-2.1">RFC 5646's Language-Tag grammar</a>. Its get accessor function performs the following steps:</p>
<p>`Intl.Locale.prototype.language` is an accessor property whose set accessor function is *undefined*. The following algorithm refers to <a href="https://www.unicode.org/reports/tr35/#Identifiers">UTS 35's Unicode Language and Locale Identifiers grammar</a>. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _loc_ be the *this* value.
1. If Type(_loc_) is not Object or _loc_ does not have an [[InitializedLocale]] internal slot, then
1. Throw a *TypeError* exception.
1. Let _locale_ be _loc_.[[Locale]].
1. Assert: _locale_ matches the `langtag` production.
1. Return the substring of _locale_ corresponding to the `language` production.
1. Assert: _locale_ matches the `unicode_locale_id` production.
1. Return the substring of _locale_ corresponding to the `unicode_language_subtag` production.
</emu-alg>
</emu-clause>

<emu-clause id="sec-Intl.Locale.prototype.script">
<h1>get Intl.Locale.prototype.script</h1>
<p>`Intl.Locale.prototype.script` is an accessor property whose set accessor function is *undefined*. The following algorithm refers to <a href="https://tools.ietf.org/html/rfc5646#section-2.1">RFC 5646's Language-Tag grammar</a>. Its get accessor function performs the following steps:</p>
<p>`Intl.Locale.prototype.script` is an accessor property whose set accessor function is *undefined*. The following algorithm refers to <a href="https://www.unicode.org/reports/tr35/#Identifiers">UTS 35's Unicode Language and Locale Identifiers grammar</a>. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _loc_ be the *this* value.
1. If Type(_loc_) is not Object or _loc_ does not have an [[InitializedLocale]] internal slot, then
1. Throw a *TypeError* exception.
1. Let _locale_ be _loc_.[[Locale]].
1. Assert: _locale_ matches the `langtag` production.
1. Assert: _locale_ matches the `unicode_locale_id` production.
1. If _locale_ does not contain the `["-" script]` sequence, return *undefined*.
1. Return the substring of _locale_ corresponding to the `script` production.
1. Return the substring of _locale_ corresponding to the `unicode_script_subtag` production.
</emu-alg>
</emu-clause>

<emu-clause id="sec-Intl.Locale.prototype.region">
<h1>get Intl.Locale.prototype.region</h1>
<p>`Intl.Locale.prototype.region` is an accessor property whose set accessor function is *undefined*. The following algorithm refers to <a href="https://tools.ietf.org/html/rfc5646#section-2.1">RFC 5646's Language-Tag grammar</a>. Its get accessor function performs the following steps:</p>
<p>`Intl.Locale.prototype.region` is an accessor property whose set accessor function is *undefined*. The following algorithm refers to <a href="https://www.unicode.org/reports/tr35/#Identifiers">UTS 35's Unicode Language and Locale Identifiers grammar</a>. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _loc_ be the *this* value.
1. If Type(_loc_) is not Object or _loc_ does not have an [[InitializedLocale]] internal slot, then
1. Throw a *TypeError* exception.
1. Let _locale_ be _loc_.[[Locale]].
1. Assert: _locale_ matches the `langtag` production.
1. Assert: _locale_ matches the `unicode_locale_id` production.
1. If _locale_ does not contain the `["-" region]` sequence, return *undefined*.
1. Return the substring of _locale_ corresponding to the `region` production.
1. Return the substring of _locale_ corresponding to the `unicode_region_subtag` production.
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down