ecma402
ecma402 copied to clipboard
LookupMatcher should retain Unicode extension keywords in DefaultLocale
The prose in https://tc39.es/ecma402/#sec-lookupmatcher says:
If the language tag of the request locale that led to the selected locale contained a Unicode locale extension sequence, then the returned record also contains an [[extension]] field whose value is the substring of the Unicode locale extension sequence within the request locale language tag.
However, the algorithm in that function does not retain the extensions when DefaultLocale is returned. This causes the following unexpected behavior (Chrome 92):
fFulfulde = new Intl.NumberFormat('ff-u-nu-adlm')
fFulfulde.format(123)
// Expected: "𞥑𞥒𞥓"
// Actual: "123"
CC @sven-oly @FrankYFTang
Be aware that DefaultLocale may also have -u-nu. Say "en-US-u-nu-Latn" or "th-TH-u-nu-Thai"
Be aware that DefaultLocale may also have -u-nu.
DefaultLocale doesn't contain any Unicode extensions per the definition in https://tc39.es/ecma402/#sec-internal-slots:
Language tags on the list must not have a Unicode locale extension sequence. The list must include the value returned by the DefaultLocale abstract operation (6.2.4), [...]
Discussion from 2021-09-09 TC39-TG2: https://github.com/tc39/ecma402/blob/master/meetings/notes-2021-09-09.md#lookupmatcher-should-retain-unicode-extension-keywords-in-defaultlocale
Conclusion: OK to move forward with this change; review the final spec text when ready.
Be aware that DefaultLocale may also have -u-nu. Say "en-US-u-nu-Latn" or "th-TH-u-nu-Thai"
If we reach a situation where DefaultLocale has extension keywords (which it currently does not), then I would think we should just merge the extension keywords, with keys in the input locale overriding conflicting keys in the default locale.
hum...
6.2.4 DefaultLocale ( )
The DefaultLocale abstract operation returns a String value representing the structurally valid (6.2.2) and canonicalized (6.2.3) Unicode BCP 47 locale identifier for the host environment's current locale.
Mention no such "no extension" requirement. If DefaultLocale() should not include exntension, then it should be changed to
6.2.4 DefaultLocale ( )
The DefaultLocale abstract operation returns a String value representing the **^unicode_language_id production of a^** structurally valid (6.2.2) and canonicalized (6.2.3) Unicode BCP 47 locale identifier for the host environment's current locale.
To be clear: DefaultLocale does not have Unicode extensions. It is always a baseName (LSRV). Therefore, if a locale has a Unicode extension sequence, but the baseName is not in availableLocales, it produces no conflict to replace the baseName of the input locale with the DefaultLocale, which only ever contains a baseName.