Intent to Ship: Intl.NumberFormat.prototype.formatToParts

63 views
Skip to first unread message

Josh Wolfe

unread,
Sep 10, 2017, 5:03:22 PM9/10/17
to v8-u...@googlegroups.com, blin...@chromium.org
# Contact emails

jwo...@igalia.com
litt...@chromium.org

# Spec

https://github.com/tc39/ecma402/pull/79

# Summary

Intl.NumberFormat.prototype.formatToParts() is scheduled to be added to the
EcmaScript Internationalization API specification (Ecma 402). It adds a
method
to format a number to a list of tokens and their types (e.g. minusSign,
integer,
decimal, fraction, currency, percentSign, etc). It is implemented and
disabled
by default by Firefox. v8 implemented it behind a flag. See also, the
corresponding DateTimeFormat feature here:
https://www.chromestatus.com/feature/6319456309477376

# Motivation

A web form may want to display a price like "$1,234.00" with the fractional
part ".00" in superscript and in a different color. If you use
Intl.NumberFormat.prototype.format(), you get a string, which you would then
need to parse to find the fractional part. However, the decimal separator is
locale dependent, so attempting to account for this variability somewhat
defeats the purpose of the locale-independent NumberFormat API. The
solution is
to expose the individual parts of the formatted string with tags to identify
each part's role in the overall representation.

# Interoperability risk

* Firefox: In development
* Edge: No public signals
* Safari: No public signals
* Web developers: No signals

# Compatibility risk

Low compatibility risk, as this feature is exposed through a new method
`Intl.NumberFormat.prototype.formatToParts`.

# Ongoing technical constraints

None

# Will this feature be supported on all six Blink platforms (Windows,
Mac, Linux, Chrome OS, Android, and Android WebView)?

Yes

# OWP launch tracking bug

https://bugs.chromium.org/p/v8/issues/detail?id=5244

# Link to entry on the Chrome Platform Status

https://www.chromestatus.com/feature/5686840812109824

jwo...@igalia.com

unread,
Sep 11, 2017, 3:18:23 PM9/11/17
to blink-dev, jwo...@igalia.com, v8-u...@googlegroups.com
Pardon my ignorance. I'll do my best to answer your questions.

> Is this actually done?

I don't know what you mean by "done". The implementation is done. See https://chromium-review.googlesource.com/c/v8/v8/+/529973

> If so, did it really go out in Chrome 61?

I don't know what you mean by "go out". It's not shipped or staged yet, but it's available if you run chrome with --js-flags="--harmony-number-format-to-parts".

On Monday, September 11, 2017 at 11:00:55 AM UTC-7, Joe Medley wrote:
Is this actually done? I can't tell. If so, did it really go out in Chrome 61?

Joe Medley | Technical Writer, Chrome DevRel | jme...@google.com | 816-678-7195
If an API's not documented it doesn't exist.



--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/429e4091-caab-1114-216b-62b2d858317e%40igalia.com.


Adam Klein

unread,
Sep 11, 2017, 5:32:20 PM9/11/17
to v8-users, blink-dev
I have the same question here as my latest question on the PluralRules thread: any idea why Firefox isn't shipping this (yet), given they have it implemented?

On Sun, Sep 10, 2017 at 2:03 PM, Josh Wolfe <jwo...@igalia.com> wrote:


--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
--- You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Ehrenberg

unread,
Sep 12, 2017, 5:35:38 PM9/12/17
to v8-u...@googlegroups.com, Zbigniew Braniecki (Gandalf), blink-dev
I asked Zbigniew Braniecki about the status of
Intl.NumberFormat.prototype.formatToParts and PluralRules, and he told
me,

> Both are ready and need to be exposed. We've been waiting for them to reach stage 4 to expose them to the Web
> NumberFormat.formatToParts is behind the flag - http://searchfox.org/mozilla-central/source/js/src/builtin/Intl.cpp#1639
> and PluralRules is exposed on mozIntl (which is our chrome-only API for UI internationalization that extends Intl API) - http://searchfox.org/mozilla-central/source/toolkit/components/mozintl/mozIntl.js#73
> With you guys having land both I think we can expose them now. I'm happy to work on the patch next week :)

In particular, Mozilla has been pushing these proposals for some time,
and has been held back by lack of buy-in from other browser vendors.

Dan
>> email to v8-users+u...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> --
> v8-users mailing list
> v8-u...@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-users+u...@googlegroups.com.

Daniel Ehrenberg

unread,
Sep 12, 2017, 5:50:47 PM9/12/17
to Joe Medley, Adam Klein, v8-users, blink-dev
Note that in 61, this feature was behind the
--js-flags=--harmony-number-format-to-parts command-line flag; it will
be added to about:flags (as part of the "experimental JavaScript
features" option) in an upcoming Canary, but is not presented that way
in the current Canary.

This is a V8 feature, so I'm not sure how to use OmahaProxy to verify
it directly. Here's how I verified that it was present in 61 behind
that command-line flag:

The current v8 version listed in OmahaProxy is 6.1.534.32 . If you
open a V8 checkout and do "git log 6.1.534", then contained in that
log is the commit with SHA-1 6c1e67f806d23ce23e398d3b210000349d1be267
, Change-ID I306dd1721cc00c5820b061f14c4b6866f8d938f6 which implements
this feature.

Dan

On Tue, Sep 12, 2017 at 4:41 PM, 'Joe Medley' via blink-dev
<blin...@chromium.org> wrote:
> I'm looking for confirmation that's it's behind a flag in 61. I don't take
> the status entries word for it. I look for a commit hash I can look up in
> OmahaProxy.
>
> Joe Medley | Technical Writer, Chrome DevRel | jme...@google.com |
> 816-678-7195
> If an API's not documented it doesn't exist.
>
>>> email to v8-users+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "blink-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to blink-dev+...@chromium.org.
>> To view this discussion on the web visit
>> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAEvLGcKm8OBEE-zp%2BsyhvC%3DVwQHFKXS3KCLjC8HYRXc%3Drg%2Bc5Q%40mail.gmail.com.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "blink-dev" group.
> To view this discussion on the web visit
> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAJUhtG-M-V0JZ7iwq5-7C4sr01McSLzc3Kr4bxa%3DGCkYovB6Kg%40mail.gmail.com.

Adam Klein

unread,
Sep 12, 2017, 7:55:21 PM9/12/17
to Daniel Ehrenberg, v8-users, Zbigniew Braniecki (Gandalf), blink-dev
Thanks, with that background this LGTM to ship.


>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> --
> v8-users mailing list
> v8-u...@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an

> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
Reply all
Reply to author
Forward
0 new messages