i18next-scanner
Advanced tools
Comparing version
@@ -14,3 +14,3 @@ "use strict"; | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Originally from: https://github.com/sderosiaux/acorn-jsx-walk | ||
Object.assign(_acornWalk.base, _defineProperty({ | ||
@@ -17,0 +17,0 @@ FieldDefinition: function FieldDefinition(node, state, callback) { |
@@ -44,3 +44,3 @@ "use strict"; | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* eslint no-console: 0 */ /* eslint no-eval: 0 */ | ||
_i18next["default"].init({ | ||
@@ -293,8 +293,2 @@ compatibilityJSON: 'v3' | ||
var Parser = /*#__PURE__*/function () { | ||
// The resStore stores all translation keys including unused ones | ||
// The resScan only stores translation keys parsed from code | ||
// The all plurals suffixes for each of target languages. | ||
function Parser(options) { | ||
@@ -304,4 +298,7 @@ var _this = this; | ||
_defineProperty(this, "options", _objectSpread({}, defaults)); | ||
// The resStore stores all translation keys including unused ones | ||
_defineProperty(this, "resStore", {}); | ||
// The resScan only stores translation keys parsed from code | ||
_defineProperty(this, "resScan", {}); | ||
// The all plurals suffixes for each of target languages. | ||
_defineProperty(this, "pluralSuffixes", {}); | ||
@@ -571,18 +568,2 @@ this.options = normalizeOptions(_objectSpread(_objectSpread({}, this.options), options)); | ||
} | ||
(0, _ensureType.ensureArray)(node.openingElement.attributes).forEach(function (attribute) { | ||
var value = attribute.value; | ||
if (!(value && value.type === 'JSXExpressionContainer')) { | ||
return; | ||
} | ||
var expression = value.expression; | ||
if (!(expression && expression.type === 'JSXElement')) { | ||
return; | ||
} | ||
parseJSXElement(expression, code); | ||
}); | ||
(0, _ensureType.ensureArray)(node.children).forEach(function (childNode) { | ||
if (childNode.type === 'JSXElement') { | ||
parseJSXElement(childNode, code); | ||
} | ||
}); | ||
if (component instanceof RegExp ? !node.openingElement.name.name.match(component) : node.openingElement.name.name !== component) { | ||
@@ -995,6 +976,7 @@ return; | ||
} else if (options.defaultValue && (!options.defaultValue_plural || !resKey.endsWith("".concat(pluralSeparator, "plural")))) { | ||
var value = _lodash["default"].isFunction(defaultValue) ? defaultValue(lng, ns, key, options) : options.defaultValue || defaultValue; // Use `options.defaultValue` if specified | ||
if (!resLoad[resKey]) { | ||
// Use `options.defaultValue` if specified | ||
resLoad[resKey] = options.defaultValue; | ||
} else if (resLoad[resKey] !== options.defaultValue && lng === defaultLng) { | ||
resLoad[resKey] = value; | ||
} else if (resLoad[resKey] !== value && lng === defaultLng) { | ||
// A default value has provided but it's different with the expected default | ||
@@ -1005,3 +987,2 @@ _this7.log("The translation key ".concat(_chalk["default"].yellow(JSON.stringify(resKey)), ", with a default value of \"").concat(_chalk["default"].yellow(options.defaultValue), "\" has a different default value, you may need to check the translation key of default language (").concat(defaultLng, ")")); | ||
if (!resLoad[resKey]) { | ||
// Use `options.defaultValue_plural` if specified | ||
resLoad[resKey] = options.defaultValue_plural; | ||
@@ -1008,0 +989,0 @@ } else if (resLoad[resKey] !== options.defaultValue_plural && lng === defaultLng) { |
{ | ||
"name": "i18next-scanner", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "Scan your code, extract translation keys/values, and merge them into i18n resource files.", | ||
@@ -69,4 +69,4 @@ "homepage": "https://github.com/i18next/i18next-scanner", | ||
"through2": "^4.0.0", | ||
"vinyl": "^2.2.0", | ||
"vinyl-fs": "^3.0.1" | ||
"vinyl": "^3.0.0", | ||
"vinyl-fs": "^4.0.0" | ||
}, | ||
@@ -73,0 +73,0 @@ "devDependencies": { |
99225
-0.49%1412
-1.19%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated