Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

v1.1.0 — Properly Resolve Parent Locales

Compare
Choose a tag to compare
@ericf ericf released this 05 Mar 00:24
· 24 commits to master since this release

In this release parent locales are now properly resolved and exposed in the output data.

The CLDR uses an algorithm to resolve locale data, but there are exceptions. The changes in this release leverage the data for the exceptional cases to now properly resolve a locale's parent locale.

Locale entries with a parent will now contain a parentLocale property. This can be used by code consuming the data this package outputs to accurately traverse the locale hierarchy. This is very useful since this package will de-duplicate data as much as possible.

Also, a change in this release now guarantees that all locales listed in the locales option will have entries in the output data.

The following example shows how the locale hierarchy is used to return the unique data:

var extractData = require('formatjs-extract-cldr-data');

var data = extractData({
    locales    : ['en-US', 'en-GB'],
    pluralRules: true
});

console.log(data); // =>

{ 'en-US': { locale: 'en-US', parentLocale: 'en' },
  'en-GB': { locale: 'en-GB', parentLocale: 'en-001' },
  'en-001': { locale: 'en-001', parentLocale: 'en' } },
  en: { locale: 'en', pluralRuleFunction: [Function] }

See: #4 for more details.