Package Exports
- @formatjs/intl-relativetimeformat
- @formatjs/intl-relativetimeformat/dist/locale-data/de
- @formatjs/intl-relativetimeformat/dist/locale-data/en
- @formatjs/intl-relativetimeformat/dist/locale-data/en.js
- @formatjs/intl-relativetimeformat/dist/locale-data/es
- @formatjs/intl-relativetimeformat/dist/locale-data/et
- @formatjs/intl-relativetimeformat/dist/locale-data/fr
- @formatjs/intl-relativetimeformat/dist/locale-data/ja.js
- @formatjs/intl-relativetimeformat/dist/locale-data/ru
- @formatjs/intl-relativetimeformat/dist/locale-data/sr
- @formatjs/intl-relativetimeformat/dist/locale-data/sv
- @formatjs/intl-relativetimeformat/polyfill
- @formatjs/intl-relativetimeformat/polyfill-locales
- @formatjs/intl-relativetimeformat/polyfill.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@formatjs/intl-relativetimeformat) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Intl RelativeTimeFormat
A spec-compliant polyfill/ponyfill for Intl.RelativeTimeFormat fully tested by the official ECMAScript Conformance test suite
Installation
npm install @formatjs/intl-relativetimeformat
Requirements
This package requires the following capabilities:
NOTE: formatToParts
only works on Node 10+ due to lack of Intl.NumberFormat.prototype.formatToParts
natively
Usage
To use the polyfill, just import it to make sure that a fully functional Intl.RelativeTimeFormat is available in your environment:
import '@formatjs/intl-relativetimeformat/polyfill'
If Intl.RelativeTimeFormat already exists, the polyfill will not be loaded.
To use this as a ponyfill:
import IntlRelativeTimeFormat from '@formatjs/intl-relativetimeformat'
By default, this library comes with en
data. To load additional locale, you can include them on demand:
import '@formatjs/intl-relativetimeformat/polyfill';
import '@formatjs/intl-relativetimeformat/dist/locale-data/de'; // Add locale data for de
If you want to polyfill all locales (e.g for Node):
import '@formatjs/intl-relativetimeformat/polyfill-locales'
Tests
This library is fully test262-compliant.
License
This software is free to use under the Yahoo! Inc. BSD license. See the [LICENSE file][license] for license text and copyright information.