-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editorial: Clarify operations related to merging locale data #804
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,16 +170,24 @@ <h1> | |
<emu-clause id="sec-insert-unicode-extension-and-canonicalize" type="abstract operation"> | ||
<h1> | ||
InsertUnicodeExtensionAndCanonicalize ( | ||
_locale_: a Unicode canonicalized locale identifier, | ||
_extension_: a Unicode locale extension sequence, | ||
_locale_: a language tag, | ||
_attributes_: a List of Strings, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The thing I'm wondering about is what this gets us over the old version -- is it just so that InsertUnicodeExtensionAndCanonicalize can do in a more explicit way what this line from the old ApplyUnicodeExtensionsToLocale did?
If all the changes in ResolveLocale were just made to account for the change in the parameters to InsertUnicodeExtensionAndCanonicalize I feel like all else being equal leaving InsertUnicodeExtensionAndCanonicalize unchanged is better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That is a goal, but so is isolating construction of Unicode locale extension sequences to one place—and both calling algorithms already have a list of attributes (trivially in the case of ResolveLocale) and handle keywords one by one. I also foresee similar convergence between CanonicalizeUnicodeLocaleId and InsertUnicodeExtensionAndCanonicalize, although I'm not yet taking that step here.
No, I do also find that replacing iterative string concatenation in ResolveLocale with use of keyword Records increases its comprehensibility. For example, compare: -1. Let _supportedExtensionAddition_ be the string-concatenation of *"-"*, _key_, *"-"*, and _value_.
+1. Set _supportedKeyword_ to the Record { [[Key]]: _key_, [[Value]]: _value_ }. |
||
_keywords_: a List of Records, | ||
): a Unicode canonicalized locale identifier | ||
</h1> | ||
<dl class="header"> | ||
<dt>description</dt> | ||
<dd>It incorporates _extension_ into _locale_ and returns the canonicalized result.</dd> | ||
<dd>It incorporates _attributes_ and _keywords_ into _locale_ as a Unicode locale extension sequence and returns the canonicalized result.</dd> | ||
</dl> | ||
<emu-alg> | ||
1. Assert: _locale_ does not contain a Unicode locale extension sequence. | ||
1. Let _extension_ be *"-u"*. | ||
1. For each element _attr_ of _attributes_, do | ||
1. Set _extension_ to the string-concatenation of _extension_, *"-"*, and _attr_. | ||
1. For each Record { [[Key]], [[Value]] } _keyword_ of _keywords_, do | ||
1. Set _extension_ to the string-concatenation of _extension_, *"-"*, and _keyword_.[[Key]]. | ||
1. If _keyword_.[[Value]] is not the empty String, set _extension_ to the string-concatenation of _extension_, *"-"*, and _keyword_.[[Value]]. | ||
1. If _extension_ is *"-u"*, return CanonicalizeUnicodeLocaleId(_locale_). | ||
1. Let _privateIndex_ be StringIndexOf(_locale_, *"-x-"*, 0). | ||
1. If _privateIndex_ is ~not-found~, then | ||
1. Let _newLocale_ be the string-concatenation of _locale_ and _extension_. | ||
|
@@ -221,24 +229,25 @@ <h1> | |
1. If _r_.[[extension]] is not ~empty~, then | ||
1. Let _components_ be UnicodeExtensionComponents(_r_.[[extension]]). | ||
1. Let _keywords_ be _components_.[[Keywords]]. | ||
1. Let _supportedExtension_ be *"-u"*. | ||
1. Else, | ||
1. Let _keywords_ be a new empty List. | ||
1. Let _supportedKeywords_ be a new empty List. | ||
1. For each element _key_ of _relevantExtensionKeys_, do | ||
1. Let _keyLocaleData_ be _foundLocaleData_.[[<_key_>]]. | ||
1. Assert: _keyLocaleData_ is a List. | ||
1. Let _value_ be _keyLocaleData_[0]. | ||
1. Assert: _value_ is a String or _value_ is *null*. | ||
1. Let _supportedExtensionAddition_ be *""*. | ||
1. If _r_.[[extension]] is not ~empty~, then | ||
1. If _keywords_ contains an element whose [[Key]] is the same as _key_, then | ||
1. Let _entry_ be the element of _keywords_ whose [[Key]] is the same as _key_. | ||
1. Let _requestedValue_ be _entry_.[[Value]]. | ||
1. If _requestedValue_ is not the empty String, then | ||
1. If _keyLocaleData_ contains _requestedValue_, then | ||
1. Set _value_ to _requestedValue_. | ||
1. Set _supportedExtensionAddition_ to the string-concatenation of *"-"*, _key_, *"-"*, and _value_. | ||
1. Else if _keyLocaleData_ contains *"true"*, then | ||
1. Set _value_ to *"true"*. | ||
1. Set _supportedExtensionAddition_ to the string-concatenation of *"-"* and _key_. | ||
1. Let _supportedKeyword_ be ~empty~. | ||
1. If _keywords_ contains an element whose [[Key]] is _key_, then | ||
1. Let _entry_ be the element of _keywords_ whose [[Key]] is _key_. | ||
1. Let _requestedValue_ be _entry_.[[Value]]. | ||
1. If _requestedValue_ is not the empty String, then | ||
1. If _keyLocaleData_ contains _requestedValue_, then | ||
1. Set _value_ to _requestedValue_. | ||
1. Set _supportedKeyword_ to the Record { [[Key]]: _key_, [[Value]]: _value_ }. | ||
1. Else if _keyLocaleData_ contains *"true"*, then | ||
1. Set _value_ to *"true"*. | ||
1. Set _supportedKeyword_ to the Record { [[Key]]: _key_, [[Value]]: *""* }. | ||
1. Assert: _options_ has a field [[<_key_>]]. | ||
1. Let _optionsValue_ be _options_.[[<_key_>]]. | ||
1. Assert: _optionsValue_ is a String, or _optionsValue_ is either *undefined* or *null*. | ||
|
@@ -251,13 +260,13 @@ <h1> | |
1. Set _optionsValue_ to *"true"*. | ||
1. If SameValue(_optionsValue_, _value_) is *false* and _keyLocaleData_ contains _optionsValue_, then | ||
1. Set _value_ to _optionsValue_. | ||
1. Set _supportedExtensionAddition_ to *""*. | ||
1. Set _supportedKeyword_ to ~empty~. | ||
1. If _supportedKeyword_ is not ~empty~, append _supportedKeyword_ to _supportedKeywords_. | ||
1. Set _result_.[[<_key_>]] to _value_. | ||
1. Set _supportedExtension_ to the string-concatenation of _supportedExtension_ and _supportedExtensionAddition_. | ||
1. If _supportedExtension_ is *"-u"*, then | ||
1. Set _result_.[[Locale]] to _foundLocale_. | ||
1. Else, | ||
1. Set _result_.[[Locale]] to InsertUnicodeExtensionAndCanonicalize(_foundLocale_, _supportedExtension_). | ||
1. If _supportedKeywords_ is not empty, then | ||
1. Let _supportedAttributes_ be a new empty List. | ||
1. Set _foundLocale_ to InsertUnicodeExtensionAndCanonicalize(_foundLocale_, _supportedAttributes_, _supportedKeywords_). | ||
1. Set _result_.[[locale]] to _foundLocale_. | ||
1. Return _result_. | ||
</emu-alg> | ||
</emu-clause> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a big fan of getting LanguageId into the name of this AO, given that the
unicode_language_id
is what it works with