First brought up by @tyxla here: https://github.com/Automattic/wp-calypso/pull/28846#pullrequestreview-178381258
As we're moving to use @wordpress/i18n
over calypso-i18n
, numberFormat
is one of the tools that is holding us back, as it's still used by a lot of code. See e.g. this JP PR by @jeherve that removes the explicit i18n-calypso
dependency, but still retains it in its lockfile, as it's required transitively by @automattic/format-currency
.
It'd be great if we could replace usage of i18n-calypso's numberFormat
by Intl.NumberFormat
, which seems to be widely supported.
Note that the API (function signature) is quite different: e.g. Intl.NumberFormat
requires an explicit locale arg.
cc/ @Automattic/team-calypso
It'd be great if we could replace usage of i18n-calypso's numberFormat by Intl.NumberFormat
That's also the approach we took in Jetpack:
An alternative may be to bring this functionality to Core itself, as discussed here:
https://github.com/WordPress/gutenberg/issues/22628
While Core may not have much use for a function used to localize the display of currency amounts (this seems to be plugin territory), I think it'd be useful to have a general number formatting function there.
Most helpful comment
That's also the approach we took in Jetpack:
An alternative may be to bring this functionality to Core itself, as discussed here:
https://github.com/WordPress/gutenberg/issues/22628
While Core may not have much use for a function used to localize the display of currency amounts (this seems to be plugin territory), I think it'd be useful to have a general number formatting function there.