broccoli-cldr-data
Advanced tools
Comparing version
{ | ||
"name": "broccoli-cldr-data", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "extracts cldr data to a broccoli directory", | ||
@@ -22,2 +22,5 @@ "main": "index.js", | ||
], | ||
"engines": { | ||
"node": ">= 4.0.0" | ||
}, | ||
"dependencies": { | ||
@@ -30,5 +33,7 @@ "broccoli-caching-writer": "^3.0.3", | ||
"devDependencies": { | ||
"broccoli": "^0.16.9", | ||
"broccoli-test-helper": "^1.1.0", | ||
"mocha": "^3.1.2" | ||
"mocha": "^3.1.2", | ||
"walk-sync": "^0.3.1" | ||
} | ||
} |
@@ -29,3 +29,3 @@ /* jshint node: true */ | ||
this.options = Object.assign( | ||
this._options = Object.assign( | ||
{ | ||
@@ -46,12 +46,7 @@ // formatjs-extract-cldr-data options | ||
CachingWriter.call(this, inputNodes, { | ||
annotation: this.options.annotation | ||
annotation: this._options.annotation | ||
}); | ||
if (Array.isArray(this.options.locales)) { | ||
this.options.locales = this.options.locales.map( | ||
function(localeName) { | ||
return this.normalizeLocale(localeName); | ||
}, | ||
this | ||
); | ||
if (Array.isArray(this._options.locales)) { | ||
this._options.locales = this._options.locales.map(locale => this.normalizeLocale(locale)); | ||
} | ||
@@ -71,10 +66,10 @@ } | ||
Plugin.prototype.writeFileSync = function(groupedByLanguage) { | ||
var options = this.options; | ||
var outputPath = path.join(this.outputPath, options.destDir); | ||
let options = this._options; | ||
let outputPath = path.join(this.outputPath, options.destDir); | ||
let prefix = options.moduleType.toLowerCase() === 'es6' ? 'export default' : 'module.exports ='; | ||
mkdirp.sync(outputPath); | ||
for (var language in groupedByLanguage) { | ||
var prefix = options.moduleType.toLowerCase() === 'es6' ? 'export default' : 'module.exports ='; | ||
var languageData = prefix + ' ' + serialize(groupedByLanguage[language]) + ';'; | ||
for (let language in groupedByLanguage) { | ||
let languageData = prefix + ' ' + serialize(groupedByLanguage[language]) + ';'; | ||
@@ -88,12 +83,12 @@ fs.writeFileSync(path.join(outputPath, language.toLowerCase() + '.js'), options.prelude.concat(languageData), { | ||
Plugin.prototype.build = function() { | ||
var data = extractor({ | ||
locales: this.options.locales, | ||
pluralRules: this.options.pluralRules, | ||
relativeFields: this.options.relativeFields | ||
let data = extractor({ | ||
locales: this._options.locales, | ||
pluralRules: this._options.pluralRules, | ||
relativeFields: this._options.relativeFields | ||
}); | ||
var groupedByLanguage = Object.keys(data).reduce( | ||
function(ret, locale) { | ||
var lang = locale.split('-')[0]; | ||
var langData = ret[lang] || []; | ||
let groupedByLanguage = Object.keys(data).reduce( | ||
(ret, locale) => { | ||
let lang = locale.split('-')[0]; | ||
let langData = ret[lang] || []; | ||
ret[lang] = langData.concat(data[locale]); | ||
@@ -100,0 +95,0 @@ |
Sorry, the diff of this file is not supported yet
43591
4.16%4
100%82
-5.75%