Intl Relativeformat Versions Save

Formats JavaScript dates to relative time strings (e.g., "3 hours ago").

v2.1.0

6 years ago
  • Add missing sourcemap files (#42, @pawsong)
  • fix: consuming using jsnext:main fails (#44, @atlanteh)
  • add support for short formats (#53, @dtm5011)
  • Update Travis CI settings (#55, @okuryu)

v2.0.0

6 years ago
  • Upgrade intl-messageformat to ^2.0.0 (#50, @jasonmit)

v1.3.0

8 years ago

This minor release upgrades the locale data to CLDR 28 and [email protected].

v1.2.0

8 years ago

This minor release simply upgrades to [email protected].

v1.1.0

9 years ago

This feature release fixes issues with the locale data—particularly with zh-Hant locales (#25)—plus adds support for more locales (#28), and support for passing a "now" has been added to the format() method (#26, @jbaudanza).

Fixed Locale Data

The locale data has been vastly improved in the following ways:

  • Added locale data for all leaf locales which differ from their root locale's data; e.g. zh-Hant-HK is not the same as zh-Hant which is not the same as zh.
  • Properly de-duplicate data for all CLDR locales by correctly traversing a locale's hierarchy of ancestor locales.
  • Added data for the following languages: aa, agq, bas, bh, ckb, dav, dje, dsb, dua, dv, dyo, ebu, ewo, guw, guz, hsb, ia, in, iu, iw, jbo, ji, jv, jw, kaj, kam, kcg, khq, ki, kln, kok, ksf, ku, lb, lu, luo, luy, mer, mfe, mgh, mo, mua, nah, nmg, no, nqo, nus, ny, pap, prg, qu, rn, rw, sbp, sh, sma, smi, smj, smn, sms, swc, syr, tk, tl, twq, vai, wa, wo, yav, yi, zgh

Improved Locale Resolution

This release also includes improvements for how locales are resolved. Here are some details of these changes:

  • If no extra locale data is loaded, the locale will always resolved to en.

  • If locale data is missing for a leaf locale like fr-FR, but there is data for the root, fr in this case, then its root will be used.

  • If there's data for the specified locale, then that locale will be resolved; i.e.,

    var rf = new IntlRelativeFormat('en-US');
    assert(rf.resolvedOptions().locale === 'en-US'); // true
    
  • The resolved locales are now normalized; e.g., en-us will resolve to: en-US.

Added now Option

A "now" can now be passed when calling the format() method to control what the date being formatted is relative to. Having this option improves testability, while also allowing format() to be a pure function and not rely on a temporal global value, Date.now().

var now = 1425839825400;
var rf  = new Intl.RelativeFormat();
rf.format(someDate, {now: now});

v1.0.3

9 years ago

This patch release actually fixes the issue brought up in https://github.com/yahoo/intl-messageformat/issues/90 so that the Browserify/Webpack output is compatible with ES3 environments. The previous release had .defaults in the transpiled CommonJS modules, the es6-module-transpiler has been updated to fix that, and this release contains those fixes.

v1.0.2

9 years ago

This patch release fixes the issue brought up in https://github.com/yahoo/intl-messageformat/issues/90 so that the Browserify/Webpack output is compatible with ES3 environments. Source maps for .min.js files have also been fixed so that they now include the actual source code.

v1.0.1

9 years ago

This patch release improves support for using Browserify or Webpack to bundle intl-relativeformat. Since the context of these tools is to bundle for the browser, this release will only include the English locale data in the bundle by default. (Previously the data for all locales would be included when bundling with Browserify or Webpack.)

When you need to support another locale in your app and you're using Browserify or Webpack, we recommend the following approach:

// app.js
var IntlRelativeFormat = window.IntlRelativeFormat = require('intl-relativeformat');
// ...
<script src="/app.bundle.js"></script>
<script src="/intl-relativeformat/dist/locale-data/fr.js"></script>

This will expose IntlRelativeFormat as a global object in the browser, allowing you to load the script for the locale data you need for the page or current request.

Propagate Original locales Value

Fixed issue #17 where the original locales value the user passed to the IntlRelativeFormat constructor was not being propagated to the internal IntlMessageFormat instances. Instead, only the resolved root locale was being propagated. This issue would arise when using the Intl.js polyfill.

Source Maps Improvements

This release also includes improvements to source maps, making debugging easier.

v1.0.0

9 years ago

Intl-relativeformat aims to provide a way to format different variations of relative time. You can use this package in the browser and on the server via Node.js.

This implementation is very similar to moment.js, in concept, although it provides only formatting features based on the Unicode CLDR locale data, an industry standard that supports more than 150 locales.