Socket
Socket
Sign inDemoInstall

gulp-po

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-po - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

86

lib/index.js

@@ -31,39 +31,59 @@ (function() {

case 'push':
POEditor.push(files, options, function(err, data) {
var details, i, lang, len;
if (err) {
callback(err);
return;
}
for (i = 0, len = data.length; i < len; i++) {
lang = data[i];
details = lang.details;
gutil.log("[" + lang.lang + "] Parsed: " + details.parsed + ", Added: " + details.added + ", Updated: " + details.updated);
}
return callback();
});
POEditor.push(files, options, (function(_this) {
return function(err, data) {
var details, file, i, j, lang, len, len1;
if (err) {
callback(err);
return;
}
for (i = 0, len = data.length; i < len; i++) {
lang = data[i];
details = lang.details;
gutil.log("[" + lang.lang + "] Parsed: " + details.parsed + ", Added: " + details.added + ", Updated: " + details.updated);
}
for (j = 0, len1 = files.length; j < len1; j++) {
file = files[j];
_this.push(file);
}
return callback();
};
})(this));
break;
case 'pull':
POEditor.pull(files, options, function(err, data) {
var i, lang, len;
if (err) {
callback(err);
return;
}
for (i = 0, len = data.length; i < len; i++) {
lang = data[i];
gutil.log("[" + lang.lang + "] Modified strings: " + lang.modified);
}
return callback();
});
POEditor.pull(files, options, (function(_this) {
return function(err, data) {
var file, i, j, lang, len, len1, ref;
if (err) {
callback(err);
return;
}
for (i = 0, len = data.length; i < len; i++) {
lang = data[i];
gutil.log("[" + lang.lang + "] Modified strings: " + lang.modified);
ref = lang.mergedFiles;
for (j = 0, len1 = ref.length; j < len1; j++) {
file = ref[j];
_this.push(file);
}
}
return callback();
};
})(this));
break;
case 'sync':
POEditor.sync(files, options, function(err, data) {
if (err) {
callback(err);
return;
}
gutil.log("Parsed: " + data.parsed + ", Added: " + data.added + ", Updated: " + data.updated);
return callback();
});
POEditor.sync(files, options, (function(_this) {
return function(err, data) {
var file, i, len;
if (err) {
callback(err);
return;
}
gutil.log("Parsed: " + data.parsed + ", Added: " + data.added + ", Updated: " + data.updated);
for (i = 0, len = files.length; i < len; i++) {
file = files[i];
_this.push(file);
}
return callback();
};
})(this));
}

@@ -70,0 +90,0 @@ };

@@ -72,4 +72,5 @@ (function() {

POEditorDownloader.prototype.merge = function(lang, terms, callback) {
var content, data, dump, e, ext, file, fileInfo, i, j, len, len1, mergedFile, modifiedStrings, pathFragment, ref, ref1, term, termDir;
var content, data, dump, e, ext, file, fileObj, i, j, len, len1, mergedFile, mergedFiles, modifiedStrings, pathFragment, ref, ref1, term, termDir;
modifiedStrings = 0;
mergedFiles = [];
for (termDir in terms) {

@@ -79,6 +80,6 @@ mergedFile = null;

for (i = 0, len = ref.length; i < len; i++) {
fileInfo = ref[i];
fileObj = ref[i];
pathFragment = "" + termDir + path.sep + lang;
if (fileInfo.path.indexOf(pathFragment) > -1) {
mergedFile = fileInfo.path;
if (fileObj.path.indexOf(pathFragment) > -1) {
mergedFile = fileObj;
}

@@ -89,7 +90,7 @@ }

}
ext = fileInfo.path.split(path.sep).slice(-1)[0].split('.')[1];
ext = mergedFile.path.split(path.sep).slice(-1)[0].split('.')[1];
try {
content = fs.readFileSync(mergedFile, 'utf-8');
content = mergedFile.contents.toString();
content = content.replace(/\t/g, ' ');
if (ext === 'neon') {
if (ext === 'neon' || ext === 'yml' || ext === 'yaml') {
file = yaml.safeLoad(content);

@@ -118,7 +119,9 @@ } else if (ext === 'json') {

dump = dump.replace(/\ \ /g, '\t');
fs.writeFileSync(mergedFile, dump);
mergedFile.contents = new Buffer(dump);
mergedFiles.push(mergedFile);
}
data = {
lang: lang,
modified: modifiedStrings
modified: modifiedStrings,
mergedFiles: mergedFiles
};

@@ -125,0 +128,0 @@ callback(null, data);

@@ -26,12 +26,12 @@ (function() {

function POEditorUploader(poeditor, files, callback) {
var content, dirName, e, ext, file, fileInfo, i, j, len, len1, ref, term, terms;
var content, dirName, e, ext, file, fileObj, i, j, len, len1, ref, term, terms;
this.poeditor = poeditor;
this.files = files;
for (i = 0, len = files.length; i < len; i++) {
fileInfo = files[i];
ext = fileInfo.path.split(path.sep).slice(-1)[0].split('.')[1];
fileObj = files[i];
ext = fileObj.path.split(path.sep).slice(-1)[0].split('.')[1];
try {
content = fs.readFileSync(fileInfo.path, 'utf-8');
content = fileObj.contents.toString();
content = content.replace(/\t/g, ' ');
if (ext === 'neon') {
if (ext === 'neon' || ext === 'yml' || ext === 'yaml') {
file = yaml.safeLoad(content);

@@ -48,4 +48,4 @@ } else if (ext === 'json') {

}
this.lang = fileInfo.path.split(path.sep).slice(-1)[0].split('.')[0];
dirName = fileInfo.path.split(path.sep).slice(-2)[0];
this.lang = fileObj.path.split(path.sep).slice(-1)[0].split('.')[0];
dirName = fileObj.path.split(path.sep).slice(-2)[0];
this.parents = [];

@@ -143,2 +143,6 @@ this.parents.push(dirName);

}
if (!translates.length) {
tasks = _.pull(tasks, lang);
continue;
}
results1.push(_this.poeditor.updateProjectLanguage(lang, translates, function(err, data) {

@@ -145,0 +149,0 @@ if (err) {

{
"name": "gulp-po",
"version": "1.0.2",
"version": "1.0.3",
"description": "Gulp extension for synchronizing translates from POEditor.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -16,4 +16,10 @@ Gulp-PO

Allowed actions: `push`, `pull`, `sync`
Allowed actions:
- `push`: Pushes all terms and translates to the POEditor server
- `pull`: Pulls all translates from the POEditor server and replace changed ones in files
- `sync`: Pushes all terms to the POEditor server
You can provide translate files in following formats: `JSON`, `YAML`, `NEON`
```js

@@ -31,5 +37,6 @@ var poConnector = require('gulp-po');

gulp.task('translates-push', function() {
return gulp.src('./translates/**/*.neon')
return gulp.src('./translates/**/*.json')
.pipe(pipes.createTranslatesPlumber())
.pipe(poConnector('push', options))
.pipe(gulp.dest('./translates/'))
});

@@ -36,0 +43,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc