v1.1.0 — Fixed Locale Data, Added `now` Option
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 aszh-Hant
which is not the same aszh
. - 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});