Changed stuff, added filter for statistics module
This commit is contained in:
parent
4a91ae2bf9
commit
fe87374e47
251 changed files with 3295 additions and 1705 deletions
49
node_modules/i18next/dist/cjs/i18next.js
generated
vendored
49
node_modules/i18next/dist/cjs/i18next.js
generated
vendored
|
|
@ -433,6 +433,27 @@ var postProcessor = {
|
|||
}
|
||||
};
|
||||
|
||||
const PATH_KEY = Symbol('i18next/PATH_KEY');
|
||||
function createProxy() {
|
||||
const state = [];
|
||||
const handler = Object.create(null);
|
||||
let proxy;
|
||||
handler.get = (target, key) => {
|
||||
proxy?.revoke?.();
|
||||
if (key === PATH_KEY) return state;
|
||||
state.push(key);
|
||||
proxy = Proxy.revocable(target, handler);
|
||||
return proxy.proxy;
|
||||
};
|
||||
return Proxy.revocable(Object.create(null), handler).proxy;
|
||||
}
|
||||
function keysFromSelector(selector, opts) {
|
||||
const {
|
||||
[PATH_KEY]: path
|
||||
} = selector(createProxy());
|
||||
return path.join(opts?.keySeparator ?? '.');
|
||||
}
|
||||
|
||||
const checkedLoadedFor = {};
|
||||
const shouldHandleAsObject = res => !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
|
||||
class Translator extends EventEmitter {
|
||||
|
|
@ -489,11 +510,15 @@ class Translator extends EventEmitter {
|
|||
if (typeof opt !== 'object' && this.options.overloadTranslationOptionHandler) {
|
||||
opt = this.options.overloadTranslationOptionHandler(arguments);
|
||||
}
|
||||
if (typeof options === 'object') opt = {
|
||||
if (typeof opt === 'object') opt = {
|
||||
...opt
|
||||
};
|
||||
if (!opt) opt = {};
|
||||
if (keys == null) return '';
|
||||
if (typeof keys === 'function') keys = keysFromSelector(keys, {
|
||||
...this.options,
|
||||
...opt
|
||||
});
|
||||
if (!Array.isArray(keys)) keys = [String(keys)];
|
||||
const returnDetails = opt.returnDetails !== undefined ? opt.returnDetails : this.options.returnDetails;
|
||||
const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
|
||||
|
|
@ -771,22 +796,22 @@ class Translator extends EventEmitter {
|
|||
const zeroSuffix = `${this.options.pluralSeparator}zero`;
|
||||
const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
||||
if (needsPluralHandling) {
|
||||
finalKeys.push(key + pluralSuffix);
|
||||
if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
|
||||
finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
||||
}
|
||||
finalKeys.push(key + pluralSuffix);
|
||||
if (needsZeroSuffixLookup) {
|
||||
finalKeys.push(key + zeroSuffix);
|
||||
}
|
||||
}
|
||||
if (needsContextHandling) {
|
||||
const contextKey = `${key}${this.options.contextSeparator}${opt.context}`;
|
||||
const contextKey = `${key}${this.options.contextSeparator || '_'}${opt.context}`;
|
||||
finalKeys.push(contextKey);
|
||||
if (needsPluralHandling) {
|
||||
finalKeys.push(contextKey + pluralSuffix);
|
||||
if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
|
||||
finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
||||
}
|
||||
finalKeys.push(contextKey + pluralSuffix);
|
||||
if (needsZeroSuffixLookup) {
|
||||
finalKeys.push(contextKey + zeroSuffix);
|
||||
}
|
||||
|
|
@ -1105,7 +1130,7 @@ class Interpolator {
|
|||
};
|
||||
this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
|
||||
this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
|
||||
this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
|
||||
this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
|
||||
}
|
||||
interpolate(str, data, lng, options) {
|
||||
let match;
|
||||
|
|
@ -1750,7 +1775,7 @@ class I18n extends EventEmitter {
|
|||
});
|
||||
const usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
|
||||
if (usingLegacyFormatFunction) {
|
||||
this.logger.warn(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
|
||||
this.logger.deprecate(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
|
||||
}
|
||||
if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
|
||||
s.formatter = createClassOnDemand(formatter);
|
||||
|
|
@ -1984,8 +2009,18 @@ class I18n extends EventEmitter {
|
|||
const keySeparator = this.options.keySeparator || '.';
|
||||
let resultKey;
|
||||
if (o.keyPrefix && Array.isArray(key)) {
|
||||
resultKey = key.map(k => `${o.keyPrefix}${keySeparator}${k}`);
|
||||
resultKey = key.map(k => {
|
||||
if (typeof k === 'function') k = keysFromSelector(k, {
|
||||
...this.options,
|
||||
...opts
|
||||
});
|
||||
return `${o.keyPrefix}${keySeparator}${k}`;
|
||||
});
|
||||
} else {
|
||||
if (typeof key === 'function') key = keysFromSelector(key, {
|
||||
...this.options,
|
||||
...opts
|
||||
});
|
||||
resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
|
||||
}
|
||||
return this.t(resultKey, o);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue