Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

i18next-conv

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18next-conv - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

.travis.yml

90

lib/gettextWrapper.js

@@ -13,2 +13,4 @@ var Gettext = require("node-gettext")

process: function(domain, source, target, options, callback) {
callback = cleanCallback(options, callback);
options = cleanOptions(options);
var ext = path.extname(source);

@@ -37,6 +39,4 @@

i18nextToGettext: function(domain, source, target, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
callback = cleanCallback(options, callback);
options = cleanOptions(options);

@@ -77,6 +77,4 @@ var self = this;

i18nextToGettextData: function(domain, source, target, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
callback = cleanCallback(options, callback);
options = cleanOptions(options);

@@ -88,5 +86,3 @@ var self = this;

var res = (path.extname(target) === '.po' || path.extname(target) === '.pot') ? GettextParser.po.compile(data) : GettextParser.mo.compile(data);
if (typeof callback === 'function') {
callback(err, res);
}
callback(err, res);
};

@@ -124,2 +120,4 @@ if (options.base) {

flattenI18nextJSON: function(source, options, callback) {
callback = cleanCallback(options, callback);
options = cleanOptions(options);
if (!options.quiet) console.log(('\n --> reading file from: ' + source));

@@ -129,5 +127,3 @@

if(err) {
if (typeof callback === 'function') {
callback(err);
}
callback(err);
return;

@@ -137,5 +133,3 @@ }

var flat = flatten.flatten(JSON.parse(body), options);
if (typeof callback === 'function') {
callback(null, flat);
}
callback(null, flat);
});

@@ -148,2 +142,4 @@ },

parseGettext: function(domain, data, options, callback) {
callback = cleanCallback(options, callback);
options = cleanOptions(options);
var out = {

@@ -159,2 +155,3 @@ "charset": "utf-8",

};
var ext = plurals.rules[domain.replace('_', '-').split('-')[0]];

@@ -229,5 +226,3 @@ var trans = {};

out["translations"] = trans;
if (typeof callback === 'function') {
callback(null, out);
}
callback(null, out);
},

@@ -264,6 +259,4 @@

gettextToI18next: function(domain, source, target, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
callback = cleanCallback(options, callback);
options = cleanOptions(options);

@@ -299,6 +292,4 @@ var self = this;

gettextToI18nextData: function(domain, source, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
callback = cleanCallback(options, callback);
options = cleanOptions(options);

@@ -333,5 +324,3 @@ var self = this;

var jsonData = JSON.stringify(json, null, 4);
if (typeof callback === 'function') {
callback(err, jsonData);
}
callback(err, jsonData);
});

@@ -346,3 +335,4 @@ });

var gt = new Gettext();
callback = cleanCallback(options, callback);
options = cleanOptions(options);
if (!options.quiet) console.log(('\n --> reading file from: ' + source));

@@ -352,6 +342,3 @@

if(err) {
if (typeof callback === 'function') {
callback(err);
}
callback(err);
return;

@@ -366,5 +353,3 @@ }

} else {
if (typeof callback === 'function'){
callback(null, gt.domains[gt._normalizeDomain(domain)] && gt.domains[gt._normalizeDomain(domain)].translations);
}
callback(null, gt.domains[gt._normalizeDomain(domain)] && gt.domains[gt._normalizeDomain(domain)].translations);
}

@@ -378,2 +363,4 @@ });

parseJSON: function(domain, data, options, callback) {
callback = cleanCallback(options, callback);
options = cleanOptions(options);
var separator = options.keyseparator || '##';

@@ -437,5 +424,3 @@

}
if (typeof callback === 'function'){
callback(null, json);
}
callback(null, json);
},

@@ -484,9 +469,24 @@

writeFile: function(target, data, options, callback) {
callback = cleanCallback(options, callback);
options = cleanOptions(options);
if (!options.quiet) console.log(('\n <-- writing file to: ' + target));
fs.writeFile(target, data, function(err) {
if (typeof callback === 'function') {
callback(err);
}
callback(err);
});
}
};
function cleanCallback (options, callback) {
if (typeof options === 'function')
callback = options;
return callback || noop;
}
function cleanOptions (options) {
if (typeof options === 'function')
options = {};
return options || {};
}
function noop () {}

@@ -9,3 +9,3 @@ {

],
"version": "2.3.0",
"version": "2.4.0",
"private": false,

@@ -29,9 +29,8 @@ "preferGlobal": "true",

"devDependencies": {
"async": "^0.9.0",
"chai": "^1.10.0",
"grunt": "^0.4.5",
"grunt-mocha-test": "^0.12.4"
"async": "0.9.0",
"chai": "1.10.0",
"mocha": "2.4.5"
},
"scripts": {
"test": "grunt mochaTest"
"test": "mocha"
},

@@ -38,0 +37,0 @@ "bin": {

@@ -334,3 +334,15 @@ var fs = require('fs')

});
})
});
describe('the functions', function() {
it('should know if the `options` argument is actually a callback', function(done) {
var output = './test/_tmp/en.utf8.po';
wrapper.i18nextToGettext('en', testFiles.en.utf8_expected, output, done);
});
it('should not require options or callback', function(done) {
var output = './test/_tmp/en.utf8.po';
wrapper.i18nextToGettext('en', testFiles.en.utf8_expected, output);
done(); // Would fail synchronously
});
});
});

Sorry, the diff of this file is not supported yet

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