@fkui/i18next-translate 6.43.0 → 6.44.0
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/esm/index.js
CHANGED
|
@@ -2295,6 +2295,7 @@ class Logger {
|
|
|
2295
2295
|
}
|
|
2296
2296
|
forward(args, lvl, prefix, debugOnly) {
|
|
2297
2297
|
if (debugOnly && !this.debug) return null;
|
|
2298
|
+
args = args.map(a => isString(a) ? a.replace(/[\r\n\x00-\x1F\x7F]/g, ' ') : a);
|
|
2298
2299
|
if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
|
|
2299
2300
|
return this.logger[lvl](args);
|
|
2300
2301
|
}
|
|
@@ -2732,7 +2733,7 @@ class Translator extends EventEmitter {
|
|
|
2732
2733
|
const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
|
|
2733
2734
|
const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
|
|
2734
2735
|
if (usedKey || usedDefault || updateMissing) {
|
|
2735
|
-
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
|
|
2736
|
+
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, needsPluralHandling && !updateMissing ? `${key}${this.pluralResolver.getSuffix(lng, opt.count, opt)}` : key, updateMissing ? defaultValue : res);
|
|
2736
2737
|
if (keySeparator) {
|
|
2737
2738
|
const fk = this.resolve(key, {
|
|
2738
2739
|
...opt,
|
|
@@ -3200,8 +3201,8 @@ class Interpolator {
|
|
|
3200
3201
|
this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || '{{';
|
|
3201
3202
|
this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || '}}';
|
|
3202
3203
|
this.formatSeparator = formatSeparator || ',';
|
|
3203
|
-
this.unescapePrefix = unescapeSuffix ? '' : unescapePrefix
|
|
3204
|
-
this.unescapeSuffix = this.unescapePrefix ? '' : unescapeSuffix
|
|
3204
|
+
this.unescapePrefix = unescapeSuffix ? '' : unescapePrefix ? regexEscape(unescapePrefix) : '-';
|
|
3205
|
+
this.unescapeSuffix = this.unescapePrefix ? '' : unescapeSuffix ? regexEscape(unescapeSuffix) : '';
|
|
3205
3206
|
this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape('$t(');
|
|
3206
3207
|
this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(')');
|
|
3207
3208
|
this.nestingOptionsSeparator = nestingOptionsSeparator || ',';
|
|
@@ -3248,6 +3249,9 @@ class Interpolator {
|
|
|
3248
3249
|
});
|
|
3249
3250
|
};
|
|
3250
3251
|
this.resetRegExp();
|
|
3252
|
+
if (!this.escapeValue && typeof str === 'string' && /\$t\([^)]*\{[^}]*\{\{/.test(str)) {
|
|
3253
|
+
this.logger.warn('nesting options string contains interpolated variables with escapeValue: false — ' + 'if any of those values are attacker-controlled they can inject additional ' + 'nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing ' + 'it to t(), or keep escapeValue: true.');
|
|
3254
|
+
}
|
|
3251
3255
|
const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
|
|
3252
3256
|
const skipOnVariables = options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
3253
3257
|
const todos = [{
|
|
@@ -3926,7 +3930,7 @@ class I18n extends EventEmitter {
|
|
|
3926
3930
|
deferred.resolve(t);
|
|
3927
3931
|
callback(err, t);
|
|
3928
3932
|
};
|
|
3929
|
-
if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
|
|
3933
|
+
if ((this.languages || this.isLanguageChangingTo) && !this.isInitialized) return finish(null, this.t.bind(this));
|
|
3930
3934
|
this.changeLanguage(this.options.lng, finish);
|
|
3931
3935
|
};
|
|
3932
3936
|
if (this.options.resources || !this.options.initAsync) {
|