tc39 / proposal-intl-relative-time

`Intl.RelativeTimeFormat` specification [draft]
http://tc39.github.io/proposal-intl-relative-time/
215 stars 24 forks source link

Allow to modify the numbering system through "nu"? #96

Closed anba closed 5 years ago

anba commented 6 years ago

V8 currently allows, contrary to the spec proposal, to modify the numbering system of the Intl.RelativeTimeFormatter.

For example new Intl.RelativeTimeFormat("en-u-nu-thai").format(1, "hour") returns "in ๑ hours" in V8 even though the current proposal requires to ignore "nu" and instead to return "in 1 hour".


Except that invalid "nu" values may crash V8, so don't try things like new Intl.RelativeTimeFormat("en-u-nu-foo").format(1, "hour") at home. :zipper_mouth_face:

littledan commented 5 years ago

This is a good point. I think we should add this feature. Let's discuss at the next Intl meeting. PRs welcome to help make this more concrete! cc @FrankYFTang

FrankYFTang commented 5 years ago

I think anab raise a good issue and it will be beneficial to clarify in the spec. "v8 currently allows, contrary to the spec proposal, to modify the numbering system of the Intl.RelativeTimeFormatter." - I do not see anywhere in the current proposal DISALLOW the use of "nu" in the locale, so I do not understand why you state it is "contrary to the spec proposal" HOW the object in each locale to format the date is not part of the proposal, from my understanding.

zbraniecki commented 5 years ago

I do not see anywhere in the current proposal DISALLOW the use of "nu" in the locale, so I do not understand why you state it is "contrary to the spec proposal" HOW the object in each locale to format the date is not part of the proposal, from my understanding.

I also don't see anything that would limit us to any particular numerical system. I think we should support nu UE and numberingSystem (in line with adding it to the `Intl.NumberFormat).

anba commented 5 years ago

ResolveLocale strips away any unsupported Unicode extension keys, so when InitializeRelativeTimeFormat calls it with an empty list for the relevantExtensionKeys parameter, the returned [[Locale]] (and [[DataLocale]]) no longer have a Unicode extension subtag. And that means the RelativeTimeFormat's internal NumberFormat object (InitializeRelativeTimeFormat, step 19) will always be created with a locale which no longer contains "nu".

gsathya commented 5 years ago

@anba is correct, nu should be ignored. V8 7.1 works fine; the nightly build has a known bug that should be fixed soon.

littledan commented 5 years ago

Well, I agree with @gsathya and @anba's interpretation of the current specification, but this doesn't mean that we shouldn't add the feature. It's on the agenda for the next Intl meeting.

littledan commented 5 years ago

OK, we agreed at the November 2018 Intl meeting to follow this option. Will follow up with a spec patch.

littledan commented 5 years ago

Closing due to #99