@fkui/i18next-translate 6.52.1 → 6.52.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -2159,7 +2159,7 @@ const getPathWithDefaults = (data, defaultData, key) => {
2159
2159
  const deepExtend = (target, source, overwrite) => {
2160
2160
  for (const prop in source) {
2161
2161
  if (prop !== '__proto__' && prop !== 'constructor') {
2162
- if (prop in target) {
2162
+ if (Object.prototype.hasOwnProperty.call(target, prop)) {
2163
2163
  if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
2164
2164
  if (overwrite) target[prop] = source[prop];
2165
2165
  } else {
@@ -2949,7 +2949,10 @@ class Translator extends EventEmitter {
2949
2949
  const useOptionsReplaceForData = options.replace && !isString(options.replace);
2950
2950
  let data = useOptionsReplaceForData ? options.replace : options;
2951
2951
  if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
2952
- data.count = options.count;
2952
+ data = {
2953
+ ...data,
2954
+ count: options.count
2955
+ };
2953
2956
  }
2954
2957
  if (this.options.interpolation.defaultVariables) {
2955
2958
  data = {
@@ -3262,10 +3265,10 @@ class Interpolator {
3262
3265
  const skipOnVariables = options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
3263
3266
  const todos = [{
3264
3267
  regex: this.regexpUnescape,
3265
- safeValue: val => regexSafe(val)
3268
+ safeValue: val => val
3266
3269
  }, {
3267
3270
  regex: this.regexp,
3268
- safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
3271
+ safeValue: val => this.escapeValue ? this.escape(val) : val
3269
3272
  }];
3270
3273
  todos.forEach(todo => {
3271
3274
  replaces = 0;
@@ -3289,9 +3292,9 @@ class Interpolator {
3289
3292
  value = makeString(value);
3290
3293
  }
3291
3294
  const safeValue = todo.safeValue(value);
3292
- str = str.replace(match[0], safeValue);
3295
+ str = str.replace(match[0], regexSafe(safeValue));
3293
3296
  if (skipOnVariables) {
3294
- todo.regex.lastIndex += value.length;
3297
+ todo.regex.lastIndex += safeValue.length;
3295
3298
  todo.regex.lastIndex -= match[0].length;
3296
3299
  } else {
3297
3300
  todo.regex.lastIndex = 0;
@@ -3341,7 +3344,7 @@ class Interpolator {
3341
3344
  clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
3342
3345
  clonedOptions.applyPostProcessor = false;
3343
3346
  delete clonedOptions.defaultValue;
3344
- const keyEndIndex = /{.*}/.test(match[1]) ? match[1].lastIndexOf('}') + 1 : match[1].indexOf(this.formatSeparator);
3347
+ const keyEndIndex = /{.*}/s.test(match[1]) ? match[1].lastIndexOf('}') + 1 : match[1].indexOf(this.formatSeparator);
3345
3348
  if (keyEndIndex !== -1) {
3346
3349
  formatters = match[1].slice(keyEndIndex).split(this.formatSeparator).map(elem => elem.trim()).filter(Boolean);
3347
3350
  match[1] = match[1].slice(0, keyEndIndex);