i18next-scanner
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -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 @@ }]); |
{ | ||
"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(); | ||
}); |
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
103020
1944