Comparing version 1.0.3 to 1.0.4
@@ -17,2 +17,4 @@ (function() { | ||
POEditorAPI.prototype.mapLangs = null; | ||
function POEditorAPI(options, callback) { | ||
@@ -29,2 +31,5 @@ this.apiToken = options.apiToken; | ||
} | ||
if (options.langs != null) { | ||
this.mapLangs = options.langs; | ||
} | ||
this.listProjects((function(_this) { | ||
@@ -31,0 +36,0 @@ return function(err, data) { |
@@ -17,4 +17,7 @@ (function() { | ||
POEditorDownloader.prototype.poeditor = null; | ||
function POEditorDownloader(poeditor, files, callback) { | ||
this.files = files; | ||
this.poeditor = poeditor; | ||
poeditor.listProjectLanguages((function(_this) { | ||
@@ -73,5 +76,9 @@ return function(err, data) { | ||
POEditorDownloader.prototype.merge = function(lang, terms, callback) { | ||
var content, data, dump, e, ext, file, fileObj, i, j, len, len1, mergedFile, mergedFiles, modifiedStrings, pathFragment, ref, ref1, term, termDir; | ||
var content, data, dump, e, ext, file, fileObj, i, j, len, len1, mapLang, mergedFile, mergedFiles, modifiedStrings, pathFragment, ref, ref1, term, termDir; | ||
modifiedStrings = 0; | ||
mergedFiles = []; | ||
mapLang = lang; | ||
if (_.has(this.poeditor.mapLangs, lang)) { | ||
mapLang = _.get(this.poeditor.mapLangs, lang); | ||
} | ||
for (termDir in terms) { | ||
@@ -82,3 +89,3 @@ mergedFile = null; | ||
fileObj = ref[i]; | ||
pathFragment = "" + termDir + path.sep + lang; | ||
pathFragment = "" + termDir + path.sep + mapLang; | ||
if (fileObj.path.indexOf(pathFragment) > -1) { | ||
@@ -85,0 +92,0 @@ mergedFile = fileObj; |
@@ -112,3 +112,3 @@ (function() { | ||
return function(err, data) { | ||
var forms, i, j, lang, langObj, len, len1, ref, results, results1, tasks, termObj, translates; | ||
var forms, i, j, lang, langObj, len, len1, mapLang, ref, results, results1, tasks, termObj, translates; | ||
if (err) { | ||
@@ -126,8 +126,12 @@ callback(err); | ||
tasks.push(lang); | ||
mapLang = lang; | ||
if (_.has(_this.poeditor.mapLangs, lang)) { | ||
mapLang = _.get(_this.poeditor.mapLangs, lang); | ||
} | ||
ref = _this.terms; | ||
for (j = 0, len1 = ref.length; j < len1; j++) { | ||
termObj = ref[j]; | ||
if (_.has(termObj, lang)) { | ||
if (_.has(termObj, mapLang)) { | ||
forms = []; | ||
forms.push(termObj[lang]); | ||
forms.push(termObj[mapLang]); | ||
translates.push({ | ||
@@ -134,0 +138,0 @@ term: { |
{ | ||
"name": "gulp-po", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Gulp extension for synchronizing translates from POEditor.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -50,2 +50,6 @@ Gulp-PO | ||
Optional parameters: | ||
- `langs`: Object of language mapping. You can map `key` to `val`, where `key` is original POEditor code, e.g. `zh-TW` to `zh` | ||
Example: | ||
@@ -56,3 +60,6 @@ | ||
apiToken: '19xf1dfbfy36b96f0ba9f7zd94a83d9e', | ||
project: 'ExampleProject' | ||
project: 'ExampleProject', | ||
langs: { | ||
'zh-TW': 'zh' | ||
} | ||
}; | ||
@@ -59,0 +66,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22300
618
77