Intl.NumberFormat (ESNext)
A polyfill for ESNext Intl.NumberFormat
and Number.prototype.toLocaleString
.
#
Installation- npm
- yarn
#
RequirementsThis package requires the following capabilities:
#
FeaturesEverything in the ES2020 Internationalization API spec (https://tc39.es/ecma402).
#
Usage#
Via polyfill.ioYou can use polyfill.io URL Builder to create a polyfill script tag for Intl.NumberFormat
. By default the created URL does not come with any locale data. In order to add locale data, append Intl.NumberFormat.~locale.<locale>
to your list of features. For example:
#
Simple#
Dynamic import + capability detection#
Supported Units#
Simple UnitsCurrently, the spec defines a list of sanctioned units as below.
#
Compound UnitsYou can specify X-per-Y
unit, where X
and Y
are sanctioned simple units (e.g. kilometer-per-hour
).
The library will choose the best-fit localized pattern to format this compound unit.