i18next-scanner
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -467,2 +467,4 @@ 'use strict'; | ||
// @param {string} [options.context] used for contexts (eg. male) | ||
// @param {string|boolean} [options.nsSeparator] The value used to override this.options.nsSeparator | ||
// @param {string|boolean} [options.keySeparator] The value used to override this.options.keySeparator | ||
@@ -484,2 +486,5 @@ }, { | ||
var nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator; | ||
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator; | ||
var ns = this.options.defaultNs; | ||
@@ -497,4 +502,4 @@ | ||
if (_lodash2.default.isString(this.options.nsSeparator) && key.indexOf(this.options.nsSeparator) > -1) { | ||
var parts = key.split(this.options.nsSeparator); | ||
if (_lodash2.default.isString(nsSeparator) && key.indexOf(nsSeparator) > -1) { | ||
var parts = key.split(nsSeparator); | ||
@@ -505,3 +510,3 @@ ns = parts[0]; | ||
var keys = _lodash2.default.isString(this.options.keySeparator) ? key.split(this.options.keySeparator) : [key]; | ||
var keys = _lodash2.default.isString(keySeparator) ? key.split(keySeparator) : [key]; | ||
@@ -508,0 +513,0 @@ this.options.lngs.forEach(function (lng) { |
{ | ||
"name": "i18next-scanner", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "Scan your code, extract translation keys/values, and merge them into i18n resource files.", | ||
@@ -41,3 +41,3 @@ "homepage": "https://github.com/i18next/i18next-scanner", | ||
"esprima": "^2.7.2", | ||
"lodash": "^4.12.0", | ||
"lodash": "^4.13.1", | ||
"through2": "^2.0.1", | ||
@@ -48,10 +48,9 @@ "vinyl": "^1.1.1", | ||
"devDependencies": { | ||
"babel-cli": "^6.8.0", | ||
"babel-core": "^6.8.0", | ||
"babel-cli": "^6.10.1", | ||
"babel-core": "^6.9.1", | ||
"babel-eslint": "^6.0.4", | ||
"babel-loader": "^6.2.4", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babel-preset-es2015": "^6.9.0", | ||
"babel-preset-stage-0": "^6.5.0", | ||
"coveralls": "^2.11.9", | ||
"eslint": "^2.10.1", | ||
"eslint": "^2.12.0", | ||
"gulp": "^3.9.1", | ||
@@ -61,5 +60,5 @@ "gulp-tap": "^0.1.3", | ||
"sha1": "^1.1.1", | ||
"tap": "^5.7.1", | ||
"tap": "^5.7.2", | ||
"text-table": "^0.2.0" | ||
} | ||
} |
@@ -412,2 +412,4 @@ /* eslint no-console: 0 */ | ||
// @param {string} [options.context] used for contexts (eg. male) | ||
// @param {string|boolean} [options.nsSeparator] The value used to override this.options.nsSeparator | ||
// @param {string|boolean} [options.keySeparator] The value used to override this.options.keySeparator | ||
set(key, options = {}) { | ||
@@ -422,2 +424,5 @@ // Backward compatibility | ||
const nsSeparator = (options.nsSeparator !== undefined) ? options.nsSeparator : this.options.nsSeparator; | ||
const keySeparator = (options.keySeparator !== undefined) ? options.keySeparator : this.options.keySeparator; | ||
let ns = this.options.defaultNs; | ||
@@ -435,4 +440,4 @@ | ||
if (_.isString(this.options.nsSeparator) && (key.indexOf(this.options.nsSeparator) > -1)) { | ||
const parts = key.split(this.options.nsSeparator); | ||
if (_.isString(nsSeparator) && (key.indexOf(nsSeparator) > -1)) { | ||
const parts = key.split(nsSeparator); | ||
@@ -443,3 +448,3 @@ ns = parts[0]; | ||
const keys = _.isString(this.options.keySeparator) ? key.split(this.options.keySeparator) : [key]; | ||
const keys = _.isString(keySeparator) ? key.split(keySeparator) : [key]; | ||
@@ -446,0 +451,0 @@ this.options.lngs.forEach((lng) => { |
@@ -8,3 +8,3 @@ import fs from 'fs'; | ||
test('skip undefined namespace', (t) => { | ||
test('Skip undefined namespace', (t) => { | ||
const parser = new Parser({ | ||
@@ -30,3 +30,3 @@ ns: ['translation'] | ||
test('parse translation function', (t) => { | ||
test('Parse translation function', (t) => { | ||
const parser = new Parser({ | ||
@@ -75,3 +75,3 @@ lngs: ['en'], | ||
test('parse HTML attribute', (t) => { | ||
test('Parse HTML attribute', (t) => { | ||
const parser = new Parser({ | ||
@@ -124,3 +124,3 @@ lngs: ['en'], | ||
test('gettext style i18n', (t) => { | ||
test('Gettext style i18n', (t) => { | ||
const parser = new Parser({ | ||
@@ -155,3 +155,3 @@ defaultValue: (lng, ns, key) => { | ||
test('disable nsSeparator', (t) => { | ||
test('Disable nsSeparator', (t) => { | ||
const parser = new Parser({ | ||
@@ -176,3 +176,3 @@ defaultValue: '__NOT_TRANSLATED__', | ||
test('disable keySeparator', (t) => { | ||
test('Disable keySeparator', (t) => { | ||
const parser = new Parser({ | ||
@@ -197,3 +197,3 @@ defaultValue: '__NOT_TRANSLATED__', | ||
test('default nsSeparator', (t) => { | ||
test('Default nsSeparator', (t) => { | ||
const parser = new Parser({ | ||
@@ -220,3 +220,3 @@ defaultValue: '__NOT_TRANSLATED__', | ||
test('default keyseparator', (t) => { | ||
test('Default keySeparator', (t) => { | ||
const parser = new Parser({ | ||
@@ -243,2 +243,48 @@ defaultValue: '__NOT_TRANSLATED__', | ||
test('Override nsSeparator with a false value', (t) => { | ||
const parser = new Parser({ | ||
defaultValue: '__NOT_TRANSLATED__', | ||
nsSeparator: ':', | ||
keySeparator: '.' | ||
}); | ||
parser.set('translation:key1.key2', { | ||
nsSeparator: false | ||
}); | ||
const resStore = parser.get(); | ||
t.same(resStore, { | ||
en: { | ||
translation: { | ||
'translation:key1': { | ||
'key2': '__NOT_TRANSLATED__' | ||
} | ||
} | ||
} | ||
}, 'Override nsSeparator with a false value'); | ||
t.end(); | ||
}); | ||
test('Override keySeparator with a false value', (t) => { | ||
const parser = new Parser({ | ||
defaultValue: '__NOT_TRANSLATED__', | ||
nsSeparator: ':', | ||
keySeparator: '.' | ||
}); | ||
parser.set('translation:key1.key2', { | ||
keySeparator: false | ||
}); | ||
const resStore = parser.get(); | ||
t.same(resStore, { | ||
en: { | ||
translation: { | ||
'key1.key2': '__NOT_TRANSLATED__' | ||
} | ||
} | ||
}, 'Override keySeparator with a false value'); | ||
t.end(); | ||
}); | ||
test('Plural', (t) => { | ||
@@ -245,0 +291,0 @@ const parser = new Parser(); |
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
104977
13
32
1992
Updatedlodash@^4.13.1