Socket
Socket
Sign inDemoInstall

i18next-scanner

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18next-scanner - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

5

lib/parser.js

@@ -24,2 +24,4 @@ 'use strict';

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -602,4 +604,5 @@

var others = _objectWithoutProperties(options, ['replacer', 'space']);
return JSON.stringify(this.getResourceStore(options), replacer, space);
return JSON.stringify(this.get(others), replacer, space);
}

@@ -606,0 +609,0 @@ }]);

2

package.json
{
"name": "i18next-scanner",
"version": "1.3.0",
"version": "1.3.1",
"description": "Scan your code, extract translation keys/values, and merge them into i18n resource files.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/i18next/i18next-scanner",

@@ -552,5 +552,5 @@ /* eslint no-console: 0 */

toJSON(options = {}) {
const { replacer, space } = options;
const { replacer, space, ...others } = options;
return JSON.stringify(this.getResourceStore(options), replacer, space);
return JSON.stringify(this.get(others), replacer, space);
}

@@ -557,0 +557,0 @@ }

@@ -8,2 +8,23 @@ import fs from 'fs';

test('skip undefined namespace', (t) => {
const parser = new Parser({
ns: ['translation']
});
const content = `
i18next.t('none:key2');
i18next.t('key1');
`;
const wanted = {
en: {
translation: {
key1: ''
}
}
};
parser.parseFuncFromString(content);
t.same(parser.get(), wanted);
t.end();
});
test('parse translation function', (t) => {

@@ -268,1 +289,38 @@ const parser = new Parser({

});
test('parser.toJSON()', (t) => {
const parser = new Parser();
const content = fs.readFileSync(path.resolve(__dirname, 'fixtures/app.js'), 'utf-8');
parser.parseFuncFromString(content);
t.same(parser.toJSON(), '{"en":{"translation":{"key2":"","key1":""}}}');
t.end();
});
test('parser.toJSON({ sort: true })', (t) => {
const parser = new Parser();
const content = fs.readFileSync(path.resolve(__dirname, 'fixtures/app.js'), 'utf-8');
parser.parseFuncFromString(content);
t.same(parser.toJSON({ sort: true }), '{"en":{"translation":{"key1":"","key2":""}}}');
t.end();
});
test('parser.toJSON({ sort: true, space: 2 })', (t) => {
const parser = new Parser();
const content = fs.readFileSync(path.resolve(__dirname, 'fixtures/app.js'), 'utf-8');
const wanted = JSON.stringify({
en: {
translation: {
key1: '',
key2: ''
}
}
}, null, 2);
parser.parseFuncFromString(content);
t.same(parser.toJSON({ sort: true, space: 2 }), wanted);
t.end();
});
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