Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

i18next-parser

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18next-parser - npm Package Compare versions

Comparing version 8.10.0 to 8.11.0

204

dist/transform.js

@@ -193,3 +193,3 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";import _classCallCheck from "@babel/runtime/helpers/classCallCheck";import _createClass from "@babel/runtime/helpers/createClass";import _inherits from "@babel/runtime/helpers/inherits";import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";function _createForOfIteratorHelper(o, allowArrayLike) {var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];if (!it) {if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {if (it) o = it;var i = 0;var F = function F() {};return { s: F, n: function n() {if (i >= o.length) return { done: true };return { done: false, value: o[i++] };}, e: function e(_e) {throw _e;}, f: F };}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion = true,didErr = false,err;return { s: function s() {it = it.call(o);}, n: function n() {var step = it.next();normalCompletion = step.done;return step;}, e: function e(_e2) {didErr = true;err = _e2;}, f: function f() {try {if (!normalCompletion && it["return"] != null) it["return"]();} finally {if (didErr) throw err;}} };}function _unsupportedIterableToArray(o, minLen) {if (!o) return;if (typeof o === "string") return _arrayLikeToArray(o, minLen);var n = Object.prototype.toString.call(o).slice(8, -1);if (n === "Object" && o.constructor) n = o.constructor.name;if (n === "Map" || n === "Set") return Array.from(o);if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);}function _arrayLikeToArray(arr, len) {if (len == null || len > arr.length) len = arr.length;for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];return arr2;}function ownKeys(e, r) {var t = Object.keys(e);if (Object.getOwnPropertySymbols) {var o = Object.getOwnPropertySymbols(e);r && (o = o.filter(function (r) {return Object.getOwnPropertyDescriptor(e, r).enumerable;})), t.push.apply(t, o);}return t;}function _objectSpread(e) {for (var r = 1; r < arguments.length; r++) {var t = null != arguments[r] ? arguments[r] : {};r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {_defineProperty(e, r, t[r]);}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));});}return e;}function _createSuper(Derived) {var hasNativeReflectConstruct = _isNativeReflectConstruct();return function _createSuperInternal() {var Super = _getPrototypeOf(Derived),result;if (hasNativeReflectConstruct) {var NewTarget = _getPrototypeOf(this).constructor;result = Reflect.construct(Super, arguments, NewTarget);} else {result = Super.apply(this, arguments);}return _possibleConstructorReturn(this, result);};}function _isNativeReflectConstruct() {if (typeof Reflect === "undefined" || !Reflect.construct) return false;if (Reflect.construct.sham) return false;if (typeof Proxy === "function") return true;try {Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));return true;} catch (e) {return false;}}import { Transform } from 'stream';

