Comments (8)
The correct results are:
js> addIntlExtras(Intl) // Add Intl.Locale to Intl in SpiderMonkey shell
js> (new Intl.Locale("en-u-kf-true")).caseFirst
""
js> (new Intl.Locale("en-u-kf-mom")).caseFirst
"mom"
The caseFirst
result for "en-u-kf-true"
is the empty string, because the tag is first canonicalised to "en-u-kf"
per BCP 47 Language Tag to Unicode BCP 47 Locale Identifier and 3.2.1 Canonical Unicode Locale Identifiers which states:
Any type or tfield value "true" is removed.
from proposal-intl-locale.
I think this is a reasonable behavior tbh.
We verify that the input language identifier string is well formed while we verify that the options are valid.
We're consistent in that behavior.
Long time ago we talked about an option to validate the input string as well, but that never came to fruition.
from proposal-intl-locale.
then
What should the expected result of
(new Intl.Locale("en-u-kf-true")).caseFirst and
(new Intl.Locale("en-u-kf-mom")).caseFirst ?
from proposal-intl-locale.
(new Intl.Locale("en-u-kf-true")).caseFirst
undefined
(new Intl.Locale("en-u-kf-mom")).caseFirst
undefined
I'm not opposed to liberating options to be well-formed only, in which case we'd also accept caseFirst = "mom"
and just not apply it since it's not valid.
That would be forward compatible, but I'm not sure if consistency is more important than feedback to users.
The reason why I think the current subset makes sense (until we complete it) is that options come from developers, so throwing on well-formed, but invalid value makes sense.
langid strings come from some external sources, browser, system etc. If they contain errors, rejecting them should be last resort, because user can rarely do anything about it, and the dev usually cannot do anything.
from proposal-intl-locale.
(new Intl.Locale("en-u-kf-true")).caseFirst
undefined
(new Intl.Locale("en-u-kf-mom")).caseFirst
undefined
Why, according to the current spec, the result is not "true" and "mom" ? That is the part I try to understand.
I'm not opposed to liberating options to be well-formed only, in which case we'd also accept
caseFirst = "mom"
and just not apply it since it's not valid.
I am not lobbying for that. Just try to figure out what the current spec said.
That would be forward compatible, but I'm not sure if consistency is more important than feedback to users.
The reason why I think the current subset makes sense (until we complete it) is that options come from developers, so throwing on well-formed, but invalid value makes sense.
langid strings come from some external sources, browser, system etc. If they contain errors, rejecting them should be last resort, because user can rarely do anything about it, and the dev usually cannot do anything.
from proposal-intl-locale.
We last discussed this topic in #19 . There, we decided to validate simply the grammar, and not the contents, in these contexts. Applying that decision here, I think we should return "mom"
and "true"
, as the current specification does, while continuing to be more strict in the options bag. (EDIT: @anba has the correct answers below)
from proposal-intl-locale.
Based on my read of the current spec and @anba's description, it seems like the current spec is correct and the behavior is as expected.
Is it ok for me to close this issue?
from proposal-intl-locale.
reopen if needed!
from proposal-intl-locale.
Related Issues (20)
- Modified CanonicalizeLocaleList does not accept Intl.Locale instances when provided as the only argument HOT 1
- Using Unicode locale ID vs BCP 47 in our spec HOT 51
- Resolved value for Unicode extension values when "true" is removed? HOT 4
- Simplified the change to 2.1 CanonicalizeLocaleList HOT 3
- Docs(MDN) Documentation for Intl.Locale HOT 17
- Does hourCycle exist unconditionally? HOT 3
- Not all RFC 5646 production names updated HOT 3
- Move "get caseFirst" after "get calendar"
- Update references to match current UTS 35 spec HOT 11
- Use `type` production from UTS35
- Directly use unicode_language_id in "get baseName"
- Need to test for SameValue(r.[[kn]], "") in addition to SameValue(r.[[kn]], "true")
- CanonicalizeLanguageTag should remove duplicate attributes/keywords in a Unicode extension, consistent with Intl.Locale HOT 6
- Getting the default locale HOT 10
- Drop this proposal in favor of a more general user settings object HOT 6
- Spec is vague regarding internal data structure representation HOT 12
- Canonicalise Unicode extensions options added through ResolveLocale HOT 8
- CanonicalizeUnicodeLocaleId should only perform step 1 of "BCP 47 Language Tag to Unicode BCP 47 Locale Identifier" HOT 3
- Archive repository, redirect draft to ecma402 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proposal-intl-locale.