-
Notifications
You must be signed in to change notification settings - Fork 108
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
Normative: Add calendar and numberingSystem options #175
Conversation
This patch implements tests for the ECMA 402 PR at tc39/ecma402#175 It is based on the test test/intl402/Collator/10.1.1_19_c.js
Test262 tests: tc39/test262#1225 V8 implementation: https://chromium-review.googlesource.com/c/v8/v8/+/664762 |
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.
Seems to be very straight forward to add these new options.
Any other opinions here? Can this be merged? |
In particular, do you think we should go to TC39 with this change, or is it minor enough to merge it without that presentation? |
I think we can do this without any presentation, but let's loop in few more folks to get their feedback: |
I agree with @caridy |
@littledan do you want to merge this? |
spec/datetimeformat.html
Outdated
1. If _calendar_ is not *undefined*, set _calendar_ to ? ToString(_calendar_). | ||
1. Set _opt_.[[ca]] to _calendar_. | ||
1. Let _numberingSystem_ be ? Get(_options_, *"numberingSystem"*). | ||
1. If _numberingSystem_ is not *undefined*, set _numberingSystem_ to ? ToString(_numeringSystem_). |
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.
Typo: numeringSystem (and in the line below and in the equivalent lines for Intl.NumberFormat
.)
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.
@littledan can you update the PR to fix these typos?
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.
Fixed the typo, apologies for the delay.
01d962e
to
8283f55
Compare
This PR reached consensus at the November 2017 TC39 meeting, see notes. |
Nit: Instead of
The
(And we should change But probably more important than how to access and convert the new options: Currently all options-bag options seem to be validated in some way and invalid option values are rejected with an error, whereas invalid options from Unicode extensions are simply ignored (e.g. For example let's consider the "calendar" option:
But which "type" is meant here? The value of the "name" attribute of the For example |
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.
sounds good to me
Unfortunately I don't think ICU has an API for validating these sorts of things. I was thinking of the validation logic a bit like, things which were based on an open-ended name would be checked through Do you think it will be important for users to get a RangeError here? Does anyone remember the original intention with the current design for error checking? cc @NorbertLindenberg We reviewed this patch at the ECMA 402 meeting. At that time, I'd only skimmed @anba's comment and didn't realize the validation issue. I guess this patch isn't ready to merge until we make a decision on that question. |
As discussed on the ECMA402 call - we should only validate the options to be well-formed, just like we do for extension key values. |
8283f55
to
98bcc48
Compare
This patch allows calendar and numberingSystem to be specified in the options bag of the DateTimeFormat and NumberFormat constructors. One use case for these options would be, when working with locales which have two numbering systems and calendars in use--the UA default may be the non-Western one, but in some contexts, it may be appropriate to use the Western one. Currently, without the patch, it would be necessary to parse the BCP 47 language tag in the application, but Intl provides no library to do so. For example, this all occurs in this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1370086 This patch validates the calendar and numbering system by comparing them to the grammar allowed for Unicode extension tags, per the resolution documented at tc39#175 (comment) Related bug: tc39#105 . This patch leaves out "collation" because of a lack of clear use cases.
OK, the newly uploaded patch is based on validating the grammar, but not contents, of the calendar and numberFormat options. It does not address @anba's other canonicalization question, however. How does this seem? |
98bcc48
to
3925958
Compare
This patch allows calendar and numberingSystem to be specified in the options bag of the DateTimeFormat and NumberFormat constructors. One use case for these options would be, when working with locales which have two numbering systems and calendars in use--the UA default may be the non-Western one, but in some contexts, it may be appropriate to use the Western one. Currently, without the patch, it would be necessary to parse the BCP 47 language tag in the application, but Intl provides no library to do so. For example, this all occurs in this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1370086 This patch validates the calendar and numbering system by comparing them to the grammar allowed for Unicode extension tags, per the resolution documented at tc39#175 (comment) Related bug: tc39#105 . This patch leaves out "collation" because of a lack of clear use cases.
hmm, at first glance, |
This patch allows calendar and numberingSystem to be specified in the options bag of the DateTimeFormat and NumberFormat constructors. One use case for these options would be, when working with locales which have two numbering systems and calendars in use--the UA default may be the non-Western one, but in some contexts, it may be appropriate to use the Western one. Currently, without the patch, it would be necessary to parse the BCP 47 language tag in the application, but Intl provides no library to do so. For example, this all occurs in this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1370086 This patch validates the calendar and numbering system by comparing them to the grammar allowed for Unicode extension tags, per the resolution documented at tc39#175 (comment) Related bug: tc39#105 . This patch leaves out "collation" because of a lack of clear use cases.
1bda139
to
b8dde1f
Compare
- Convert calendar and numbering system to lowercase, analogously with canonicalizing language tags - Reference the Unicode grammar, to avoid the need to keep up to date with notational changes from upstream
I've rebased and updated the PR to follow @anba's suggestions above. The lowercase conversion is a really necessary bug fix IMO. Probably we need to add some additional test262 tests to verify. |
Ok, I am having some trouble understanding... Looking at the spec, the test and using the implementations I have a question. Here's a matrix of various inputs and qualities..
as a developer I find it hard to understand the logic behind these results.. why wouldn't you have a |
The problem for the last part is the caller asked for a "numeric" for year, but in en-u-ca-chinese calendar, the year is not a numeric value (not 1 , 2, 3, 4, in any numbering system), but a string name |
@FrankYFTang thanks... sorry, I still don't entirely understand. If there is a better venue to ask you these kinds of questions, let me know.. In the meantime, here are some more clarifying quesitons - sorry if they seem basic or something.. Does this mean that:
|
As the current spec, YES
YES, because the form is neither "numeric" nor "2-digit"
First, it may not ALWAYS output 'relatedYear'. It MAY output it, depending on the values in the options. |
Thanks @FrankYFTang that's very helpful. I still find it confusing as someone not yet deeply into this problem, but at least I kind of understand how it winds up here now! |
@bkardell and I had talked about this before filing the issue, and the case that I found surprising was where we actually had a var df = new Intl.DateTimeFormat("en-u-ca-chinese") [{"type":"month","value":"12"},{"type":"literal","value":"/"},{"type":"day","value":"21"},{"type":"literal","value":"/"},{"type":"relatedYear","value":"2019"}] This works the same in V8 and SpiderMonkey. @FrankYFTang wrote,
This is the part where I didn't quite understand the current spec. I guess this is because in ToLocalTime, the calendar calculation is independent of the format being output? So, even though we're just using a month/day/year format and there's no yearName, we still use relatedYear. Is that right? The motivation here is that 2019 is not the year in the Chinese calendar? If that's the case, then I'm a bit confused about why this display format exists in the locale database... |
The skeleton it asked inside ICU is "yMd" for this case, and the pattern is Feel free to file a CLDR ticket ask CLDR linguist to clarify the rationale. |
Thanks for explaining, @FrankYFTang |
…-case-sensitivity-and-case-mapping
Adding case to map values properly when mapping to lower case
My understanding is that we have tests for this. cc @caiolima, is this correct? |
This PR landed after |
This is a temporary revert commit for tc39#175 until a canonicalization for Unicode extensions are added through ResolveLocale. Ref tc39/proposal-intl-locale#96 This commit should be reverted along the proposed solution. Changes are simplified in this single commit to avoid reverting all the 7 original commits from tc39#175.
This patch allows calendar and numberingSystem to be specified in
the options bag of the DateTimeFormat and NumberFormat constructors.
One use case for these options would be, when working with locales
which have two numbering systems and calendars in use--the UA default
may be the non-Western one, but in some contexts, it may be appropriate
to use the Western one. Currently, without the patch, it would be
necessary to parse the BCP 47 language tag in the application, but Intl
provides no library to do so. For example, this all occurs in this bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=1370086
Related bug: #105 . This patch leaves out "collation" because of a lack
of clear use cases.