@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 +10 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +10 -7
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -2157,7 +2157,7 @@ const getPathWithDefaults = (data, defaultData, key) => {
|
|
|
2157
2157
|
const deepExtend = (target, source, overwrite) => {
|
|
2158
2158
|
for (const prop in source) {
|
|
2159
2159
|
if (prop !== '__proto__' && prop !== 'constructor') {
|
|
2160
|
-
if (prop
|
|
2160
|
+
if (Object.prototype.hasOwnProperty.call(target, prop)) {
|
|
2161
2161
|
if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
|
|
2162
2162
|
if (overwrite) target[prop] = source[prop];
|
|
2163
2163
|
} else {
|
|
@@ -2947,7 +2947,10 @@ class Translator extends EventEmitter {
|
|
|
2947
2947
|
const useOptionsReplaceForData = options.replace && !isString(options.replace);
|
|
2948
2948
|
let data = useOptionsReplaceForData ? options.replace : options;
|
|
2949
2949
|
if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
|
|
2950
|
-
data
|
|
2950
|
+
data = {
|
|
2951
|
+
...data,
|
|
2952
|
+
count: options.count
|
|
2953
|
+
};
|
|
2951
2954
|
}
|
|
2952
2955
|
if (this.options.interpolation.defaultVariables) {
|
|
2953
2956
|
data = {
|
|
@@ -3260,10 +3263,10 @@ class Interpolator {
|
|
|
3260
3263
|
const skipOnVariables = options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
3261
3264
|
const todos = [{
|
|
3262
3265
|
regex: this.regexpUnescape,
|
|
3263
|
-
safeValue: val =>
|
|
3266
|
+
safeValue: val => val
|
|
3264
3267
|
}, {
|
|
3265
3268
|
regex: this.regexp,
|
|
3266
|
-
safeValue: val => this.escapeValue ?
|
|
3269
|
+
safeValue: val => this.escapeValue ? this.escape(val) : val
|
|
3267
3270
|
}];
|
|
3268
3271
|
todos.forEach(todo => {
|
|
3269
3272
|
replaces = 0;
|
|
@@ -3287,9 +3290,9 @@ class Interpolator {
|
|
|
3287
3290
|
value = makeString(value);
|
|
3288
3291
|
}
|
|
3289
3292
|
const safeValue = todo.safeValue(value);
|
|
3290
|
-
str = str.replace(match[0], safeValue);
|
|
3293
|
+
str = str.replace(match[0], regexSafe(safeValue));
|
|
3291
3294
|
if (skipOnVariables) {
|
|
3292
|
-
todo.regex.lastIndex +=
|
|
3295
|
+
todo.regex.lastIndex += safeValue.length;
|
|
3293
3296
|
todo.regex.lastIndex -= match[0].length;
|
|
3294
3297
|
} else {
|
|
3295
3298
|
todo.regex.lastIndex = 0;
|
|
@@ -3339,7 +3342,7 @@ class Interpolator {
|
|
|
3339
3342
|
clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
|
|
3340
3343
|
clonedOptions.applyPostProcessor = false;
|
|
3341
3344
|
delete clonedOptions.defaultValue;
|
|
3342
|
-
const keyEndIndex = /{.*}
|
|
3345
|
+
const keyEndIndex = /{.*}/s.test(match[1]) ? match[1].lastIndexOf('}') + 1 : match[1].indexOf(this.formatSeparator);
|
|
3343
3346
|
if (keyEndIndex !== -1) {
|
|
3344
3347
|
formatters = match[1].slice(keyEndIndex).split(this.formatSeparator).map(elem => elem.trim()).filter(Boolean);
|
|
3345
3348
|
match[1] = match[1].slice(0, keyEndIndex);
|