// generates plurals according to i18next rules: key_zero, key_one, key_two, key_few, key_many and key_other
var _iterator3 = _createForOfIteratorHelper(_this2.entries),_step3;try {var _loop2 = function _loop2() {var entry = _step3.value;
var _iterator3 = _createForOfIteratorHelper(_this2.entries),_step3;try {var _loop3 = function _loop3() {var entry = _step3.value;
if (

@@ -207,23 +207,23 @@ _this2.options.pluralSeparator !== false &&

}
};for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {_loop2();}} catch (err) {_iterator3.e(err);} finally {_iterator3.f();}
};for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {_loop3();}} catch (err) {_iterator3.e(err);} finally {_iterator3.f();}
var outputPath = path.resolve(_this2.options.output);
var outputPath = path.resolve(_this2.options.output);var _loop2 = function _loop2()
for (var namespace in catalog) {
var namespacePath = outputPath;
namespacePath = namespacePath.replace(_this2.localeRegex, locale);
namespacePath = namespacePath.replace(_this2.namespaceRegex, namespace);
{
var namespacePath = outputPath;
namespacePath = namespacePath.replace(_this2.localeRegex, locale);
namespacePath = namespacePath.replace(_this2.namespaceRegex, namespace);
var parsedNamespacePath = path.parse(namespacePath);
var parsedNamespacePath = path.parse(namespacePath);
var namespaceOldPath = path.join(
parsedNamespacePath.dir, "".concat(
parsedNamespacePath.name, "_old").concat(parsedNamespacePath.ext)
);
var namespaceOldPath = path.join(
parsedNamespacePath.dir, "".concat(
parsedNamespacePath.name, "_old").concat(parsedNamespacePath.ext)
);
var existingCatalog = _this2.getCatalog(namespacePath);
var existingOldCatalog = _this2.getCatalog(namespaceOldPath);
var existingCatalog = _this2.getCatalog(namespacePath);
var existingOldCatalog = _this2.getCatalog(namespaceOldPath);
// merges existing translations with the new ones
var _mergeHashes =
// merges existing translations with the new ones
var _mergeHashes =

@@ -235,83 +235,96 @@

mergeHashes(
existingCatalog,
catalog[namespace], _objectSpread(_objectSpread({},
mergeHashes(
existingCatalog,
catalog[namespace], _objectSpread(_objectSpread({},
_this2.options), {}, {
resetAndFlag: resetAndFlag,
fullKeyPrefix: namespace + _this2.options.namespaceSeparator }),
_this2.options), {}, {
resetAndFlag: resetAndFlag,
fullKeyPrefix: namespace + _this2.options.namespaceSeparator }),
resetValues[namespace]
),newCatalog = _mergeHashes["new"],oldKeys = _mergeHashes.old,mergeCount = _mergeHashes.mergeCount,oldCount = _mergeHashes.oldCount,resetFlags = _mergeHashes.reset,resetCount = _mergeHashes.resetCount;
resetValues[namespace]
),newCatalog = _mergeHashes["new"],oldKeys = _mergeHashes.old,mergeCount = _mergeHashes.mergeCount,oldCount = _mergeHashes.oldCount,resetFlags = _mergeHashes.reset,resetCount = _mergeHashes.resetCount;
// record values to be reset
// assumes that the 'default' namespace is processed first
if (resetAndFlag && !resetValues[namespace]) {
resetValues[namespace] = resetFlags;
}
// record values to be reset
// assumes that the 'default' namespace is processed first
if (resetAndFlag && !resetValues[namespace]) {
resetValues[namespace] = resetFlags;
}
// restore old translations
var _mergeHashes2 = mergeHashes(
existingOldCatalog,
newCatalog, _objectSpread(_objectSpread({},
_this2.options), {}, { keepRemoved: false })
),oldCatalog = _mergeHashes2.old,restoreCount = _mergeHashes2.mergeCount;
// restore old translations
var _mergeHashes2 = mergeHashes(
existingOldCatalog,
newCatalog, _objectSpread(_objectSpread({},
_this2.options), {}, { keepRemoved: false })
),oldCatalog = _mergeHashes2.old,restoreCount = _mergeHashes2.mergeCount;
// backup unused translations
transferValues(oldKeys, oldCatalog);
// backup unused translations
transferValues(oldKeys, oldCatalog);
if (_this2.options.verbose) {
console.log("[".concat(locale, "] ").concat(namespace));
console.log("Unique keys: ".concat(
uniqueCount[namespace], " (").concat(uniquePluralsCount[namespace], " are plurals)")
);
var addCount = uniqueCount[namespace] - mergeCount;
console.log("Added keys: ".concat(addCount));
console.log("Restored keys: ".concat(restoreCount));
if (_this2.options.keepRemoved) {
console.log("Unreferenced keys: ".concat(oldCount));
} else {
console.log("Removed keys: ".concat(oldCount));
if (_this2.options.verbose) {
console.log("[".concat(locale, "] ").concat(namespace));
console.log("Unique keys: ".concat(
uniqueCount[namespace], " (").concat(uniquePluralsCount[namespace], " are plurals)")
);
var addCount = uniqueCount[namespace] - mergeCount;
console.log("Added keys: ".concat(addCount));
console.log("Restored keys: ".concat(restoreCount));
if (_this2.options.keepRemoved) {
console.log("Unreferenced keys: ".concat(oldCount));
} else {
console.log("Removed keys: ".concat(oldCount));
}
if (_this2.options.resetDefaultValueLocale) {
console.log("Reset keys: ".concat(resetCount));
}
console.log('');
}
if (_this2.options.resetDefaultValueLocale) {
console.log("Reset keys: ".concat(resetCount));
if (_this2.options.failOnUpdate) {
var _addCount = uniqueCount[namespace] - mergeCount;
var refCount =
_addCount + restoreCount + (_this2.options.keepRemoved ? 0 : oldCount);
if (refCount !== 0) {
_this2.parserHadUpdate = true;return 0; // continue
}
}
console.log('');
}
if (_this2.options.failOnUpdate) {
var _addCount = uniqueCount[namespace] - mergeCount;
var refCount =
_addCount + restoreCount + (_this2.options.keepRemoved ? 0 : oldCount);
if (refCount !== 0) {
_this2.parserHadUpdate = true;
continue;
if (_this2.options.failOnWarnings && _this2.parserHadWarnings) {return 0; // continue
}
}
if (_this2.options.failOnWarnings && _this2.parserHadWarnings) {
continue;
}
var maybeSortedNewCatalog = newCatalog;
var maybeSortedOldCatalog = oldCatalog;
var sort = _this2.options.sort;
if (sort) {
var compare =
typeof sort === 'function' ?
sort :
makeDefaultSort(_this2.options.pluralSeparator);
var wrappedCompare = _this2.options.failOnUpdate ?
function () {
var result = compare.apply(void 0, arguments);
if (result > 0) {
_this2.parserHadSortUpdate = true;
wrappedCompare = compare;
}
return result;
} :
compare;
maybeSortedNewCatalog = sortKeys(newCatalog, {
deep: true,
compare: wrappedCompare
});
maybeSortedOldCatalog = sortKeys(oldCatalog, { deep: true, compare: compare });
}
var maybeSortedNewCatalog = newCatalog;
var maybeSortedOldCatalog = oldCatalog;
var sort = _this2.options.sort;
if (sort) {
var compare =
typeof sort === 'function' ?
sort :
makeDefaultSort(_this2.options.pluralSeparator);
maybeSortedNewCatalog = sortKeys(newCatalog, { deep: true, compare: compare });
maybeSortedOldCatalog = sortKeys(oldCatalog, { deep: true, compare: compare });
}
// push files back to the stream
_this2.pushFile(namespacePath, maybeSortedNewCatalog);
if (
_this2.options.createOldCatalogs && (
Object.keys(oldCatalog).length || existingOldCatalog))
{
_this2.pushFile(namespaceOldPath, maybeSortedOldCatalog);
}
}
// push files back to the stream
_this2.pushFile(namespacePath, maybeSortedNewCatalog);
if (
_this2.options.createOldCatalogs && (
Object.keys(oldCatalog).length || existingOldCatalog))
{
_this2.pushFile(namespaceOldPath, maybeSortedOldCatalog);
}
},_ret;for (var namespace in catalog) {_ret = _loop2();if (_ret === 0) continue;}
};for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {_loop();}} catch (err) {_iterator2.e(err);} finally {_iterator2.f();}

@@ -327,8 +340,17 @@

if (this.options.failOnUpdate && this.parserHadUpdate) {
this.emit(
'error',
'Some translations was updated and failOnUpdate option is enabled. Exiting...'
);
process.exit(1);
if (this.options.failOnUpdate) {
if (this.parserHadUpdate) {
this.emit(
'error',
'Some translations was updated and failOnUpdate option is enabled. Exiting...'
);
process.exit(1);
}
if (this.parserHadSortUpdate) {
this.emit(
'error',
'Some keys were sorted and failOnUpdate option is enabled. Exiting...'
);
process.exit(1);
}
}

@@ -335,0 +357,0 @@

{
"name": "i18next-parser",
"description": "Command Line tool for i18next",
"version": "8.10.0",
"version": "8.11.0",
"type": "module",

@@ -6,0 +6,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

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