i18next-scanner
Advanced tools
Comparing version 2.9.0 to 2.9.1
@@ -256,6 +256,6 @@ 'use strict'; | ||
// Get an array of plurals suffixes for a given language. | ||
// Get an array of plural suffixes for a given language. | ||
// @param {string} lng The language. | ||
// @param {string} pluralSeparator pluralSeparator, default '_'. | ||
// @return {array|boolean} Return array of suffixes of false if lng is not supported. | ||
// @return {array} An array of plural suffixes. | ||
var getPluralSuffixes = function getPluralSuffixes(lng) { | ||
@@ -266,19 +266,18 @@ var pluralSeparator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '_'; | ||
var suffixes = []; | ||
if (!(rule && rule.numbers)) { | ||
return []; // Return an empty array if lng is not supported | ||
} | ||
if (!rule) { | ||
return false; | ||
} else if (rule.numbers.length === 2) { | ||
suffixes = ['', pluralSeparator + 'plural']; | ||
} else { | ||
var res = []; | ||
suffixes = rule.numbers.reduce(function (red, n, i) { | ||
if (rule.numbers.length === 1) { | ||
return [pluralSeparator + '0']; | ||
} | ||
res.push('' + pluralSeparator + i); | ||
return res; | ||
}, ''); | ||
if (rule.numbers.length === 1) { | ||
return [pluralSeparator + '0']; | ||
} | ||
if (rule.numbers.length === 2) { | ||
return ['', pluralSeparator + 'plural']; | ||
} | ||
var suffixes = rule.numbers.reduce(function (acc, n, i) { | ||
return acc.concat('' + pluralSeparator + i); | ||
}, []); | ||
return suffixes; | ||
@@ -313,7 +312,8 @@ }; | ||
_this.resScan[lng] = _this.resScan[lng] || {}; | ||
_this.pluralSuffixes[lng] = getPluralSuffixes(lng, _this.options.pluralSeparator); | ||
if (!_this.pluralSuffixes[lng]) { | ||
_this.log('i18next-scanner: Unexpected language ' + lng); | ||
return; | ||
_this.pluralSuffixes[lng] = (0, _ensureArray2.default)(getPluralSuffixes(lng, _this.options.pluralSeparator)); | ||
if (_this.pluralSuffixes[lng].length === 0) { | ||
_this.log('i18next-scanner: No plural rule found for: ' + lng); | ||
} | ||
namespaces.forEach(function (ns) { | ||
@@ -320,0 +320,0 @@ var resPath = _this.formatResourceLoadPath(lng, ns); |
{ | ||
"name": "i18next-scanner", | ||
"version": "2.9.0", | ||
"version": "2.9.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", |
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
89839
15
1390