rxaviers / cldr-data-npm

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

New helper methods to iterate through the entire main and supplemental files #12

Closed rxaviers closed 9 years ago

rxaviers commented 9 years ago

On #3, a couple of methods have been defined to help to iterate through the locales. I am considering to improve (and also change) the previous API according to the below:

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

// List all locales: (no change compared to previous API)
cldrData.availableLocales.forEach(function(locale) {
  console.log(locale);
});

// Get the entire supplemental (new method)
cldrData.entireSupplemental();

// Get the entire main for certain locales (new method)
cldrData.entireMain("en", "en-GB", "pt-BR", ...)

// Get certain main file for all locales: (the previous .main() method has been deprecated)
var path = require("path");
cldrData.availableLocales.map(function(locale) {
  return cldrData(path.join("main", locale, "numbers"));
});

// Get the entire thing
cldrData.all();