rxaviers / cldr-data-npm

Npm module for Unicode CLDR JSON data
MIT License
42 stars 28 forks source link

Provide way to iterate through all locales #3

Closed rxaviers closed 9 years ago

rxaviers commented 10 years ago

Suggestion:

var cldrData = require("cldr-data");

// Load main/<all locales>/numbers.json.
cldrData.forEachLocale(function(locale, mainData) {
  Cldr.load(mainData("numbers"));
});
rxaviers commented 10 years ago

Ref: https://github.com/rxaviers/cldr-data-downloader/issues/6

rxaviers commented 10 years ago

Slightly different implementation:

var cldrData = require("cldr-data");

// Load main/<all locales>/numbers.json.
cldrData.main("numbers").forEach( Cldr.load );

// or
cldrData.forEachMain(function(main) {
  Cldr.load(main("numbers"));
});

// List all locales:
cldrData.availableLocales.forEach(function(locale) {
  console.log(locale);
});