@uipath/maestro-sdk 1.207.0-preview.360 → 1.207.0-preview.362
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/THIRD-PARTY-NOTICES.md +3 -3
- package/dist/bpmn-packaging/index.js +7 -1
- package/dist/bpmn-validation/project-validator.js +84 -2
- package/dist/connector-spec/index.js +806 -718
- package/dist/index.js +893 -723
- package/dist/manifest/bpmn-spec.js +2 -1
- package/dist/registry/command.js +808 -720
- package/package.json +2 -2
|
@@ -1121,7 +1121,7 @@ var init_package = __esm(() => {
|
|
|
1121
1121
|
name: "@uipath/integrationservice-sdk",
|
|
1122
1122
|
author: "UiPath",
|
|
1123
1123
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
1124
|
-
version: "1.207.0-preview.
|
|
1124
|
+
version: "1.207.0-preview.362",
|
|
1125
1125
|
repository: {
|
|
1126
1126
|
type: "git",
|
|
1127
1127
|
url: "https://github.com/UiPath/cli.git",
|
|
@@ -151012,44 +151012,38 @@ class RegExpCache {
|
|
|
151012
151012
|
}
|
|
151013
151013
|
|
|
151014
151014
|
class Logger4 {
|
|
151015
|
-
constructor(concreteLogger) {
|
|
151016
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
151015
|
+
constructor(concreteLogger, options = {}) {
|
|
151017
151016
|
this.init(concreteLogger, options);
|
|
151018
151017
|
}
|
|
151019
|
-
init(concreteLogger) {
|
|
151020
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
151018
|
+
init(concreteLogger, options = {}) {
|
|
151021
151019
|
this.prefix = options.prefix || "i18next:";
|
|
151022
151020
|
this.logger = concreteLogger || consoleLogger;
|
|
151023
151021
|
this.options = options;
|
|
151024
151022
|
this.debug = options.debug;
|
|
151023
|
+
this.seen = new Set;
|
|
151025
151024
|
}
|
|
151026
|
-
log() {
|
|
151027
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0;_key < _len; _key++) {
|
|
151028
|
-
args[_key] = arguments[_key];
|
|
151029
|
-
}
|
|
151025
|
+
log(...args) {
|
|
151030
151026
|
return this.forward(args, "log", "", true);
|
|
151031
151027
|
}
|
|
151032
|
-
warn() {
|
|
151033
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0;_key2 < _len2; _key2++) {
|
|
151034
|
-
args[_key2] = arguments[_key2];
|
|
151035
|
-
}
|
|
151028
|
+
warn(...args) {
|
|
151036
151029
|
return this.forward(args, "warn", "", true);
|
|
151037
151030
|
}
|
|
151038
|
-
error() {
|
|
151039
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0;_key3 < _len3; _key3++) {
|
|
151040
|
-
args[_key3] = arguments[_key3];
|
|
151041
|
-
}
|
|
151031
|
+
error(...args) {
|
|
151042
151032
|
return this.forward(args, "error", "");
|
|
151043
151033
|
}
|
|
151044
|
-
deprecate() {
|
|
151045
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0;_key4 < _len4; _key4++) {
|
|
151046
|
-
args[_key4] = arguments[_key4];
|
|
151047
|
-
}
|
|
151034
|
+
deprecate(...args) {
|
|
151048
151035
|
return this.forward(args, "warn", "WARNING DEPRECATED: ", true);
|
|
151049
151036
|
}
|
|
151037
|
+
once(key, lvl, ...args) {
|
|
151038
|
+
if (!this.debug || this.seen.has(key) || this.seen.size >= 1000)
|
|
151039
|
+
return null;
|
|
151040
|
+
this.seen.add(key);
|
|
151041
|
+
return this[lvl](...args);
|
|
151042
|
+
}
|
|
151050
151043
|
forward(args, lvl, prefix, debugOnly) {
|
|
151051
151044
|
if (debugOnly && !this.debug)
|
|
151052
151045
|
return null;
|
|
151046
|
+
args = args.map((a) => isString2(a) ? a.replace(/[\r\n\x00-\x1F\x7F]/g, " ") : a);
|
|
151053
151047
|
if (isString2(args[0]))
|
|
151054
151048
|
args[0] = `${prefix}${this.prefix} ${args[0]}`;
|
|
151055
151049
|
return this.logger[lvl](args);
|
|
@@ -151082,23 +151076,29 @@ class EventEmitter {
|
|
|
151082
151076
|
});
|
|
151083
151077
|
return this;
|
|
151084
151078
|
}
|
|
151085
|
-
off(
|
|
151086
|
-
|
|
151087
|
-
|
|
151088
|
-
|
|
151089
|
-
|
|
151090
|
-
|
|
151091
|
-
|
|
151092
|
-
|
|
151079
|
+
off(events, listener) {
|
|
151080
|
+
(typeof events === "string" ? events.split(" ") : [events]).forEach((event) => {
|
|
151081
|
+
if (!this.observers[event])
|
|
151082
|
+
return;
|
|
151083
|
+
if (!listener) {
|
|
151084
|
+
delete this.observers[event];
|
|
151085
|
+
return;
|
|
151086
|
+
}
|
|
151087
|
+
this.observers[event].delete(listener);
|
|
151088
|
+
});
|
|
151093
151089
|
}
|
|
151094
|
-
|
|
151095
|
-
|
|
151096
|
-
args
|
|
151097
|
-
|
|
151090
|
+
once(event, listener) {
|
|
151091
|
+
const wrapper = (...args) => {
|
|
151092
|
+
listener(...args);
|
|
151093
|
+
this.off(event, wrapper);
|
|
151094
|
+
};
|
|
151095
|
+
this.on(event, wrapper);
|
|
151096
|
+
return this;
|
|
151097
|
+
}
|
|
151098
|
+
emit(event, ...args) {
|
|
151098
151099
|
if (this.observers[event]) {
|
|
151099
151100
|
const cloned = Array.from(this.observers[event].entries());
|
|
151100
|
-
cloned.forEach((
|
|
151101
|
-
let [observer, numTimesAdded] = _ref;
|
|
151101
|
+
cloned.forEach(([observer, numTimesAdded]) => {
|
|
151102
151102
|
for (let i = 0;i < numTimesAdded; i++) {
|
|
151103
151103
|
observer(...args);
|
|
151104
151104
|
}
|
|
@@ -151106,25 +151106,61 @@ class EventEmitter {
|
|
|
151106
151106
|
}
|
|
151107
151107
|
if (this.observers["*"]) {
|
|
151108
151108
|
const cloned = Array.from(this.observers["*"].entries());
|
|
151109
|
-
cloned.forEach((
|
|
151110
|
-
let [observer, numTimesAdded] = _ref2;
|
|
151109
|
+
cloned.forEach(([observer, numTimesAdded]) => {
|
|
151111
151110
|
for (let i = 0;i < numTimesAdded; i++) {
|
|
151112
|
-
observer
|
|
151111
|
+
observer(event, ...args);
|
|
151113
151112
|
}
|
|
151114
151113
|
});
|
|
151115
151114
|
}
|
|
151116
151115
|
}
|
|
151117
151116
|
}
|
|
151117
|
+
function createProxy() {
|
|
151118
|
+
const state = [];
|
|
151119
|
+
const handler = Object.create(null);
|
|
151120
|
+
let proxy;
|
|
151121
|
+
handler.get = (target, key) => {
|
|
151122
|
+
proxy?.revoke?.();
|
|
151123
|
+
if (key === PATH_KEY)
|
|
151124
|
+
return state;
|
|
151125
|
+
state.push(key);
|
|
151126
|
+
proxy = Proxy.revocable(target, handler);
|
|
151127
|
+
return proxy.proxy;
|
|
151128
|
+
};
|
|
151129
|
+
return Proxy.revocable(Object.create(null), handler).proxy;
|
|
151130
|
+
}
|
|
151131
|
+
function keysFromSelector(selector, opts) {
|
|
151132
|
+
const {
|
|
151133
|
+
[PATH_KEY]: path
|
|
151134
|
+
} = selector(createProxy());
|
|
151135
|
+
const keySeparator = opts?.keySeparator ?? ".";
|
|
151136
|
+
const nsSeparator = opts?.nsSeparator ?? ":";
|
|
151137
|
+
const strict = opts?.enableSelector === "strict";
|
|
151138
|
+
if (path.length > 1 && nsSeparator) {
|
|
151139
|
+
const ns = opts?.ns;
|
|
151140
|
+
const nsList = strict ? Array.isArray(ns) ? ns : ns ? [ns] : null : Array.isArray(ns) ? ns : null;
|
|
151141
|
+
if (nsList) {
|
|
151142
|
+
const candidates = strict ? nsList : nsList.length > 1 ? nsList.slice(1) : [];
|
|
151143
|
+
if (candidates.includes(path[0])) {
|
|
151144
|
+
return `${path[0]}${nsSeparator}${path.slice(1).join(keySeparator)}`;
|
|
151145
|
+
}
|
|
151146
|
+
}
|
|
151147
|
+
}
|
|
151148
|
+
return path.join(keySeparator);
|
|
151149
|
+
}
|
|
151118
151150
|
|
|
151119
151151
|
class LanguageUtil {
|
|
151120
151152
|
constructor(options) {
|
|
151121
151153
|
this.options = options;
|
|
151122
151154
|
this.supportedLngs = this.options.supportedLngs || false;
|
|
151123
151155
|
this.logger = baseLogger.create("languageUtils");
|
|
151156
|
+
this.resolveHierarchyCache = {};
|
|
151157
|
+
}
|
|
151158
|
+
clearCache() {
|
|
151159
|
+
this.resolveHierarchyCache = {};
|
|
151124
151160
|
}
|
|
151125
151161
|
getScriptPartFromCode(code) {
|
|
151126
151162
|
code = getCleanedCode(code);
|
|
151127
|
-
if (!code || code.
|
|
151163
|
+
if (!code || !code.includes("-"))
|
|
151128
151164
|
return null;
|
|
151129
151165
|
const p = code.split("-");
|
|
151130
151166
|
if (p.length === 2)
|
|
@@ -151136,52 +151172,51 @@ class LanguageUtil {
|
|
|
151136
151172
|
}
|
|
151137
151173
|
getLanguagePartFromCode(code) {
|
|
151138
151174
|
code = getCleanedCode(code);
|
|
151139
|
-
if (!code || code.
|
|
151175
|
+
if (!code || !code.includes("-"))
|
|
151140
151176
|
return code;
|
|
151141
151177
|
const p = code.split("-");
|
|
151142
151178
|
return this.formatLanguageCode(p[0]);
|
|
151143
151179
|
}
|
|
151144
151180
|
formatLanguageCode(code) {
|
|
151145
|
-
if (isString2(code) && code.
|
|
151146
|
-
|
|
151147
|
-
|
|
151148
|
-
|
|
151149
|
-
|
|
151150
|
-
|
|
151151
|
-
|
|
151152
|
-
if (formattedCode)
|
|
151153
|
-
return formattedCode;
|
|
151154
|
-
} catch (e) {}
|
|
151181
|
+
if (isString2(code) && code.includes("-")) {
|
|
151182
|
+
let formattedCode;
|
|
151183
|
+
try {
|
|
151184
|
+
formattedCode = Intl.getCanonicalLocales(code)[0];
|
|
151185
|
+
} catch (e) {}
|
|
151186
|
+
if (formattedCode && this.options.lowerCaseLng) {
|
|
151187
|
+
formattedCode = formattedCode.toLowerCase();
|
|
151155
151188
|
}
|
|
151156
|
-
|
|
151157
|
-
|
|
151189
|
+
if (formattedCode)
|
|
151190
|
+
return formattedCode;
|
|
151158
151191
|
if (this.options.lowerCaseLng) {
|
|
151159
|
-
|
|
151160
|
-
}
|
|
151161
|
-
|
|
151162
|
-
|
|
151163
|
-
|
|
151164
|
-
|
|
151165
|
-
|
|
151166
|
-
|
|
151167
|
-
|
|
151168
|
-
|
|
151169
|
-
|
|
151170
|
-
|
|
151171
|
-
|
|
151172
|
-
|
|
151173
|
-
|
|
151174
|
-
|
|
151175
|
-
|
|
151176
|
-
|
|
151177
|
-
|
|
151178
|
-
|
|
151192
|
+
return code.toLowerCase();
|
|
151193
|
+
}
|
|
151194
|
+
return code;
|
|
151195
|
+
}
|
|
151196
|
+
const formatted = this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
|
|
151197
|
+
if (this.logger.debug && isString2(code))
|
|
151198
|
+
this.deprecateBareCode(code, formatted);
|
|
151199
|
+
return formatted;
|
|
151200
|
+
}
|
|
151201
|
+
deprecateBareCode(code, formatted) {
|
|
151202
|
+
let canonical;
|
|
151203
|
+
try {
|
|
151204
|
+
canonical = Intl.getCanonicalLocales(code)[0];
|
|
151205
|
+
} catch (e) {
|
|
151206
|
+
return;
|
|
151207
|
+
}
|
|
151208
|
+
let v27 = canonical.toLowerCase() === code.toLowerCase() ? canonical : code.toLowerCase();
|
|
151209
|
+
if (this.options.lowerCaseLng)
|
|
151210
|
+
v27 = v27.toLowerCase();
|
|
151211
|
+
if (v27 === formatted)
|
|
151212
|
+
return;
|
|
151213
|
+
this.logger.once(code, "deprecate", `language code '${code}' is used as '${formatted}'; i18next v27 gives it the canonical casing '${v27}', use '${v27}' in lng, fallbackLng, supportedLngs and the resources`);
|
|
151179
151214
|
}
|
|
151180
151215
|
isSupportedCode(code) {
|
|
151181
151216
|
if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) {
|
|
151182
151217
|
code = this.getLanguagePartFromCode(code);
|
|
151183
151218
|
}
|
|
151184
|
-
return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.
|
|
151219
|
+
return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.includes(code);
|
|
151185
151220
|
}
|
|
151186
151221
|
getBestMatchFromCodes(codes) {
|
|
151187
151222
|
if (!codes)
|
|
@@ -151198,18 +151233,20 @@ class LanguageUtil {
|
|
|
151198
151233
|
codes.forEach((code) => {
|
|
151199
151234
|
if (found)
|
|
151200
151235
|
return;
|
|
151236
|
+
const lngScOnly = this.getScriptPartFromCode(code);
|
|
151237
|
+
if (this.isSupportedCode(lngScOnly))
|
|
151238
|
+
return found = lngScOnly;
|
|
151201
151239
|
const lngOnly = this.getLanguagePartFromCode(code);
|
|
151202
151240
|
if (this.isSupportedCode(lngOnly))
|
|
151203
151241
|
return found = lngOnly;
|
|
151204
151242
|
found = this.options.supportedLngs.find((supportedLng) => {
|
|
151205
151243
|
if (supportedLng === lngOnly)
|
|
151206
|
-
return
|
|
151207
|
-
if (supportedLng.
|
|
151208
|
-
return;
|
|
151209
|
-
if (supportedLng.
|
|
151210
|
-
return
|
|
151211
|
-
|
|
151212
|
-
return supportedLng;
|
|
151244
|
+
return true;
|
|
151245
|
+
if (!supportedLng.includes("-") && !lngOnly.includes("-"))
|
|
151246
|
+
return false;
|
|
151247
|
+
if (supportedLng.includes("-") && !lngOnly.includes("-") && supportedLng.slice(0, supportedLng.indexOf("-")) === lngOnly)
|
|
151248
|
+
return true;
|
|
151249
|
+
return false;
|
|
151213
151250
|
});
|
|
151214
151251
|
});
|
|
151215
151252
|
}
|
|
@@ -151240,7 +151277,32 @@ class LanguageUtil {
|
|
|
151240
151277
|
return found || [];
|
|
151241
151278
|
}
|
|
151242
151279
|
toResolveHierarchy(code, fallbackCode) {
|
|
151243
|
-
const
|
|
151280
|
+
const fallbackLng = this.options.fallbackLng;
|
|
151281
|
+
const fallbackLngKey = Array.isArray(fallbackLng) ? fallbackLng.join("|") : fallbackLng;
|
|
151282
|
+
if (fallbackLngKey !== this._cachedFallbackLng) {
|
|
151283
|
+
this.resolveHierarchyCache = {};
|
|
151284
|
+
this._cachedFallbackLng = fallbackLngKey;
|
|
151285
|
+
}
|
|
151286
|
+
const hasCacheableFallback = fallbackCode === undefined || fallbackCode === false || isString2(fallbackCode);
|
|
151287
|
+
const usesUncacheableOptionsFallback = fallbackCode === undefined && typeof this.options.fallbackLng === "function";
|
|
151288
|
+
const cacheable = isString2(code) && hasCacheableFallback && !usesUncacheableOptionsFallback;
|
|
151289
|
+
let cacheKey = null;
|
|
151290
|
+
if (cacheable) {
|
|
151291
|
+
let fallbackCacheKey;
|
|
151292
|
+
if (fallbackCode === undefined)
|
|
151293
|
+
fallbackCacheKey = "undefined";
|
|
151294
|
+
else if (fallbackCode === false)
|
|
151295
|
+
fallbackCacheKey = "boolean:false";
|
|
151296
|
+
else
|
|
151297
|
+
fallbackCacheKey = `string:${fallbackCode}`;
|
|
151298
|
+
cacheKey = `${code.length}:${code}|${fallbackCacheKey}`;
|
|
151299
|
+
}
|
|
151300
|
+
if (cacheKey !== null) {
|
|
151301
|
+
const cached = this.resolveHierarchyCache[cacheKey];
|
|
151302
|
+
if (cached !== undefined)
|
|
151303
|
+
return cached.slice();
|
|
151304
|
+
}
|
|
151305
|
+
const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
|
|
151244
151306
|
const codes = [];
|
|
151245
151307
|
const addCode = (c) => {
|
|
151246
151308
|
if (!c)
|
|
@@ -151251,7 +151313,7 @@ class LanguageUtil {
|
|
|
151251
151313
|
this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
|
|
151252
151314
|
}
|
|
151253
151315
|
};
|
|
151254
|
-
if (isString2(code) && (code.
|
|
151316
|
+
if (isString2(code) && (code.includes("-") || code.includes("_"))) {
|
|
151255
151317
|
if (this.options.load !== "languageOnly")
|
|
151256
151318
|
addCode(this.formatLanguageCode(code));
|
|
151257
151319
|
if (this.options.load !== "languageOnly" && this.options.load !== "currentOnly")
|
|
@@ -151262,134 +151324,91 @@ class LanguageUtil {
|
|
|
151262
151324
|
addCode(this.formatLanguageCode(code));
|
|
151263
151325
|
}
|
|
151264
151326
|
fallbackCodes.forEach((fc) => {
|
|
151265
|
-
|
|
151266
|
-
|
|
151327
|
+
const formattedFc = this.formatLanguageCode(fc);
|
|
151328
|
+
if (!codes.includes(formattedFc))
|
|
151329
|
+
addCode(formattedFc);
|
|
151267
151330
|
});
|
|
151331
|
+
if (cacheKey !== null) {
|
|
151332
|
+
this.resolveHierarchyCache[cacheKey] = codes;
|
|
151333
|
+
return codes.slice();
|
|
151334
|
+
}
|
|
151268
151335
|
return codes;
|
|
151269
151336
|
}
|
|
151270
151337
|
}
|
|
151271
151338
|
|
|
151272
151339
|
class PluralResolver {
|
|
151273
|
-
constructor(languageUtils) {
|
|
151274
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
151340
|
+
constructor(languageUtils, options = {}) {
|
|
151275
151341
|
this.languageUtils = languageUtils;
|
|
151276
151342
|
this.options = options;
|
|
151277
151343
|
this.logger = baseLogger.create("pluralResolver");
|
|
151278
|
-
if ((!this.options.compatibilityJSON || intlVersions.includes(this.options.compatibilityJSON)) && (typeof Intl === "undefined" || !Intl.PluralRules)) {
|
|
151279
|
-
this.options.compatibilityJSON = "v3";
|
|
151280
|
-
this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.");
|
|
151281
|
-
}
|
|
151282
|
-
this.rules = createRules();
|
|
151283
151344
|
this.pluralRulesCache = {};
|
|
151284
151345
|
}
|
|
151285
|
-
addRule(lng, obj) {
|
|
151286
|
-
this.rules[lng] = obj;
|
|
151287
|
-
}
|
|
151288
151346
|
clearCache() {
|
|
151289
151347
|
this.pluralRulesCache = {};
|
|
151290
151348
|
}
|
|
151291
|
-
getRule(code) {
|
|
151292
|
-
|
|
151293
|
-
|
|
151294
|
-
|
|
151295
|
-
|
|
151296
|
-
|
|
151297
|
-
|
|
151349
|
+
getRule(code, options = {}) {
|
|
151350
|
+
const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
|
|
151351
|
+
const type = options.ordinal ? "ordinal" : "cardinal";
|
|
151352
|
+
const cacheKey = JSON.stringify({
|
|
151353
|
+
cleanedCode,
|
|
151354
|
+
type
|
|
151355
|
+
});
|
|
151356
|
+
if (cacheKey in this.pluralRulesCache) {
|
|
151357
|
+
return this.pluralRulesCache[cacheKey];
|
|
151358
|
+
}
|
|
151359
|
+
let rule;
|
|
151360
|
+
try {
|
|
151361
|
+
rule = new Intl.PluralRules(cleanedCode, {
|
|
151298
151362
|
type
|
|
151299
151363
|
});
|
|
151300
|
-
|
|
151301
|
-
|
|
151302
|
-
|
|
151303
|
-
|
|
151304
|
-
try {
|
|
151305
|
-
rule = new Intl.PluralRules(cleanedCode, {
|
|
151306
|
-
type
|
|
151307
|
-
});
|
|
151308
|
-
} catch (err) {
|
|
151309
|
-
if (!code.match(/-|_/))
|
|
151310
|
-
return;
|
|
151311
|
-
const lngPart = this.languageUtils.getLanguagePartFromCode(code);
|
|
151312
|
-
rule = this.getRule(lngPart, options);
|
|
151364
|
+
} catch (err) {
|
|
151365
|
+
if (typeof Intl === "undefined") {
|
|
151366
|
+
this.logger.error("No Intl support, please use an Intl polyfill!");
|
|
151367
|
+
return dummyRule;
|
|
151313
151368
|
}
|
|
151314
|
-
|
|
151315
|
-
|
|
151369
|
+
if (!code.match(/-|_/))
|
|
151370
|
+
return dummyRule;
|
|
151371
|
+
const lngPart = this.languageUtils.getLanguagePartFromCode(code);
|
|
151372
|
+
rule = this.getRule(lngPart, options);
|
|
151316
151373
|
}
|
|
151317
|
-
|
|
151374
|
+
this.pluralRulesCache[cacheKey] = rule;
|
|
151375
|
+
return rule;
|
|
151318
151376
|
}
|
|
151319
|
-
needsPlural(code) {
|
|
151320
|
-
let
|
|
151321
|
-
|
|
151322
|
-
|
|
151323
|
-
|
|
151324
|
-
}
|
|
151325
|
-
return rule && rule.numbers.length > 1;
|
|
151377
|
+
needsPlural(code, options = {}) {
|
|
151378
|
+
let rule = this.getRule(code, options);
|
|
151379
|
+
if (!rule)
|
|
151380
|
+
rule = this.getRule("dev", options);
|
|
151381
|
+
return rule?.resolvedOptions().pluralCategories.length > 1;
|
|
151326
151382
|
}
|
|
151327
|
-
getPluralFormsOfKey(code, key) {
|
|
151328
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
151383
|
+
getPluralFormsOfKey(code, key, options = {}) {
|
|
151329
151384
|
return this.getSuffixes(code, options).map((suffix) => `${key}${suffix}`);
|
|
151330
151385
|
}
|
|
151331
|
-
getSuffixes(code) {
|
|
151332
|
-
let
|
|
151333
|
-
|
|
151334
|
-
|
|
151386
|
+
getSuffixes(code, options = {}) {
|
|
151387
|
+
let rule = this.getRule(code, options);
|
|
151388
|
+
if (!rule)
|
|
151389
|
+
rule = this.getRule("dev", options);
|
|
151390
|
+
if (!rule)
|
|
151335
151391
|
return [];
|
|
151336
|
-
}
|
|
151337
|
-
if (this.shouldUseIntlApi()) {
|
|
151338
|
-
return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
|
|
151339
|
-
}
|
|
151340
|
-
return rule.numbers.map((number) => this.getSuffix(code, number, options));
|
|
151392
|
+
return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
|
|
151341
151393
|
}
|
|
151342
|
-
getSuffix(code, count) {
|
|
151343
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
151394
|
+
getSuffix(code, count, options = {}) {
|
|
151344
151395
|
const rule = this.getRule(code, options);
|
|
151345
151396
|
if (rule) {
|
|
151346
|
-
|
|
151347
|
-
return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
|
|
151348
|
-
}
|
|
151349
|
-
return this.getSuffixRetroCompatible(rule, count);
|
|
151397
|
+
return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
|
|
151350
151398
|
}
|
|
151351
151399
|
this.logger.warn(`no plural rule found for: ${code}`);
|
|
151352
|
-
return "";
|
|
151353
|
-
}
|
|
151354
|
-
getSuffixRetroCompatible(rule, count) {
|
|
151355
|
-
const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
|
|
151356
|
-
let suffix = rule.numbers[idx];
|
|
151357
|
-
if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
|
151358
|
-
if (suffix === 2) {
|
|
151359
|
-
suffix = "plural";
|
|
151360
|
-
} else if (suffix === 1) {
|
|
151361
|
-
suffix = "";
|
|
151362
|
-
}
|
|
151363
|
-
}
|
|
151364
|
-
const returnSuffix = () => this.options.prepend && suffix.toString() ? this.options.prepend + suffix.toString() : suffix.toString();
|
|
151365
|
-
if (this.options.compatibilityJSON === "v1") {
|
|
151366
|
-
if (suffix === 1)
|
|
151367
|
-
return "";
|
|
151368
|
-
if (typeof suffix === "number")
|
|
151369
|
-
return `_plural_${suffix.toString()}`;
|
|
151370
|
-
return returnSuffix();
|
|
151371
|
-
} else if (this.options.compatibilityJSON === "v2") {
|
|
151372
|
-
return returnSuffix();
|
|
151373
|
-
} else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
|
151374
|
-
return returnSuffix();
|
|
151375
|
-
}
|
|
151376
|
-
return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
|
|
151377
|
-
}
|
|
151378
|
-
shouldUseIntlApi() {
|
|
151379
|
-
return !nonIntlVersions.includes(this.options.compatibilityJSON);
|
|
151400
|
+
return this.getSuffix("dev", count, options);
|
|
151380
151401
|
}
|
|
151381
151402
|
}
|
|
151382
151403
|
|
|
151383
151404
|
class Interpolator {
|
|
151384
|
-
constructor() {
|
|
151385
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
151405
|
+
constructor(options = {}) {
|
|
151386
151406
|
this.logger = baseLogger.create("interpolator");
|
|
151387
151407
|
this.options = options;
|
|
151388
|
-
this.format = options
|
|
151408
|
+
this.format = options?.interpolation?.format || ((value) => value);
|
|
151389
151409
|
this.init(options);
|
|
151390
151410
|
}
|
|
151391
|
-
init() {
|
|
151392
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
151411
|
+
init(options = {}) {
|
|
151393
151412
|
if (!options.interpolation)
|
|
151394
151413
|
options.interpolation = {
|
|
151395
151414
|
escapeValue: true
|
|
@@ -151413,14 +151432,23 @@ class Interpolator {
|
|
|
151413
151432
|
maxReplaces,
|
|
151414
151433
|
alwaysFormat
|
|
151415
151434
|
} = options.interpolation;
|
|
151435
|
+
if (prefixEscaped || suffixEscaped || nestingPrefixEscaped || nestingSuffixEscaped) {
|
|
151436
|
+
const names = Object.entries({
|
|
151437
|
+
prefixEscaped,
|
|
151438
|
+
suffixEscaped,
|
|
151439
|
+
nestingPrefixEscaped,
|
|
151440
|
+
nestingSuffixEscaped
|
|
151441
|
+
}).filter(([, v]) => v).map(([k]) => k);
|
|
151442
|
+
this.logger.once(names.join(), "deprecate", `interpolation.${names.join(", interpolation.")}: the regex-escaped delimiter options are removed in v27; pass the literal delimiters as prefix, suffix, nestingPrefix and nestingSuffix`);
|
|
151443
|
+
}
|
|
151416
151444
|
this.escape = escape$1 !== undefined ? escape$1 : escape3;
|
|
151417
151445
|
this.escapeValue = escapeValue !== undefined ? escapeValue : true;
|
|
151418
151446
|
this.useRawValueToEscape = useRawValueToEscape !== undefined ? useRawValueToEscape : false;
|
|
151419
151447
|
this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || "{{";
|
|
151420
151448
|
this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
|
|
151421
151449
|
this.formatSeparator = formatSeparator || ",";
|
|
151422
|
-
this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix
|
|
151423
|
-
this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix
|
|
151450
|
+
this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix ? regexEscape(unescapePrefix) : "-";
|
|
151451
|
+
this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix ? regexEscape(unescapeSuffix) : "";
|
|
151424
151452
|
this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
|
|
151425
151453
|
this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
|
|
151426
151454
|
this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
|
|
@@ -151434,7 +151462,7 @@ class Interpolator {
|
|
|
151434
151462
|
}
|
|
151435
151463
|
resetRegExp() {
|
|
151436
151464
|
const getOrResetRegExp = (existingRegExp, pattern) => {
|
|
151437
|
-
if (existingRegExp
|
|
151465
|
+
if (existingRegExp?.source === pattern) {
|
|
151438
151466
|
existingRegExp.lastIndex = 0;
|
|
151439
151467
|
return existingRegExp;
|
|
151440
151468
|
}
|
|
@@ -151442,15 +151470,16 @@ class Interpolator {
|
|
|
151442
151470
|
};
|
|
151443
151471
|
this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
|
|
151444
151472
|
this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
|
|
151445
|
-
this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(
|
|
151473
|
+
this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']|"[^"]*"|'[^']*'|\\((?:[^()"']|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
|
|
151446
151474
|
}
|
|
151447
151475
|
interpolate(str, data, lng, options) {
|
|
151448
151476
|
let match;
|
|
151449
151477
|
let value;
|
|
151450
151478
|
let replaces;
|
|
151479
|
+
const original = str;
|
|
151451
151480
|
const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
|
|
151452
151481
|
const handleFormat = (key) => {
|
|
151453
|
-
if (key.
|
|
151482
|
+
if (!key.includes(this.formatSeparator)) {
|
|
151454
151483
|
const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
151455
151484
|
return this.alwaysFormat ? this.format(path, undefined, lng, {
|
|
151456
151485
|
...options,
|
|
@@ -151468,18 +151497,36 @@ class Interpolator {
|
|
|
151468
151497
|
});
|
|
151469
151498
|
};
|
|
151470
151499
|
this.resetRegExp();
|
|
151471
|
-
|
|
151472
|
-
|
|
151500
|
+
if (!this.escapeValue && typeof str === "string" && /\$t\([^)]*\{[^}]*\{\{/.test(str)) {
|
|
151501
|
+
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.");
|
|
151502
|
+
}
|
|
151503
|
+
const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
|
|
151504
|
+
const skipOnVariables = options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
151473
151505
|
const todos = [{
|
|
151474
151506
|
regex: this.regexpUnescape,
|
|
151475
|
-
safeValue: (val) =>
|
|
151507
|
+
safeValue: (val) => val
|
|
151476
151508
|
}, {
|
|
151477
151509
|
regex: this.regexp,
|
|
151478
|
-
safeValue: (val) =>
|
|
151510
|
+
safeValue: (val) => {
|
|
151511
|
+
if (!this.escapeValue)
|
|
151512
|
+
return val;
|
|
151513
|
+
if (this.escape === escape3 && this.options?.interpolation?.escapeValue !== false && isString2(val) && val.includes("/")) {
|
|
151514
|
+
this.logger.once("/", "deprecate", "escapeValue renders '/' in a value as '/' today; from v27 the default escape leaves '/' as it is");
|
|
151515
|
+
}
|
|
151516
|
+
return this.escape(val);
|
|
151517
|
+
}
|
|
151479
151518
|
}];
|
|
151519
|
+
const unescapedValues = [];
|
|
151520
|
+
let shift = 0;
|
|
151480
151521
|
todos.forEach((todo) => {
|
|
151481
151522
|
replaces = 0;
|
|
151482
151523
|
while (match = todo.regex.exec(str)) {
|
|
151524
|
+
const at = match.index - shift;
|
|
151525
|
+
const written = unescapedValues.find(([start, end]) => at >= start && at < end);
|
|
151526
|
+
if (written) {
|
|
151527
|
+
todo.regex.lastIndex = written[1] + shift;
|
|
151528
|
+
continue;
|
|
151529
|
+
}
|
|
151483
151530
|
const matchedVar = match[1].trim();
|
|
151484
151531
|
value = handleFormat(matchedVar);
|
|
151485
151532
|
if (value === undefined) {
|
|
@@ -151489,6 +151536,9 @@ class Interpolator {
|
|
|
151489
151536
|
} else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
|
|
151490
151537
|
value = "";
|
|
151491
151538
|
} else if (skipOnVariables) {
|
|
151539
|
+
if (this.logger.debug) {
|
|
151540
|
+
this.logger.once(`${original}\x00${match[0]}`, "warn", `missed to pass in variable ${matchedVar} for interpolating ${original}`);
|
|
151541
|
+
}
|
|
151492
151542
|
value = match[0];
|
|
151493
151543
|
continue;
|
|
151494
151544
|
} else {
|
|
@@ -151498,10 +151548,15 @@ class Interpolator {
|
|
|
151498
151548
|
} else if (!isString2(value) && !this.useRawValueToEscape) {
|
|
151499
151549
|
value = makeString(value);
|
|
151500
151550
|
}
|
|
151501
|
-
const safeValue = todo.safeValue(value);
|
|
151502
|
-
str = str.
|
|
151551
|
+
const safeValue = makeString(todo.safeValue(value));
|
|
151552
|
+
str = str.slice(0, match.index) + safeValue + str.slice(match.index + match[0].length);
|
|
151503
151553
|
if (skipOnVariables) {
|
|
151504
|
-
todo.regex
|
|
151554
|
+
if (todo.regex === this.regexpUnescape) {
|
|
151555
|
+
unescapedValues.push([match.index, match.index + safeValue.length]);
|
|
151556
|
+
} else {
|
|
151557
|
+
shift += safeValue.length - match[0].length;
|
|
151558
|
+
}
|
|
151559
|
+
todo.regex.lastIndex += safeValue.length;
|
|
151505
151560
|
todo.regex.lastIndex -= match[0].length;
|
|
151506
151561
|
} else {
|
|
151507
151562
|
todo.regex.lastIndex = 0;
|
|
@@ -151514,22 +151569,21 @@ class Interpolator {
|
|
|
151514
151569
|
});
|
|
151515
151570
|
return str;
|
|
151516
151571
|
}
|
|
151517
|
-
nest(str, fc) {
|
|
151518
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
151572
|
+
nest(str, fc, options = {}) {
|
|
151519
151573
|
let match;
|
|
151520
151574
|
let value;
|
|
151521
151575
|
let clonedOptions;
|
|
151522
151576
|
const handleHasOptions = (key, inheritedOptions) => {
|
|
151523
151577
|
const sep = this.nestingOptionsSeparator;
|
|
151524
|
-
if (key.
|
|
151578
|
+
if (!key.includes(sep))
|
|
151525
151579
|
return key;
|
|
151526
|
-
const c = key.split(new RegExp(`${sep}[ ]*{`));
|
|
151580
|
+
const c = key.split(new RegExp(`${regexEscape(sep)}[ ]*{`));
|
|
151527
151581
|
let optionsString = `{${c[1]}`;
|
|
151528
151582
|
key = c[0];
|
|
151529
151583
|
optionsString = this.interpolate(optionsString, clonedOptions);
|
|
151530
151584
|
const matchedSingleQuotes = optionsString.match(/'/g);
|
|
151531
151585
|
const matchedDoubleQuotes = optionsString.match(/"/g);
|
|
151532
|
-
if (matchedSingleQuotes
|
|
151586
|
+
if ((matchedSingleQuotes?.length ?? 0) % 2 === 0 && !matchedDoubleQuotes || (matchedDoubleQuotes?.length ?? 0) % 2 !== 0) {
|
|
151533
151587
|
optionsString = optionsString.replace(/'/g, '"');
|
|
151534
151588
|
}
|
|
151535
151589
|
try {
|
|
@@ -151543,11 +151597,14 @@ class Interpolator {
|
|
|
151543
151597
|
this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
|
|
151544
151598
|
return `${key}${sep}${optionsString}`;
|
|
151545
151599
|
}
|
|
151546
|
-
if (clonedOptions.defaultValue && clonedOptions.defaultValue.
|
|
151600
|
+
if (clonedOptions.defaultValue && clonedOptions.defaultValue.includes(this.prefix))
|
|
151547
151601
|
delete clonedOptions.defaultValue;
|
|
151548
151602
|
return key;
|
|
151549
151603
|
};
|
|
151550
|
-
|
|
151604
|
+
const nestingRegexp = new RegExp(this.nestingRegexp);
|
|
151605
|
+
let out = "";
|
|
151606
|
+
let lastEnd = 0;
|
|
151607
|
+
while (match = nestingRegexp.exec(str)) {
|
|
151551
151608
|
let formatters = [];
|
|
151552
151609
|
clonedOptions = {
|
|
151553
151610
|
...options
|
|
@@ -151555,12 +151612,10 @@ class Interpolator {
|
|
|
151555
151612
|
clonedOptions = clonedOptions.replace && !isString2(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
|
|
151556
151613
|
clonedOptions.applyPostProcessor = false;
|
|
151557
151614
|
delete clonedOptions.defaultValue;
|
|
151558
|
-
|
|
151559
|
-
if (
|
|
151560
|
-
|
|
151561
|
-
match[1] =
|
|
151562
|
-
formatters = r;
|
|
151563
|
-
doReduce = true;
|
|
151615
|
+
const keyEndIndex = /{.*}/s.test(match[1]) ? match[1].lastIndexOf("}") + 1 : match[1].indexOf(this.formatSeparator);
|
|
151616
|
+
if (keyEndIndex !== -1) {
|
|
151617
|
+
formatters = match[1].slice(keyEndIndex).split(this.formatSeparator).map((elem) => elem.trim()).filter(Boolean);
|
|
151618
|
+
match[1] = match[1].slice(0, keyEndIndex);
|
|
151564
151619
|
}
|
|
151565
151620
|
value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
|
|
151566
151621
|
if (value && match[0] === str && !isString2(value))
|
|
@@ -151571,64 +151626,64 @@ class Interpolator {
|
|
|
151571
151626
|
this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
|
|
151572
151627
|
value = "";
|
|
151573
151628
|
}
|
|
151574
|
-
if (
|
|
151629
|
+
if (formatters.length) {
|
|
151575
151630
|
value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
|
|
151576
151631
|
...options,
|
|
151577
151632
|
interpolationkey: match[1].trim()
|
|
151578
151633
|
}), value.trim());
|
|
151579
151634
|
}
|
|
151580
|
-
|
|
151635
|
+
out += str.slice(lastEnd, match.index) + makeString(value);
|
|
151636
|
+
lastEnd = nestingRegexp.lastIndex;
|
|
151581
151637
|
this.regexp.lastIndex = 0;
|
|
151582
151638
|
}
|
|
151583
|
-
return str;
|
|
151639
|
+
return lastEnd ? out + str.slice(lastEnd) : str;
|
|
151584
151640
|
}
|
|
151585
151641
|
}
|
|
151586
151642
|
|
|
151587
151643
|
class Formatter2 {
|
|
151588
|
-
constructor() {
|
|
151589
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
151644
|
+
constructor(options = {}) {
|
|
151590
151645
|
this.logger = baseLogger.create("formatter");
|
|
151591
151646
|
this.options = options;
|
|
151647
|
+
this.init(options);
|
|
151648
|
+
}
|
|
151649
|
+
init(services, options = {
|
|
151650
|
+
interpolation: {}
|
|
151651
|
+
}) {
|
|
151652
|
+
this.formatSeparator = options.interpolation.formatSeparator || ",";
|
|
151653
|
+
const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
|
|
151592
151654
|
this.formats = {
|
|
151593
|
-
number:
|
|
151655
|
+
number: cf((lng, opt) => {
|
|
151594
151656
|
const formatter = new Intl.NumberFormat(lng, {
|
|
151595
151657
|
...opt
|
|
151596
151658
|
});
|
|
151597
151659
|
return (val) => formatter.format(val);
|
|
151598
151660
|
}),
|
|
151599
|
-
currency:
|
|
151661
|
+
currency: cf((lng, opt) => {
|
|
151600
151662
|
const formatter = new Intl.NumberFormat(lng, {
|
|
151601
151663
|
...opt,
|
|
151602
151664
|
style: "currency"
|
|
151603
151665
|
});
|
|
151604
151666
|
return (val) => formatter.format(val);
|
|
151605
151667
|
}),
|
|
151606
|
-
datetime:
|
|
151668
|
+
datetime: cf((lng, opt) => {
|
|
151607
151669
|
const formatter = new Intl.DateTimeFormat(lng, {
|
|
151608
151670
|
...opt
|
|
151609
151671
|
});
|
|
151610
151672
|
return (val) => formatter.format(val);
|
|
151611
151673
|
}),
|
|
151612
|
-
relativetime:
|
|
151674
|
+
relativetime: cf((lng, opt) => {
|
|
151613
151675
|
const formatter = new Intl.RelativeTimeFormat(lng, {
|
|
151614
151676
|
...opt
|
|
151615
151677
|
});
|
|
151616
151678
|
return (val) => formatter.format(val, opt.range || "day");
|
|
151617
151679
|
}),
|
|
151618
|
-
list:
|
|
151680
|
+
list: cf((lng, opt) => {
|
|
151619
151681
|
const formatter = new Intl.ListFormat(lng, {
|
|
151620
151682
|
...opt
|
|
151621
151683
|
});
|
|
151622
151684
|
return (val) => formatter.format(val);
|
|
151623
151685
|
})
|
|
151624
151686
|
};
|
|
151625
|
-
this.init(options);
|
|
151626
|
-
}
|
|
151627
|
-
init(services) {
|
|
151628
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
151629
|
-
interpolation: {}
|
|
151630
|
-
};
|
|
151631
|
-
this.formatSeparator = options.interpolation.formatSeparator || ",";
|
|
151632
151687
|
}
|
|
151633
151688
|
add(name, fc) {
|
|
151634
151689
|
this.formats[name.toLowerCase().trim()] = fc;
|
|
@@ -151636,12 +151691,19 @@ class Formatter2 {
|
|
|
151636
151691
|
addCached(name, fc) {
|
|
151637
151692
|
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
151638
151693
|
}
|
|
151639
|
-
format(value, format, lng) {
|
|
151640
|
-
|
|
151641
|
-
|
|
151642
|
-
if (
|
|
151643
|
-
|
|
151644
|
-
|
|
151694
|
+
format(value, format, lng, options = {}) {
|
|
151695
|
+
if (!format)
|
|
151696
|
+
return value;
|
|
151697
|
+
if (value == null)
|
|
151698
|
+
return value;
|
|
151699
|
+
const rawFormats = format.split(this.formatSeparator);
|
|
151700
|
+
const formats = [];
|
|
151701
|
+
for (let i = 0;i < rawFormats.length; i++) {
|
|
151702
|
+
let f = rawFormats[i];
|
|
151703
|
+
while (f.indexOf("(") > -1 && !f.includes(")") && i + 1 < rawFormats.length) {
|
|
151704
|
+
f = `${f}${this.formatSeparator}${rawFormats[++i]}`;
|
|
151705
|
+
}
|
|
151706
|
+
formats.push(f);
|
|
151645
151707
|
}
|
|
151646
151708
|
const result = formats.reduce((mem, f) => {
|
|
151647
151709
|
const {
|
|
@@ -151651,7 +151713,7 @@ class Formatter2 {
|
|
|
151651
151713
|
if (this.formats[formatName]) {
|
|
151652
151714
|
let formatted = mem;
|
|
151653
151715
|
try {
|
|
151654
|
-
const valOptions = options
|
|
151716
|
+
const valOptions = options?.formatParams?.[options.interpolationkey] || {};
|
|
151655
151717
|
const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
|
|
151656
151718
|
formatted = this.formats[formatName](mem, l, {
|
|
151657
151719
|
...formatOptions,
|
|
@@ -151683,13 +151745,13 @@ var isString2 = (obj) => typeof obj === "string", defer2 = () => {
|
|
|
151683
151745
|
}, makeString = (object) => {
|
|
151684
151746
|
if (object == null)
|
|
151685
151747
|
return "";
|
|
151686
|
-
return
|
|
151687
|
-
}, copy = (a, s, t) => {
|
|
151748
|
+
return String(object);
|
|
151749
|
+
}, isSafeLanguageCode = (code) => isString2(code) && /^[A-Za-z0-9_@.-]{1,128}$/.test(code) && !code.includes("..") && !["__proto__", "constructor", "prototype"].includes(code), callbackApiOf = (plugin) => plugin?.callbackApi ?? plugin?.constructor?.callbackApi, copy = (a, s, t) => {
|
|
151688
151750
|
a.forEach((m) => {
|
|
151689
151751
|
if (s[m])
|
|
151690
151752
|
t[m] = s[m];
|
|
151691
151753
|
});
|
|
151692
|
-
}, lastOfPathSeparatorRegExp, cleanKey = (key) => key && key.
|
|
151754
|
+
}, lastOfPathSeparatorRegExp, cleanKey = (key) => key && key.includes("###") ? key.replace(lastOfPathSeparatorRegExp, ".") : key, canNotTraverseDeeper = (object) => !object || isString2(object), getLastOfPath = (object, path, Empty) => {
|
|
151693
151755
|
const stack = !isString2(path) ? path : path.split(".");
|
|
151694
151756
|
let stackIndex = 0;
|
|
151695
151757
|
while (stackIndex < stack.length - 1) {
|
|
@@ -151727,7 +151789,7 @@ var isString2 = (obj) => typeof obj === "string", defer2 = () => {
|
|
|
151727
151789
|
e = `${p[p.length - 1]}.${e}`;
|
|
151728
151790
|
p = p.slice(0, p.length - 1);
|
|
151729
151791
|
last = getLastOfPath(object, p, Object);
|
|
151730
|
-
if (last
|
|
151792
|
+
if (last?.obj && typeof last.obj[`${last.k}.${e}`] !== "undefined") {
|
|
151731
151793
|
last.obj = undefined;
|
|
151732
151794
|
}
|
|
151733
151795
|
}
|
|
@@ -151746,6 +151808,8 @@ var isString2 = (obj) => typeof obj === "string", defer2 = () => {
|
|
|
151746
151808
|
} = getLastOfPath(object, path);
|
|
151747
151809
|
if (!obj)
|
|
151748
151810
|
return;
|
|
151811
|
+
if (!Object.prototype.hasOwnProperty.call(obj, k))
|
|
151812
|
+
return;
|
|
151749
151813
|
return obj[k];
|
|
151750
151814
|
}, getPathWithDefaults = (data, defaultData, key) => {
|
|
151751
151815
|
const value = getPath(data, key);
|
|
@@ -151756,7 +151820,7 @@ var isString2 = (obj) => typeof obj === "string", defer2 = () => {
|
|
|
151756
151820
|
}, deepExtend = (target, source, overwrite) => {
|
|
151757
151821
|
for (const prop in source) {
|
|
151758
151822
|
if (prop !== "__proto__" && prop !== "constructor") {
|
|
151759
|
-
if (prop
|
|
151823
|
+
if (Object.prototype.hasOwnProperty.call(target, prop)) {
|
|
151760
151824
|
if (isString2(target[prop]) || target[prop] instanceof String || isString2(source[prop]) || source[prop] instanceof String) {
|
|
151761
151825
|
if (overwrite)
|
|
151762
151826
|
target[prop] = source[prop];
|
|
@@ -151777,7 +151841,7 @@ var isString2 = (obj) => typeof obj === "string", defer2 = () => {
|
|
|
151777
151841
|
}, chars, looksLikeObjectPathRegExpCache, looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
|
|
151778
151842
|
nsSeparator = nsSeparator || "";
|
|
151779
151843
|
keySeparator = keySeparator || "";
|
|
151780
|
-
const possibleChars = chars.filter((c) => nsSeparator.
|
|
151844
|
+
const possibleChars = chars.filter((c) => !nsSeparator.includes(c) && !keySeparator.includes(c));
|
|
151781
151845
|
if (possibleChars.length === 0)
|
|
151782
151846
|
return true;
|
|
151783
151847
|
const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map((c) => c === "?" ? "\\?" : c).join("|")})`);
|
|
@@ -151789,12 +151853,14 @@ var isString2 = (obj) => typeof obj === "string", defer2 = () => {
|
|
|
151789
151853
|
}
|
|
151790
151854
|
}
|
|
151791
151855
|
return matched;
|
|
151792
|
-
}, deepFind =
|
|
151793
|
-
let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ".";
|
|
151856
|
+
}, deepFind = (obj, path, keySeparator = ".") => {
|
|
151794
151857
|
if (!obj)
|
|
151795
151858
|
return;
|
|
151796
|
-
if (obj[path])
|
|
151859
|
+
if (obj[path]) {
|
|
151860
|
+
if (!Object.prototype.hasOwnProperty.call(obj, path))
|
|
151861
|
+
return;
|
|
151797
151862
|
return obj[path];
|
|
151863
|
+
}
|
|
151798
151864
|
const tokens = path.split(keySeparator);
|
|
151799
151865
|
let current = obj;
|
|
151800
151866
|
for (let i = 0;i < tokens.length; ) {
|
|
@@ -151809,8 +151875,11 @@ var isString2 = (obj) => typeof obj === "string", defer2 = () => {
|
|
|
151809
151875
|
}
|
|
151810
151876
|
nextPath += tokens[j];
|
|
151811
151877
|
next = current[nextPath];
|
|
151878
|
+
if ((typeof next === "function" || nextPath === "__proto__") && !Object.prototype.hasOwnProperty.call(current, nextPath)) {
|
|
151879
|
+
next = undefined;
|
|
151880
|
+
}
|
|
151812
151881
|
if (next !== undefined) {
|
|
151813
|
-
if (["string", "number", "boolean"].
|
|
151882
|
+
if (["string", "number", "boolean"].includes(typeof next) && j < tokens.length - 1) {
|
|
151814
151883
|
continue;
|
|
151815
151884
|
}
|
|
151816
151885
|
i += j - i + 1;
|
|
@@ -151820,38 +151889,25 @@ var isString2 = (obj) => typeof obj === "string", defer2 = () => {
|
|
|
151820
151889
|
current = next;
|
|
151821
151890
|
}
|
|
151822
151891
|
return current;
|
|
151823
|
-
}, getCleanedCode = (code) => code
|
|
151824
|
-
const rules = {};
|
|
151825
|
-
sets.forEach((set) => {
|
|
151826
|
-
set.lngs.forEach((l) => {
|
|
151827
|
-
rules[l] = {
|
|
151828
|
-
numbers: set.nr,
|
|
151829
|
-
plurals: _rulesPluralsTypes[set.fc]
|
|
151830
|
-
};
|
|
151831
|
-
});
|
|
151832
|
-
});
|
|
151833
|
-
return rules;
|
|
151834
|
-
}, deepFindWithDefaults = function(data, defaultData, key) {
|
|
151835
|
-
let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ".";
|
|
151836
|
-
let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
151892
|
+
}, getCleanedCode = (code) => code?.replace(/_/g, "-"), consoleLogger, baseLogger, nonEmptyBundles, ResourceStore, postProcessor, PATH_KEY, shouldHandleAsObject = (res) => !isString2(res) && typeof res !== "boolean" && typeof res !== "number", Translator, suffixesOrder, dummyRule, deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJSONStructure = true) => {
|
|
151837
151893
|
let path = getPathWithDefaults(data, defaultData, key);
|
|
151838
|
-
if (
|
|
151894
|
+
if (path == null && ignoreJSONStructure && isString2(key)) {
|
|
151839
151895
|
path = deepFind(data, key, keySeparator);
|
|
151840
151896
|
if (path === undefined)
|
|
151841
151897
|
path = deepFind(defaultData, key, keySeparator);
|
|
151842
151898
|
}
|
|
151843
151899
|
return path;
|
|
151844
|
-
},
|
|
151900
|
+
}, parseFormatStr = (formatStr) => {
|
|
151845
151901
|
let formatName = formatStr.toLowerCase().trim();
|
|
151846
151902
|
const formatOptions = {};
|
|
151847
|
-
if (formatStr.
|
|
151903
|
+
if (formatStr.includes("(")) {
|
|
151848
151904
|
const p = formatStr.split("(");
|
|
151849
151905
|
formatName = p[0].toLowerCase().trim();
|
|
151850
|
-
const optStr = p[1].
|
|
151851
|
-
if (formatName === "currency" && optStr.
|
|
151906
|
+
const optStr = p[1].slice(0, -1);
|
|
151907
|
+
if (formatName === "currency" && !optStr.includes(":")) {
|
|
151852
151908
|
if (!formatOptions.currency)
|
|
151853
151909
|
formatOptions.currency = optStr.trim();
|
|
151854
|
-
} else if (formatName === "relativetime" && optStr.
|
|
151910
|
+
} else if (formatName === "relativetime" && !optStr.includes(":")) {
|
|
151855
151911
|
if (!formatOptions.range)
|
|
151856
151912
|
formatOptions.range = optStr.trim();
|
|
151857
151913
|
} else {
|
|
@@ -151879,30 +151935,35 @@ var isString2 = (obj) => typeof obj === "string", defer2 = () => {
|
|
|
151879
151935
|
};
|
|
151880
151936
|
}, createCachedFormatter = (fn) => {
|
|
151881
151937
|
const cache = {};
|
|
151882
|
-
return (
|
|
151883
|
-
let optForCache =
|
|
151884
|
-
if (
|
|
151938
|
+
return (v, l, o) => {
|
|
151939
|
+
let optForCache = o;
|
|
151940
|
+
if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) {
|
|
151885
151941
|
optForCache = {
|
|
151886
151942
|
...optForCache,
|
|
151887
|
-
[
|
|
151943
|
+
[o.interpolationkey]: undefined
|
|
151888
151944
|
};
|
|
151889
151945
|
}
|
|
151890
|
-
|
|
151891
|
-
|
|
151892
|
-
|
|
151893
|
-
|
|
151894
|
-
|
|
151946
|
+
let key;
|
|
151947
|
+
try {
|
|
151948
|
+
key = l + JSON.stringify(optForCache);
|
|
151949
|
+
} catch (e) {
|
|
151950
|
+
return fn(getCleanedCode(l), o)(v);
|
|
151895
151951
|
}
|
|
151896
|
-
|
|
151952
|
+
let frm = cache[key];
|
|
151953
|
+
if (!frm) {
|
|
151954
|
+
frm = fn(getCleanedCode(l), o);
|
|
151955
|
+
cache[key] = frm;
|
|
151956
|
+
}
|
|
151957
|
+
return frm(v);
|
|
151897
151958
|
};
|
|
151898
|
-
}, removePending = (q, name) => {
|
|
151959
|
+
}, createNonCachedFormatter = (fn) => (v, l, o) => fn(getCleanedCode(l), o)(v), removePending = (q, name) => {
|
|
151899
151960
|
if (q.pending[name] !== undefined) {
|
|
151900
151961
|
delete q.pending[name];
|
|
151901
151962
|
q.pendingCount--;
|
|
151902
151963
|
}
|
|
151903
151964
|
}, Connector, get2 = () => ({
|
|
151904
151965
|
debug: false,
|
|
151905
|
-
|
|
151966
|
+
initAsync: true,
|
|
151906
151967
|
ns: ["translation"],
|
|
151907
151968
|
defaultNS: ["translation"],
|
|
151908
151969
|
fallbackLng: ["dev"],
|
|
@@ -151911,11 +151972,11 @@ var isString2 = (obj) => typeof obj === "string", defer2 = () => {
|
|
|
151911
151972
|
nonExplicitSupportedLngs: false,
|
|
151912
151973
|
load: "all",
|
|
151913
151974
|
preload: false,
|
|
151914
|
-
simplifyPluralSuffix: true,
|
|
151915
151975
|
keySeparator: ".",
|
|
151916
151976
|
nsSeparator: ":",
|
|
151917
151977
|
pluralSeparator: "_",
|
|
151918
151978
|
contextSeparator: "_",
|
|
151979
|
+
enableSelector: false,
|
|
151919
151980
|
partialBundledLanguages: false,
|
|
151920
151981
|
saveMissing: false,
|
|
151921
151982
|
updateMissing: false,
|
|
@@ -151951,7 +152012,6 @@ var isString2 = (obj) => typeof obj === "string", defer2 = () => {
|
|
|
151951
152012
|
},
|
|
151952
152013
|
interpolation: {
|
|
151953
152014
|
escapeValue: true,
|
|
151954
|
-
format: (value) => value,
|
|
151955
152015
|
prefix: "{{",
|
|
151956
152016
|
suffix: "}}",
|
|
151957
152017
|
formatSeparator: ",",
|
|
@@ -151961,7 +152021,8 @@ var isString2 = (obj) => typeof obj === "string", defer2 = () => {
|
|
|
151961
152021
|
nestingOptionsSeparator: ",",
|
|
151962
152022
|
maxReplaces: 1000,
|
|
151963
152023
|
skipOnVariables: true
|
|
151964
|
-
}
|
|
152024
|
+
},
|
|
152025
|
+
cacheInBuiltFormats: true
|
|
151965
152026
|
}), transformOptions = (options) => {
|
|
151966
152027
|
if (isString2(options.ns))
|
|
151967
152028
|
options.ns = [options.ns];
|
|
@@ -151969,11 +152030,11 @@ var isString2 = (obj) => typeof obj === "string", defer2 = () => {
|
|
|
151969
152030
|
options.fallbackLng = [options.fallbackLng];
|
|
151970
152031
|
if (isString2(options.fallbackNS))
|
|
151971
152032
|
options.fallbackNS = [options.fallbackNS];
|
|
151972
|
-
if (options.supportedLngs && options.supportedLngs.
|
|
152033
|
+
if (options.supportedLngs && !options.supportedLngs.includes("cimode")) {
|
|
151973
152034
|
options.supportedLngs = options.supportedLngs.concat(["cimode"]);
|
|
151974
152035
|
}
|
|
151975
152036
|
return options;
|
|
151976
|
-
}, noop2 = () => {}, bindMemberFunctions = (inst) => {
|
|
152037
|
+
}, noop2 = () => {}, loggerOwner, bindMemberFunctions = (inst) => {
|
|
151977
152038
|
const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
|
|
151978
152039
|
mems.forEach((mem) => {
|
|
151979
152040
|
if (typeof inst[mem] === "function") {
|
|
@@ -152005,20 +152066,20 @@ var init_i18next = __esm(() => {
|
|
|
152005
152066
|
this.output("error", args);
|
|
152006
152067
|
},
|
|
152007
152068
|
output(type, args) {
|
|
152008
|
-
|
|
152009
|
-
console[type].apply(console, args);
|
|
152069
|
+
console?.[type]?.apply?.(console, args);
|
|
152010
152070
|
}
|
|
152011
152071
|
};
|
|
152012
152072
|
baseLogger = new Logger4;
|
|
152073
|
+
nonEmptyBundles = new WeakSet;
|
|
152013
152074
|
ResourceStore = class ResourceStore extends EventEmitter {
|
|
152014
|
-
constructor(data
|
|
152015
|
-
|
|
152016
|
-
|
|
152017
|
-
|
|
152018
|
-
};
|
|
152075
|
+
constructor(data, options = {
|
|
152076
|
+
ns: ["translation"],
|
|
152077
|
+
defaultNS: "translation"
|
|
152078
|
+
}) {
|
|
152019
152079
|
super();
|
|
152020
152080
|
this.data = data || {};
|
|
152021
152081
|
this.options = options;
|
|
152082
|
+
this.logger = baseLogger.create("resourceStore");
|
|
152022
152083
|
if (this.options.keySeparator === undefined) {
|
|
152023
152084
|
this.options.keySeparator = ".";
|
|
152024
152085
|
}
|
|
@@ -152027,7 +152088,7 @@ var init_i18next = __esm(() => {
|
|
|
152027
152088
|
}
|
|
152028
152089
|
}
|
|
152029
152090
|
addNamespaces(ns) {
|
|
152030
|
-
if (this.options.ns.
|
|
152091
|
+
if (!this.options.ns.includes(ns)) {
|
|
152031
152092
|
this.options.ns.push(ns);
|
|
152032
152093
|
}
|
|
152033
152094
|
}
|
|
@@ -152037,12 +152098,15 @@ var init_i18next = __esm(() => {
|
|
|
152037
152098
|
this.options.ns.splice(index, 1);
|
|
152038
152099
|
}
|
|
152039
152100
|
}
|
|
152040
|
-
|
|
152041
|
-
|
|
152101
|
+
deprecateDottedLng(method) {
|
|
152102
|
+
this.logger.once(method, "deprecate", `${method}: a dotted language ('en.translation.key') that carries the namespace and key is removed in v27; pass language, namespace and key as separate arguments`);
|
|
152103
|
+
}
|
|
152104
|
+
getResource(lng, ns, key, options = {}) {
|
|
152042
152105
|
const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
152043
152106
|
const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
152044
152107
|
let path;
|
|
152045
|
-
if (lng.
|
|
152108
|
+
if (lng.includes(".")) {
|
|
152109
|
+
this.deprecateDottedLng("getResource");
|
|
152046
152110
|
path = lng.split(".");
|
|
152047
152111
|
} else {
|
|
152048
152112
|
path = [lng, ns];
|
|
@@ -152057,24 +152121,24 @@ var init_i18next = __esm(() => {
|
|
|
152057
152121
|
}
|
|
152058
152122
|
}
|
|
152059
152123
|
const result = getPath(this.data, path);
|
|
152060
|
-
if (
|
|
152124
|
+
if (result == null && !ns && !key && lng.includes(".")) {
|
|
152061
152125
|
lng = path[0];
|
|
152062
152126
|
ns = path[1];
|
|
152063
152127
|
key = path.slice(2).join(".");
|
|
152064
152128
|
}
|
|
152065
|
-
if (result || !ignoreJSONStructure || !isString2(key))
|
|
152129
|
+
if (result != null || !ignoreJSONStructure || !isString2(key))
|
|
152066
152130
|
return result;
|
|
152067
|
-
return deepFind(this.data
|
|
152131
|
+
return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
|
|
152068
152132
|
}
|
|
152069
|
-
addResource(lng, ns, key, value
|
|
152070
|
-
|
|
152071
|
-
|
|
152072
|
-
};
|
|
152133
|
+
addResource(lng, ns, key, value, options = {
|
|
152134
|
+
silent: false
|
|
152135
|
+
}) {
|
|
152073
152136
|
const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
152074
152137
|
let path = [lng, ns];
|
|
152075
152138
|
if (key)
|
|
152076
152139
|
path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
152077
|
-
if (lng.
|
|
152140
|
+
if (lng.includes(".")) {
|
|
152141
|
+
this.deprecateDottedLng("addResource");
|
|
152078
152142
|
path = lng.split(".");
|
|
152079
152143
|
value = ns;
|
|
152080
152144
|
ns = path[1];
|
|
@@ -152084,10 +152148,9 @@ var init_i18next = __esm(() => {
|
|
|
152084
152148
|
if (!options.silent)
|
|
152085
152149
|
this.emit("added", lng, ns, key, value);
|
|
152086
152150
|
}
|
|
152087
|
-
addResources(lng, ns, resources
|
|
152088
|
-
|
|
152089
|
-
|
|
152090
|
-
};
|
|
152151
|
+
addResources(lng, ns, resources, options = {
|
|
152152
|
+
silent: false
|
|
152153
|
+
}) {
|
|
152091
152154
|
for (const m in resources) {
|
|
152092
152155
|
if (isString2(resources[m]) || Array.isArray(resources[m]))
|
|
152093
152156
|
this.addResource(lng, ns, m, resources[m], {
|
|
@@ -152097,13 +152160,13 @@ var init_i18next = __esm(() => {
|
|
|
152097
152160
|
if (!options.silent)
|
|
152098
152161
|
this.emit("added", lng, ns, resources);
|
|
152099
152162
|
}
|
|
152100
|
-
addResourceBundle(lng, ns, resources, deep, overwrite
|
|
152101
|
-
|
|
152102
|
-
|
|
152103
|
-
|
|
152104
|
-
};
|
|
152163
|
+
addResourceBundle(lng, ns, resources, deep, overwrite, options = {
|
|
152164
|
+
silent: false,
|
|
152165
|
+
skipCopy: false
|
|
152166
|
+
}) {
|
|
152105
152167
|
let path = [lng, ns];
|
|
152106
|
-
if (lng.
|
|
152168
|
+
if (lng.includes(".")) {
|
|
152169
|
+
this.deprecateDottedLng("addResourceBundle");
|
|
152107
152170
|
path = lng.split(".");
|
|
152108
152171
|
deep = resources;
|
|
152109
152172
|
resources = ns;
|
|
@@ -152138,11 +152201,6 @@ var init_i18next = __esm(() => {
|
|
|
152138
152201
|
getResourceBundle(lng, ns) {
|
|
152139
152202
|
if (!ns)
|
|
152140
152203
|
ns = this.options.defaultNS;
|
|
152141
|
-
if (this.options.compatibilityAPI === "v1")
|
|
152142
|
-
return {
|
|
152143
|
-
...{},
|
|
152144
|
-
...this.getResource(lng, ns)
|
|
152145
|
-
};
|
|
152146
152204
|
return this.getResource(lng, ns);
|
|
152147
152205
|
}
|
|
152148
152206
|
getDataByLanguage(lng) {
|
|
@@ -152151,7 +152209,16 @@ var init_i18next = __esm(() => {
|
|
|
152151
152209
|
hasLanguageSomeTranslations(lng) {
|
|
152152
152210
|
const data = this.getDataByLanguage(lng);
|
|
152153
152211
|
const n = data && Object.keys(data) || [];
|
|
152154
|
-
return !!n.find((v) =>
|
|
152212
|
+
return !!n.find((v) => {
|
|
152213
|
+
const bundle = data[v];
|
|
152214
|
+
if (nonEmptyBundles.has(bundle))
|
|
152215
|
+
return true;
|
|
152216
|
+
if (!bundle || Object.keys(bundle).length === 0)
|
|
152217
|
+
return false;
|
|
152218
|
+
if (typeof bundle === "object")
|
|
152219
|
+
nonEmptyBundles.add(bundle);
|
|
152220
|
+
return true;
|
|
152221
|
+
});
|
|
152155
152222
|
}
|
|
152156
152223
|
toJSON() {
|
|
152157
152224
|
return this.data;
|
|
@@ -152164,46 +152231,52 @@ var init_i18next = __esm(() => {
|
|
|
152164
152231
|
},
|
|
152165
152232
|
handle(processors, value, key, options, translator) {
|
|
152166
152233
|
processors.forEach((processor) => {
|
|
152167
|
-
|
|
152168
|
-
value = this.processors[processor].process(value, key, options, translator);
|
|
152234
|
+
value = this.processors[processor]?.process(value, key, options, translator) ?? value;
|
|
152169
152235
|
});
|
|
152170
152236
|
return value;
|
|
152171
152237
|
}
|
|
152172
152238
|
};
|
|
152173
|
-
|
|
152239
|
+
PATH_KEY = Symbol("i18next/PATH_KEY");
|
|
152174
152240
|
Translator = class Translator extends EventEmitter {
|
|
152175
|
-
constructor(services) {
|
|
152176
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
152241
|
+
constructor(services, options = {}) {
|
|
152177
152242
|
super();
|
|
152178
|
-
copy(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], services, this);
|
|
152243
|
+
copy(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils", "ownPostProcessors"], services, this);
|
|
152179
152244
|
this.options = options;
|
|
152180
152245
|
if (this.options.keySeparator === undefined) {
|
|
152181
152246
|
this.options.keySeparator = ".";
|
|
152182
152247
|
}
|
|
152183
152248
|
this.logger = baseLogger.create("translator");
|
|
152249
|
+
this.checkedLoadedFor = {};
|
|
152184
152250
|
}
|
|
152185
152251
|
changeLanguage(lng) {
|
|
152186
152252
|
if (lng)
|
|
152187
152253
|
this.language = lng;
|
|
152188
152254
|
}
|
|
152189
|
-
exists(key
|
|
152190
|
-
|
|
152191
|
-
|
|
152255
|
+
exists(key, o = {
|
|
152256
|
+
interpolation: {}
|
|
152257
|
+
}) {
|
|
152258
|
+
const opt = {
|
|
152259
|
+
...o
|
|
152192
152260
|
};
|
|
152193
|
-
if (key
|
|
152261
|
+
if (key == null)
|
|
152262
|
+
return false;
|
|
152263
|
+
const resolved = this.resolve(key, opt);
|
|
152264
|
+
if (resolved?.res === undefined)
|
|
152265
|
+
return false;
|
|
152266
|
+
const isObject = shouldHandleAsObject(resolved.res);
|
|
152267
|
+
if (opt.returnObjects === false && isObject) {
|
|
152194
152268
|
return false;
|
|
152195
152269
|
}
|
|
152196
|
-
|
|
152197
|
-
return resolved && resolved.res !== undefined;
|
|
152270
|
+
return true;
|
|
152198
152271
|
}
|
|
152199
|
-
extractFromKey(key,
|
|
152200
|
-
let nsSeparator =
|
|
152272
|
+
extractFromKey(key, opt) {
|
|
152273
|
+
let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
|
|
152201
152274
|
if (nsSeparator === undefined)
|
|
152202
152275
|
nsSeparator = ":";
|
|
152203
|
-
const keySeparator =
|
|
152204
|
-
let namespaces =
|
|
152205
|
-
const wouldCheckForNsInKey = nsSeparator && key.
|
|
152206
|
-
const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !
|
|
152276
|
+
const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
|
|
152277
|
+
let namespaces = opt.ns || this.options.defaultNS || [];
|
|
152278
|
+
const wouldCheckForNsInKey = nsSeparator && key.includes(nsSeparator);
|
|
152279
|
+
const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
|
|
152207
152280
|
if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
|
|
152208
152281
|
const m = key.match(this.interpolator.nestingRegexp);
|
|
152209
152282
|
if (m && m.length > 0) {
|
|
@@ -152213,7 +152286,7 @@ var init_i18next = __esm(() => {
|
|
|
152213
152286
|
};
|
|
152214
152287
|
}
|
|
152215
152288
|
const parts = key.split(nsSeparator);
|
|
152216
|
-
if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.
|
|
152289
|
+
if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.includes(parts[0]))
|
|
152217
152290
|
namespaces = parts.shift();
|
|
152218
152291
|
key = parts.join(keySeparator);
|
|
152219
152292
|
}
|
|
@@ -152222,32 +152295,46 @@ var init_i18next = __esm(() => {
|
|
|
152222
152295
|
namespaces: isString2(namespaces) ? [namespaces] : namespaces
|
|
152223
152296
|
};
|
|
152224
152297
|
}
|
|
152225
|
-
translate(keys,
|
|
152226
|
-
|
|
152227
|
-
|
|
152298
|
+
translate(keys, o, lastKey) {
|
|
152299
|
+
let opt = typeof o === "object" ? {
|
|
152300
|
+
...o
|
|
152301
|
+
} : o;
|
|
152302
|
+
if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) {
|
|
152303
|
+
opt = this.options.overloadTranslationOptionHandler(arguments);
|
|
152228
152304
|
}
|
|
152229
|
-
if (typeof
|
|
152230
|
-
|
|
152231
|
-
...
|
|
152305
|
+
if (typeof opt === "object")
|
|
152306
|
+
opt = {
|
|
152307
|
+
...opt
|
|
152232
152308
|
};
|
|
152233
|
-
if (!
|
|
152234
|
-
|
|
152235
|
-
if (keys
|
|
152309
|
+
if (!opt)
|
|
152310
|
+
opt = {};
|
|
152311
|
+
if (keys == null)
|
|
152236
152312
|
return "";
|
|
152313
|
+
if (typeof keys === "function")
|
|
152314
|
+
keys = keysFromSelector(keys, {
|
|
152315
|
+
...this.options,
|
|
152316
|
+
...opt
|
|
152317
|
+
});
|
|
152237
152318
|
if (!Array.isArray(keys))
|
|
152238
152319
|
keys = [String(keys)];
|
|
152239
|
-
|
|
152240
|
-
|
|
152320
|
+
keys = keys.map((k) => typeof k === "function" ? keysFromSelector(k, {
|
|
152321
|
+
...this.options,
|
|
152322
|
+
...opt
|
|
152323
|
+
}) : String(k));
|
|
152324
|
+
const returnDetails = opt.returnDetails !== undefined ? opt.returnDetails : this.options.returnDetails;
|
|
152325
|
+
const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
|
|
152241
152326
|
const {
|
|
152242
152327
|
key,
|
|
152243
152328
|
namespaces
|
|
152244
|
-
} = this.extractFromKey(keys[keys.length - 1],
|
|
152329
|
+
} = this.extractFromKey(keys[keys.length - 1], opt);
|
|
152245
152330
|
const namespace = namespaces[namespaces.length - 1];
|
|
152246
|
-
|
|
152247
|
-
|
|
152248
|
-
|
|
152331
|
+
let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
|
|
152332
|
+
if (nsSeparator === undefined)
|
|
152333
|
+
nsSeparator = ":";
|
|
152334
|
+
const lng = opt.lng || this.language;
|
|
152335
|
+
const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
152336
|
+
if (lng?.toLowerCase() === "cimode") {
|
|
152249
152337
|
if (appendNamespaceToCIMode) {
|
|
152250
|
-
const nsSeparator = options.nsSeparator || this.options.nsSeparator;
|
|
152251
152338
|
if (returnDetails) {
|
|
152252
152339
|
return {
|
|
152253
152340
|
res: `${namespace}${nsSeparator}${key}`,
|
|
@@ -152255,7 +152342,7 @@ var init_i18next = __esm(() => {
|
|
|
152255
152342
|
exactUsedKey: key,
|
|
152256
152343
|
usedLng: lng,
|
|
152257
152344
|
usedNS: namespace,
|
|
152258
|
-
usedParams: this.getUsedParamsDetails(
|
|
152345
|
+
usedParams: this.getUsedParamsDetails(opt)
|
|
152259
152346
|
};
|
|
152260
152347
|
}
|
|
152261
152348
|
return `${namespace}${nsSeparator}${key}`;
|
|
@@ -152267,52 +152354,76 @@ var init_i18next = __esm(() => {
|
|
|
152267
152354
|
exactUsedKey: key,
|
|
152268
152355
|
usedLng: lng,
|
|
152269
152356
|
usedNS: namespace,
|
|
152270
|
-
usedParams: this.getUsedParamsDetails(
|
|
152357
|
+
usedParams: this.getUsedParamsDetails(opt)
|
|
152271
152358
|
};
|
|
152272
152359
|
}
|
|
152273
152360
|
return key;
|
|
152274
152361
|
}
|
|
152275
|
-
const resolved = this.resolve(keys,
|
|
152276
|
-
let res = resolved
|
|
152277
|
-
const resUsedKey = resolved
|
|
152278
|
-
const resExactUsedKey = resolved
|
|
152279
|
-
const resType = Object.prototype.toString.apply(res);
|
|
152362
|
+
const resolved = this.resolve(keys, opt);
|
|
152363
|
+
let res = resolved?.res;
|
|
152364
|
+
const resUsedKey = resolved?.usedKey || key;
|
|
152365
|
+
const resExactUsedKey = resolved?.exactUsedKey || key;
|
|
152280
152366
|
const noObject = ["[object Number]", "[object Function]", "[object RegExp]"];
|
|
152281
|
-
const joinArrays =
|
|
152367
|
+
const joinArrays = opt.joinArrays !== undefined ? opt.joinArrays : this.options.joinArrays;
|
|
152282
152368
|
const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
|
152283
|
-
const
|
|
152284
|
-
|
|
152285
|
-
|
|
152369
|
+
const needsPluralHandling = opt.count !== undefined && !isString2(opt.count);
|
|
152370
|
+
const hasDefaultValue = Translator.hasDefaultValue(opt);
|
|
152371
|
+
const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : "";
|
|
152372
|
+
const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, {
|
|
152373
|
+
ordinal: false
|
|
152374
|
+
}) : "";
|
|
152375
|
+
const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
|
|
152376
|
+
const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
|
|
152377
|
+
let resForObjHndl = res;
|
|
152378
|
+
if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
|
|
152379
|
+
resForObjHndl = defaultValue;
|
|
152380
|
+
}
|
|
152381
|
+
const handleAsObject = shouldHandleAsObject(resForObjHndl);
|
|
152382
|
+
const resType = Object.prototype.toString.apply(resForObjHndl);
|
|
152383
|
+
if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && !noObject.includes(resType) && !(isString2(joinArrays) && Array.isArray(resForObjHndl))) {
|
|
152384
|
+
if (!opt.returnObjects && !this.options.returnObjects) {
|
|
152286
152385
|
if (!this.options.returnedObjectHandler) {
|
|
152287
152386
|
this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
152387
|
+
this.logger.once("returnedObject", "deprecate", "accessing an object without returnObjects returns a sentence about it today; from v27 t() returns the key, as for a missing key (returnedObjectHandler can keep today's text)");
|
|
152288
152388
|
}
|
|
152289
|
-
const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey,
|
|
152290
|
-
...
|
|
152389
|
+
const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
|
|
152390
|
+
...opt,
|
|
152291
152391
|
ns: namespaces
|
|
152292
152392
|
}) : `key '${key} (${this.language})' returned an object instead of string.`;
|
|
152293
152393
|
if (returnDetails) {
|
|
152294
152394
|
resolved.res = r;
|
|
152295
|
-
resolved.usedParams = this.getUsedParamsDetails(
|
|
152395
|
+
resolved.usedParams = this.getUsedParamsDetails(opt);
|
|
152296
152396
|
return resolved;
|
|
152297
152397
|
}
|
|
152298
152398
|
return r;
|
|
152299
152399
|
}
|
|
152300
152400
|
if (keySeparator) {
|
|
152301
|
-
const resTypeIsArray = Array.isArray(
|
|
152401
|
+
const resTypeIsArray = Array.isArray(resForObjHndl);
|
|
152302
152402
|
const copy = resTypeIsArray ? [] : {};
|
|
152303
152403
|
const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
|
|
152304
|
-
for (const m in
|
|
152305
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
152404
|
+
for (const m in resForObjHndl) {
|
|
152405
|
+
if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
|
|
152306
152406
|
const deepKey = `${newKeyToUse}${keySeparator}${m}`;
|
|
152307
|
-
|
|
152308
|
-
|
|
152309
|
-
|
|
152310
|
-
|
|
152311
|
-
|
|
152312
|
-
|
|
152313
|
-
|
|
152407
|
+
if (hasDefaultValue && !res) {
|
|
152408
|
+
copy[m] = this.translate(deepKey, {
|
|
152409
|
+
...opt,
|
|
152410
|
+
defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : undefined,
|
|
152411
|
+
...{
|
|
152412
|
+
joinArrays: false,
|
|
152413
|
+
ns: namespaces
|
|
152414
|
+
}
|
|
152415
|
+
});
|
|
152416
|
+
} else {
|
|
152417
|
+
copy[m] = this.translate(deepKey, {
|
|
152418
|
+
...opt,
|
|
152419
|
+
...{
|
|
152420
|
+
joinArrays: false,
|
|
152421
|
+
ns: namespaces
|
|
152422
|
+
}
|
|
152423
|
+
});
|
|
152424
|
+
}
|
|
152314
152425
|
if (copy[m] === deepKey)
|
|
152315
|
-
copy[m] =
|
|
152426
|
+
copy[m] = resForObjHndl[m];
|
|
152316
152427
|
}
|
|
152317
152428
|
}
|
|
152318
152429
|
res = copy;
|
|
@@ -152320,18 +152431,10 @@ var init_i18next = __esm(() => {
|
|
|
152320
152431
|
} else if (handleAsObjectInI18nFormat && isString2(joinArrays) && Array.isArray(res)) {
|
|
152321
152432
|
res = res.join(joinArrays);
|
|
152322
152433
|
if (res)
|
|
152323
|
-
res = this.extendTranslation(res, keys,
|
|
152434
|
+
res = this.extendTranslation(res, keys, opt, resolved, lastKey);
|
|
152324
152435
|
} else {
|
|
152325
152436
|
let usedDefault = false;
|
|
152326
152437
|
let usedKey = false;
|
|
152327
|
-
const needsPluralHandling = options.count !== undefined && !isString2(options.count);
|
|
152328
|
-
const hasDefaultValue = Translator.hasDefaultValue(options);
|
|
152329
|
-
const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : "";
|
|
152330
|
-
const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
|
|
152331
|
-
ordinal: false
|
|
152332
|
-
}) : "";
|
|
152333
|
-
const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
|
|
152334
|
-
const defaultValue = needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] || options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
|
|
152335
152438
|
if (!this.isValidLookup(res) && hasDefaultValue) {
|
|
152336
152439
|
usedDefault = true;
|
|
152337
152440
|
res = defaultValue;
|
|
@@ -152340,48 +152443,48 @@ var init_i18next = __esm(() => {
|
|
|
152340
152443
|
usedKey = true;
|
|
152341
152444
|
res = key;
|
|
152342
152445
|
}
|
|
152343
|
-
const missingKeyNoValueFallbackToKey =
|
|
152446
|
+
const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
|
|
152344
152447
|
const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
|
|
152345
152448
|
const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
|
|
152346
152449
|
if (usedKey || usedDefault || updateMissing) {
|
|
152347
|
-
this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, key, updateMissing ? defaultValue : res);
|
|
152450
|
+
this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, needsPluralHandling && !updateMissing ? `${key}${this.pluralResolver.getSuffix(lng, opt.count, opt)}` : key, updateMissing ? defaultValue : res);
|
|
152348
152451
|
if (keySeparator) {
|
|
152349
152452
|
const fk = this.resolve(key, {
|
|
152350
|
-
...
|
|
152453
|
+
...opt,
|
|
152351
152454
|
keySeparator: false
|
|
152352
152455
|
});
|
|
152353
152456
|
if (fk && fk.res)
|
|
152354
152457
|
this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
|
|
152355
152458
|
}
|
|
152356
152459
|
let lngs = [];
|
|
152357
|
-
const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng,
|
|
152460
|
+
const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
|
|
152358
152461
|
if (this.options.saveMissingTo === "fallback" && fallbackLngs && fallbackLngs[0]) {
|
|
152359
152462
|
for (let i = 0;i < fallbackLngs.length; i++) {
|
|
152360
152463
|
lngs.push(fallbackLngs[i]);
|
|
152361
152464
|
}
|
|
152362
152465
|
} else if (this.options.saveMissingTo === "all") {
|
|
152363
|
-
lngs = this.languageUtils.toResolveHierarchy(
|
|
152466
|
+
lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
|
|
152364
152467
|
} else {
|
|
152365
|
-
lngs.push(
|
|
152468
|
+
lngs.push(opt.lng || this.language);
|
|
152366
152469
|
}
|
|
152367
152470
|
const send = (l, k, specificDefaultValue) => {
|
|
152368
152471
|
const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
|
|
152369
152472
|
if (this.options.missingKeyHandler) {
|
|
152370
|
-
this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing,
|
|
152371
|
-
} else if (this.backendConnector
|
|
152372
|
-
this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing,
|
|
152473
|
+
this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
|
|
152474
|
+
} else if (this.backendConnector?.saveMissing) {
|
|
152475
|
+
this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt, undefined, this.utils?.hasLoadedNamespace);
|
|
152373
152476
|
}
|
|
152374
152477
|
this.emit("missingKey", l, namespace, k, res);
|
|
152375
152478
|
};
|
|
152376
152479
|
if (this.options.saveMissing) {
|
|
152377
152480
|
if (this.options.saveMissingPlurals && needsPluralHandling) {
|
|
152378
152481
|
lngs.forEach((language) => {
|
|
152379
|
-
const suffixes = this.pluralResolver.getSuffixes(language,
|
|
152380
|
-
if (needsZeroSuffixLookup &&
|
|
152482
|
+
const suffixes = this.pluralResolver.getSuffixes(language, opt);
|
|
152483
|
+
if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && !suffixes.includes(`${this.options.pluralSeparator}zero`)) {
|
|
152381
152484
|
suffixes.push(`${this.options.pluralSeparator}zero`);
|
|
152382
152485
|
}
|
|
152383
152486
|
suffixes.forEach((suffix) => {
|
|
152384
|
-
send([language], key + suffix,
|
|
152487
|
+
send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
|
|
152385
152488
|
});
|
|
152386
152489
|
});
|
|
152387
152490
|
} else {
|
|
@@ -152389,94 +152492,91 @@ var init_i18next = __esm(() => {
|
|
|
152389
152492
|
}
|
|
152390
152493
|
}
|
|
152391
152494
|
}
|
|
152392
|
-
res = this.extendTranslation(res, keys,
|
|
152393
|
-
if (usedKey && res === key && this.options.appendNamespaceToMissingKey)
|
|
152394
|
-
res = `${namespace}
|
|
152495
|
+
res = this.extendTranslation(res, keys, opt, resolved, lastKey);
|
|
152496
|
+
if (usedKey && res === key && this.options.appendNamespaceToMissingKey) {
|
|
152497
|
+
res = `${namespace}${nsSeparator}${key}`;
|
|
152498
|
+
}
|
|
152395
152499
|
if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
|
|
152396
|
-
|
|
152397
|
-
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
|
|
152398
|
-
} else {
|
|
152399
|
-
res = this.options.parseMissingKeyHandler(res);
|
|
152400
|
-
}
|
|
152500
|
+
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : undefined, opt);
|
|
152401
152501
|
}
|
|
152402
152502
|
}
|
|
152403
152503
|
if (returnDetails) {
|
|
152404
152504
|
resolved.res = res;
|
|
152405
|
-
resolved.usedParams = this.getUsedParamsDetails(
|
|
152505
|
+
resolved.usedParams = this.getUsedParamsDetails(opt);
|
|
152406
152506
|
return resolved;
|
|
152407
152507
|
}
|
|
152408
152508
|
return res;
|
|
152409
152509
|
}
|
|
152410
|
-
extendTranslation(res, key,
|
|
152411
|
-
|
|
152412
|
-
if (this.i18nFormat && this.i18nFormat.parse) {
|
|
152510
|
+
extendTranslation(res, key, opt, resolved, lastKey) {
|
|
152511
|
+
if (this.i18nFormat?.parse) {
|
|
152413
152512
|
res = this.i18nFormat.parse(res, {
|
|
152414
152513
|
...this.options.interpolation.defaultVariables,
|
|
152415
|
-
...
|
|
152416
|
-
},
|
|
152514
|
+
...opt
|
|
152515
|
+
}, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
|
|
152417
152516
|
resolved
|
|
152418
152517
|
});
|
|
152419
|
-
} else if (!
|
|
152420
|
-
if (
|
|
152518
|
+
} else if (!opt.skipInterpolation) {
|
|
152519
|
+
if (opt.interpolation)
|
|
152421
152520
|
this.interpolator.init({
|
|
152422
|
-
...
|
|
152521
|
+
...opt,
|
|
152423
152522
|
...{
|
|
152424
152523
|
interpolation: {
|
|
152425
152524
|
...this.options.interpolation,
|
|
152426
|
-
...
|
|
152525
|
+
...opt.interpolation
|
|
152427
152526
|
}
|
|
152428
152527
|
}
|
|
152429
152528
|
});
|
|
152430
|
-
const skipOnVariables = isString2(res) && (
|
|
152529
|
+
const skipOnVariables = isString2(res) && (opt?.interpolation?.skipOnVariables !== undefined ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
152431
152530
|
let nestBef;
|
|
152432
152531
|
if (skipOnVariables) {
|
|
152433
152532
|
const nb = res.match(this.interpolator.nestingRegexp);
|
|
152434
152533
|
nestBef = nb && nb.length;
|
|
152435
152534
|
}
|
|
152436
|
-
let data =
|
|
152535
|
+
let data = opt.replace && !isString2(opt.replace) ? opt.replace : opt;
|
|
152437
152536
|
if (this.options.interpolation.defaultVariables)
|
|
152438
152537
|
data = {
|
|
152439
152538
|
...this.options.interpolation.defaultVariables,
|
|
152440
152539
|
...data
|
|
152441
152540
|
};
|
|
152442
|
-
res = this.interpolator.interpolate(res, data,
|
|
152541
|
+
res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
|
|
152443
152542
|
if (skipOnVariables) {
|
|
152444
152543
|
const na = res.match(this.interpolator.nestingRegexp);
|
|
152445
152544
|
const nestAft = na && na.length;
|
|
152446
152545
|
if (nestBef < nestAft)
|
|
152447
|
-
|
|
152448
|
-
}
|
|
152449
|
-
if (!
|
|
152450
|
-
|
|
152451
|
-
if (
|
|
152452
|
-
res = this.interpolator.nest(res,
|
|
152453
|
-
|
|
152454
|
-
args[
|
|
152455
|
-
}
|
|
152456
|
-
if (lastKey && lastKey[0] === args[0] && !options.context) {
|
|
152457
|
-
_this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
|
|
152546
|
+
opt.nest = false;
|
|
152547
|
+
}
|
|
152548
|
+
if (!opt.lng && resolved && resolved.res)
|
|
152549
|
+
opt.lng = this.language || resolved.usedLng;
|
|
152550
|
+
if (opt.nest !== false)
|
|
152551
|
+
res = this.interpolator.nest(res, (...args) => {
|
|
152552
|
+
if (lastKey?.[0] === args[0] && !opt.context) {
|
|
152553
|
+
this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
|
|
152458
152554
|
return null;
|
|
152459
152555
|
}
|
|
152460
|
-
return
|
|
152461
|
-
},
|
|
152462
|
-
if (
|
|
152556
|
+
return this.translate(...args, key);
|
|
152557
|
+
}, opt);
|
|
152558
|
+
if (opt.interpolation)
|
|
152463
152559
|
this.interpolator.reset();
|
|
152464
152560
|
}
|
|
152465
|
-
const postProcess =
|
|
152561
|
+
const postProcess = opt.postProcess || this.options.postProcess;
|
|
152466
152562
|
const postProcessorNames = isString2(postProcess) ? [postProcess] : postProcess;
|
|
152467
|
-
if (res
|
|
152563
|
+
if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) {
|
|
152564
|
+
postProcessorNames.forEach((name) => {
|
|
152565
|
+
if (this.logger.debug && postProcessor.processors[name] && this.ownPostProcessors && !this.ownPostProcessors.has(name)) {
|
|
152566
|
+
this.logger.once(name, "deprecate", `postProcess: '${name}' was registered with use() on another i18next instance; from v27 post-processors are per instance, so call use() with it on this instance too`);
|
|
152567
|
+
}
|
|
152568
|
+
});
|
|
152468
152569
|
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
|
|
152469
152570
|
i18nResolved: {
|
|
152470
152571
|
...resolved,
|
|
152471
|
-
usedParams: this.getUsedParamsDetails(
|
|
152572
|
+
usedParams: this.getUsedParamsDetails(opt)
|
|
152472
152573
|
},
|
|
152473
|
-
...
|
|
152474
|
-
} :
|
|
152574
|
+
...opt
|
|
152575
|
+
} : opt, this);
|
|
152475
152576
|
}
|
|
152476
152577
|
return res;
|
|
152477
152578
|
}
|
|
152478
|
-
resolve(keys) {
|
|
152479
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
152579
|
+
resolve(keys, opt = {}) {
|
|
152480
152580
|
let found;
|
|
152481
152581
|
let usedKey;
|
|
152482
152582
|
let exactUsedKey;
|
|
@@ -152484,25 +152584,30 @@ var init_i18next = __esm(() => {
|
|
|
152484
152584
|
let usedNS;
|
|
152485
152585
|
if (isString2(keys))
|
|
152486
152586
|
keys = [keys];
|
|
152587
|
+
if (Array.isArray(keys))
|
|
152588
|
+
keys = keys.map((k) => typeof k === "function" ? keysFromSelector(k, {
|
|
152589
|
+
...this.options,
|
|
152590
|
+
...opt
|
|
152591
|
+
}) : k);
|
|
152487
152592
|
keys.forEach((k) => {
|
|
152488
152593
|
if (this.isValidLookup(found))
|
|
152489
152594
|
return;
|
|
152490
|
-
const extracted = this.extractFromKey(k,
|
|
152595
|
+
const extracted = this.extractFromKey(k, opt);
|
|
152491
152596
|
const key = extracted.key;
|
|
152492
152597
|
usedKey = key;
|
|
152493
152598
|
let namespaces = extracted.namespaces;
|
|
152494
152599
|
if (this.options.fallbackNS)
|
|
152495
152600
|
namespaces = namespaces.concat(this.options.fallbackNS);
|
|
152496
|
-
const needsPluralHandling =
|
|
152497
|
-
const needsZeroSuffixLookup = needsPluralHandling && !
|
|
152498
|
-
const needsContextHandling =
|
|
152499
|
-
const codes =
|
|
152601
|
+
const needsPluralHandling = opt.count !== undefined && !isString2(opt.count);
|
|
152602
|
+
const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
|
|
152603
|
+
const needsContextHandling = opt.context !== undefined && (isString2(opt.context) || typeof opt.context === "number") && opt.context !== "";
|
|
152604
|
+
const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
|
|
152500
152605
|
namespaces.forEach((ns) => {
|
|
152501
152606
|
if (this.isValidLookup(found))
|
|
152502
152607
|
return;
|
|
152503
152608
|
usedNS = ns;
|
|
152504
|
-
if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils
|
|
152505
|
-
checkedLoadedFor[`${codes[0]}-${ns}`] = true;
|
|
152609
|
+
if (!this.checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(usedNS)) {
|
|
152610
|
+
this.checkedLoadedFor[`${codes[0]}-${ns}`] = true;
|
|
152506
152611
|
this.logger.warn(`key "${usedKey}" for languages "${codes.join(", ")}" won't get resolved as namespace "${usedNS}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
|
|
152507
152612
|
}
|
|
152508
152613
|
codes.forEach((code) => {
|
|
@@ -152510,31 +152615,31 @@ var init_i18next = __esm(() => {
|
|
|
152510
152615
|
return;
|
|
152511
152616
|
usedLng = code;
|
|
152512
152617
|
const finalKeys = [key];
|
|
152513
|
-
if (this.i18nFormat
|
|
152514
|
-
this.i18nFormat.addLookupKeys(finalKeys, key, code, ns,
|
|
152618
|
+
if (this.i18nFormat?.addLookupKeys) {
|
|
152619
|
+
this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
|
|
152515
152620
|
} else {
|
|
152516
152621
|
let pluralSuffix;
|
|
152517
152622
|
if (needsPluralHandling)
|
|
152518
|
-
pluralSuffix = this.pluralResolver.getSuffix(code,
|
|
152623
|
+
pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
|
|
152519
152624
|
const zeroSuffix = `${this.options.pluralSeparator}zero`;
|
|
152520
152625
|
const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
152521
152626
|
if (needsPluralHandling) {
|
|
152522
|
-
|
|
152523
|
-
if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
|
|
152627
|
+
if (opt.ordinal && pluralSuffix.startsWith(ordinalPrefix)) {
|
|
152524
152628
|
finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
|
152525
152629
|
}
|
|
152630
|
+
finalKeys.push(key + pluralSuffix);
|
|
152526
152631
|
if (needsZeroSuffixLookup) {
|
|
152527
152632
|
finalKeys.push(key + zeroSuffix);
|
|
152528
152633
|
}
|
|
152529
152634
|
}
|
|
152530
152635
|
if (needsContextHandling) {
|
|
152531
|
-
const contextKey = `${key}${this.options.contextSeparator}${
|
|
152636
|
+
const contextKey = `${key}${this.options.contextSeparator || "_"}${opt.context}`;
|
|
152532
152637
|
finalKeys.push(contextKey);
|
|
152533
152638
|
if (needsPluralHandling) {
|
|
152534
|
-
|
|
152535
|
-
if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
|
|
152639
|
+
if (opt.ordinal && pluralSuffix.startsWith(ordinalPrefix)) {
|
|
152536
152640
|
finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
|
152537
152641
|
}
|
|
152642
|
+
finalKeys.push(contextKey + pluralSuffix);
|
|
152538
152643
|
if (needsZeroSuffixLookup) {
|
|
152539
152644
|
finalKeys.push(contextKey + zeroSuffix);
|
|
152540
152645
|
}
|
|
@@ -152545,7 +152650,7 @@ var init_i18next = __esm(() => {
|
|
|
152545
152650
|
while (possibleKey = finalKeys.pop()) {
|
|
152546
152651
|
if (!this.isValidLookup(found)) {
|
|
152547
152652
|
exactUsedKey = possibleKey;
|
|
152548
|
-
found = this.getResource(code, ns, possibleKey,
|
|
152653
|
+
found = this.getResource(code, ns, possibleKey, opt);
|
|
152549
152654
|
}
|
|
152550
152655
|
}
|
|
152551
152656
|
});
|
|
@@ -152562,19 +152667,20 @@ var init_i18next = __esm(() => {
|
|
|
152562
152667
|
isValidLookup(res) {
|
|
152563
152668
|
return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
|
|
152564
152669
|
}
|
|
152565
|
-
getResource(code, ns, key) {
|
|
152566
|
-
|
|
152567
|
-
if (this.i18nFormat && this.i18nFormat.getResource)
|
|
152670
|
+
getResource(code, ns, key, options = {}) {
|
|
152671
|
+
if (this.i18nFormat?.getResource)
|
|
152568
152672
|
return this.i18nFormat.getResource(code, ns, key, options);
|
|
152569
152673
|
return this.resourceStore.getResource(code, ns, key, options);
|
|
152570
152674
|
}
|
|
152571
|
-
getUsedParamsDetails() {
|
|
152572
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
152675
|
+
getUsedParamsDetails(options = {}) {
|
|
152573
152676
|
const optionsKeys = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"];
|
|
152574
152677
|
const useOptionsReplaceForData = options.replace && !isString2(options.replace);
|
|
152575
152678
|
let data = useOptionsReplaceForData ? options.replace : options;
|
|
152576
152679
|
if (useOptionsReplaceForData && typeof options.count !== "undefined") {
|
|
152577
|
-
data
|
|
152680
|
+
data = {
|
|
152681
|
+
...data,
|
|
152682
|
+
count: options.count
|
|
152683
|
+
};
|
|
152578
152684
|
}
|
|
152579
152685
|
if (this.options.interpolation.defaultVariables) {
|
|
152580
152686
|
data = {
|
|
@@ -152595,132 +152701,13 @@ var init_i18next = __esm(() => {
|
|
|
152595
152701
|
static hasDefaultValue(options) {
|
|
152596
152702
|
const prefix = "defaultValue";
|
|
152597
152703
|
for (const option in options) {
|
|
152598
|
-
if (Object.prototype.hasOwnProperty.call(options, option) &&
|
|
152704
|
+
if (Object.prototype.hasOwnProperty.call(options, option) && option.startsWith(prefix) && options[option] !== undefined) {
|
|
152599
152705
|
return true;
|
|
152600
152706
|
}
|
|
152601
152707
|
}
|
|
152602
152708
|
return false;
|
|
152603
152709
|
}
|
|
152604
152710
|
};
|
|
152605
|
-
sets = [{
|
|
152606
|
-
lngs: ["ach", "ak", "am", "arn", "br", "fil", "gun", "ln", "mfe", "mg", "mi", "oc", "pt", "pt-BR", "tg", "tl", "ti", "tr", "uz", "wa"],
|
|
152607
|
-
nr: [1, 2],
|
|
152608
|
-
fc: 1
|
|
152609
|
-
}, {
|
|
152610
|
-
lngs: ["af", "an", "ast", "az", "bg", "bn", "ca", "da", "de", "dev", "el", "en", "eo", "es", "et", "eu", "fi", "fo", "fur", "fy", "gl", "gu", "ha", "hi", "hu", "hy", "ia", "it", "kk", "kn", "ku", "lb", "mai", "ml", "mn", "mr", "nah", "nap", "nb", "ne", "nl", "nn", "no", "nso", "pa", "pap", "pms", "ps", "pt-PT", "rm", "sco", "se", "si", "so", "son", "sq", "sv", "sw", "ta", "te", "tk", "ur", "yo"],
|
|
152611
|
-
nr: [1, 2],
|
|
152612
|
-
fc: 2
|
|
152613
|
-
}, {
|
|
152614
|
-
lngs: ["ay", "bo", "cgg", "fa", "ht", "id", "ja", "jbo", "ka", "km", "ko", "ky", "lo", "ms", "sah", "su", "th", "tt", "ug", "vi", "wo", "zh"],
|
|
152615
|
-
nr: [1],
|
|
152616
|
-
fc: 3
|
|
152617
|
-
}, {
|
|
152618
|
-
lngs: ["be", "bs", "cnr", "dz", "hr", "ru", "sr", "uk"],
|
|
152619
|
-
nr: [1, 2, 5],
|
|
152620
|
-
fc: 4
|
|
152621
|
-
}, {
|
|
152622
|
-
lngs: ["ar"],
|
|
152623
|
-
nr: [0, 1, 2, 3, 11, 100],
|
|
152624
|
-
fc: 5
|
|
152625
|
-
}, {
|
|
152626
|
-
lngs: ["cs", "sk"],
|
|
152627
|
-
nr: [1, 2, 5],
|
|
152628
|
-
fc: 6
|
|
152629
|
-
}, {
|
|
152630
|
-
lngs: ["csb", "pl"],
|
|
152631
|
-
nr: [1, 2, 5],
|
|
152632
|
-
fc: 7
|
|
152633
|
-
}, {
|
|
152634
|
-
lngs: ["cy"],
|
|
152635
|
-
nr: [1, 2, 3, 8],
|
|
152636
|
-
fc: 8
|
|
152637
|
-
}, {
|
|
152638
|
-
lngs: ["fr"],
|
|
152639
|
-
nr: [1, 2],
|
|
152640
|
-
fc: 9
|
|
152641
|
-
}, {
|
|
152642
|
-
lngs: ["ga"],
|
|
152643
|
-
nr: [1, 2, 3, 7, 11],
|
|
152644
|
-
fc: 10
|
|
152645
|
-
}, {
|
|
152646
|
-
lngs: ["gd"],
|
|
152647
|
-
nr: [1, 2, 3, 20],
|
|
152648
|
-
fc: 11
|
|
152649
|
-
}, {
|
|
152650
|
-
lngs: ["is"],
|
|
152651
|
-
nr: [1, 2],
|
|
152652
|
-
fc: 12
|
|
152653
|
-
}, {
|
|
152654
|
-
lngs: ["jv"],
|
|
152655
|
-
nr: [0, 1],
|
|
152656
|
-
fc: 13
|
|
152657
|
-
}, {
|
|
152658
|
-
lngs: ["kw"],
|
|
152659
|
-
nr: [1, 2, 3, 4],
|
|
152660
|
-
fc: 14
|
|
152661
|
-
}, {
|
|
152662
|
-
lngs: ["lt"],
|
|
152663
|
-
nr: [1, 2, 10],
|
|
152664
|
-
fc: 15
|
|
152665
|
-
}, {
|
|
152666
|
-
lngs: ["lv"],
|
|
152667
|
-
nr: [1, 2, 0],
|
|
152668
|
-
fc: 16
|
|
152669
|
-
}, {
|
|
152670
|
-
lngs: ["mk"],
|
|
152671
|
-
nr: [1, 2],
|
|
152672
|
-
fc: 17
|
|
152673
|
-
}, {
|
|
152674
|
-
lngs: ["mnk"],
|
|
152675
|
-
nr: [0, 1, 2],
|
|
152676
|
-
fc: 18
|
|
152677
|
-
}, {
|
|
152678
|
-
lngs: ["mt"],
|
|
152679
|
-
nr: [1, 2, 11, 20],
|
|
152680
|
-
fc: 19
|
|
152681
|
-
}, {
|
|
152682
|
-
lngs: ["or"],
|
|
152683
|
-
nr: [2, 1],
|
|
152684
|
-
fc: 2
|
|
152685
|
-
}, {
|
|
152686
|
-
lngs: ["ro"],
|
|
152687
|
-
nr: [1, 2, 20],
|
|
152688
|
-
fc: 20
|
|
152689
|
-
}, {
|
|
152690
|
-
lngs: ["sl"],
|
|
152691
|
-
nr: [5, 1, 2, 3],
|
|
152692
|
-
fc: 21
|
|
152693
|
-
}, {
|
|
152694
|
-
lngs: ["he", "iw"],
|
|
152695
|
-
nr: [1, 2, 20, 21],
|
|
152696
|
-
fc: 22
|
|
152697
|
-
}];
|
|
152698
|
-
_rulesPluralsTypes = {
|
|
152699
|
-
1: (n) => Number(n > 1),
|
|
152700
|
-
2: (n) => Number(n != 1),
|
|
152701
|
-
3: (n) => 0,
|
|
152702
|
-
4: (n) => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
|
|
152703
|
-
5: (n) => Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5),
|
|
152704
|
-
6: (n) => Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2),
|
|
152705
|
-
7: (n) => Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
|
|
152706
|
-
8: (n) => Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3),
|
|
152707
|
-
9: (n) => Number(n >= 2),
|
|
152708
|
-
10: (n) => Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4),
|
|
152709
|
-
11: (n) => Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3),
|
|
152710
|
-
12: (n) => Number(n % 10 != 1 || n % 100 == 11),
|
|
152711
|
-
13: (n) => Number(n !== 0),
|
|
152712
|
-
14: (n) => Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3),
|
|
152713
|
-
15: (n) => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
|
|
152714
|
-
16: (n) => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2),
|
|
152715
|
-
17: (n) => Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1),
|
|
152716
|
-
18: (n) => Number(n == 0 ? 0 : n == 1 ? 1 : 2),
|
|
152717
|
-
19: (n) => Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3),
|
|
152718
|
-
20: (n) => Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2),
|
|
152719
|
-
21: (n) => Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0),
|
|
152720
|
-
22: (n) => Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3)
|
|
152721
|
-
};
|
|
152722
|
-
nonIntlVersions = ["v1", "v2", "v3"];
|
|
152723
|
-
intlVersions = ["v4"];
|
|
152724
152711
|
suffixesOrder = {
|
|
152725
152712
|
zero: 0,
|
|
152726
152713
|
one: 1,
|
|
@@ -152729,9 +152716,14 @@ var init_i18next = __esm(() => {
|
|
|
152729
152716
|
many: 4,
|
|
152730
152717
|
other: 5
|
|
152731
152718
|
};
|
|
152719
|
+
dummyRule = {
|
|
152720
|
+
select: (count) => count === 1 ? "one" : "other",
|
|
152721
|
+
resolvedOptions: () => ({
|
|
152722
|
+
pluralCategories: ["one", "other"]
|
|
152723
|
+
})
|
|
152724
|
+
};
|
|
152732
152725
|
Connector = class Connector extends EventEmitter {
|
|
152733
|
-
constructor(backend, store, services) {
|
|
152734
|
-
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
152726
|
+
constructor(backend, store, services, options = {}) {
|
|
152735
152727
|
super();
|
|
152736
152728
|
this.backend = backend;
|
|
152737
152729
|
this.store = store;
|
|
@@ -152746,8 +152738,10 @@ var init_i18next = __esm(() => {
|
|
|
152746
152738
|
this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
|
|
152747
152739
|
this.state = {};
|
|
152748
152740
|
this.queue = [];
|
|
152749
|
-
|
|
152750
|
-
|
|
152741
|
+
this.backend?.init?.(services, options.backend, options);
|
|
152742
|
+
this.callbackApi = callbackApiOf(this.backend);
|
|
152743
|
+
if (this.backend && this.callbackApi === undefined && (this.backend.read || this.backend.create)) {
|
|
152744
|
+
this.logger.deprecate("backend: set callbackApi to declare the calling convention (true: read(language, namespace, callback) and create(languages, namespace, key, fallbackValue, callback, options); false: both return a promise or a value); guessing it from the number of parameters is deprecated");
|
|
152751
152745
|
}
|
|
152752
152746
|
}
|
|
152753
152747
|
queueLoad(languages, namespaces, options, callback) {
|
|
@@ -152761,7 +152755,7 @@ var init_i18next = __esm(() => {
|
|
|
152761
152755
|
const name = `${lng}|${ns}`;
|
|
152762
152756
|
if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
|
|
152763
152757
|
this.state[name] = 2;
|
|
152764
|
-
} else if (this.state[name] < 0)
|
|
152758
|
+
} else if (!options.reload && this.state[name] < 0)
|
|
152765
152759
|
;
|
|
152766
152760
|
else if (this.state[name] === 1) {
|
|
152767
152761
|
if (pending[name] === undefined)
|
|
@@ -152839,10 +152833,7 @@ var init_i18next = __esm(() => {
|
|
|
152839
152833
|
this.emit("loaded", loaded);
|
|
152840
152834
|
this.queue = this.queue.filter((q) => !q.done);
|
|
152841
152835
|
}
|
|
152842
|
-
read(lng, ns, fcName) {
|
|
152843
|
-
let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
152844
|
-
let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
|
|
152845
|
-
let callback = arguments.length > 5 ? arguments[5] : undefined;
|
|
152836
|
+
read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
|
|
152846
152837
|
if (!lng.length)
|
|
152847
152838
|
return callback(null, {});
|
|
152848
152839
|
if (this.readingCalls >= this.maxParallelReads) {
|
|
@@ -152865,14 +152856,14 @@ var init_i18next = __esm(() => {
|
|
|
152865
152856
|
}
|
|
152866
152857
|
if (err && data && tried < this.maxRetries) {
|
|
152867
152858
|
setTimeout(() => {
|
|
152868
|
-
this.read
|
|
152859
|
+
this.read(lng, ns, fcName, tried + 1, wait * 2, callback);
|
|
152869
152860
|
}, wait);
|
|
152870
152861
|
return;
|
|
152871
152862
|
}
|
|
152872
152863
|
callback(err, data);
|
|
152873
152864
|
};
|
|
152874
152865
|
const fc = this.backend[fcName].bind(this.backend);
|
|
152875
|
-
if (fc.length === 2) {
|
|
152866
|
+
if (this.callbackApi === false || this.callbackApi === undefined && fc.length === 2) {
|
|
152876
152867
|
try {
|
|
152877
152868
|
const r = fc(lng, ns);
|
|
152878
152869
|
if (r && typeof r.then === "function") {
|
|
@@ -152887,9 +152878,7 @@ var init_i18next = __esm(() => {
|
|
|
152887
152878
|
}
|
|
152888
152879
|
return fc(lng, ns, resolver);
|
|
152889
152880
|
}
|
|
152890
|
-
prepareLoading(languages, namespaces) {
|
|
152891
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
152892
|
-
let callback = arguments.length > 3 ? arguments[3] : undefined;
|
|
152881
|
+
prepareLoading(languages, namespaces, options = {}, callback) {
|
|
152893
152882
|
if (!this.backend) {
|
|
152894
152883
|
this.logger.warn("No backend was added via i18next.use. Will not load resources.");
|
|
152895
152884
|
return callback && callback();
|
|
@@ -152916,11 +152905,16 @@ var init_i18next = __esm(() => {
|
|
|
152916
152905
|
reload: true
|
|
152917
152906
|
}, callback);
|
|
152918
152907
|
}
|
|
152919
|
-
|
|
152920
|
-
|
|
152908
|
+
noticeDevFallback(lng) {
|
|
152909
|
+
if (lng !== "dev" || !this.devIsDefaultFallback)
|
|
152910
|
+
return;
|
|
152911
|
+
this.logger.once("dev", "warn", "language 'dev' is requested because fallbackLng is not set (its default is ['dev']); i18next v27 defaults to fallbackLng: false and loads and saves missing keys in the requested language instead. Set fallbackLng to your source language, or to 'dev' to keep this behavior");
|
|
152912
|
+
}
|
|
152913
|
+
loadOne(name, prefix = "") {
|
|
152921
152914
|
const s = name.split("|");
|
|
152922
152915
|
const lng = s[0];
|
|
152923
152916
|
const ns = s[1];
|
|
152917
|
+
this.noticeDevFallback(lng);
|
|
152924
152918
|
this.read(lng, ns, "read", undefined, undefined, (err, data) => {
|
|
152925
152919
|
if (err)
|
|
152926
152920
|
this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
|
|
@@ -152929,25 +152923,24 @@ var init_i18next = __esm(() => {
|
|
|
152929
152923
|
this.loaded(name, err, data);
|
|
152930
152924
|
});
|
|
152931
152925
|
}
|
|
152932
|
-
saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
|
|
152933
|
-
|
|
152934
|
-
let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
|
|
152935
|
-
if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
|
|
152926
|
+
saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {}, hasLoadedNamespace = this.newestCloneHasLoadedNamespace || this.services?.utils?.hasLoadedNamespace) {
|
|
152927
|
+
if (hasLoadedNamespace && !hasLoadedNamespace(namespace)) {
|
|
152936
152928
|
this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
|
|
152937
152929
|
return;
|
|
152938
152930
|
}
|
|
152939
152931
|
if (key === undefined || key === null || key === "")
|
|
152940
152932
|
return;
|
|
152941
|
-
if (this.backend
|
|
152933
|
+
if (this.backend?.create) {
|
|
152934
|
+
languages?.forEach?.((l) => this.noticeDevFallback(l));
|
|
152942
152935
|
const opts = {
|
|
152943
152936
|
...options,
|
|
152944
152937
|
isUpdate
|
|
152945
152938
|
};
|
|
152946
152939
|
const fc = this.backend.create.bind(this.backend);
|
|
152947
|
-
if (fc.length < 6) {
|
|
152940
|
+
if (this.callbackApi === false || this.callbackApi === undefined && fc.length < 6) {
|
|
152948
152941
|
try {
|
|
152949
152942
|
let r;
|
|
152950
|
-
if (fc.length === 5) {
|
|
152943
|
+
if (this.callbackApi === false || fc.length === 5) {
|
|
152951
152944
|
r = fc(languages, namespace, key, fallbackValue, opts);
|
|
152952
152945
|
} else {
|
|
152953
152946
|
r = fc(languages, namespace, key, fallbackValue);
|
|
@@ -152970,19 +152963,19 @@ var init_i18next = __esm(() => {
|
|
|
152970
152963
|
}
|
|
152971
152964
|
};
|
|
152972
152965
|
I18n = class I18n extends EventEmitter {
|
|
152973
|
-
constructor() {
|
|
152974
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
152975
|
-
let callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
152966
|
+
constructor(options = {}, callback) {
|
|
152976
152967
|
super();
|
|
152977
152968
|
this.options = transformOptions(options);
|
|
152978
|
-
this.services = {
|
|
152969
|
+
this.services = {
|
|
152970
|
+
ownPostProcessors: new Set
|
|
152971
|
+
};
|
|
152979
152972
|
this.logger = baseLogger;
|
|
152980
152973
|
this.modules = {
|
|
152981
152974
|
external: []
|
|
152982
152975
|
};
|
|
152983
152976
|
bindMemberFunctions(this);
|
|
152984
152977
|
if (callback && !this.isInitialized && !options.isClone) {
|
|
152985
|
-
if (!this.options.
|
|
152978
|
+
if (!this.options.initAsync) {
|
|
152986
152979
|
this.init(options, callback);
|
|
152987
152980
|
return this;
|
|
152988
152981
|
}
|
|
@@ -152991,40 +152984,39 @@ var init_i18next = __esm(() => {
|
|
|
152991
152984
|
}, 0);
|
|
152992
152985
|
}
|
|
152993
152986
|
}
|
|
152994
|
-
init() {
|
|
152995
|
-
var _this = this;
|
|
152996
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
152997
|
-
let callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
152987
|
+
init(options = {}, callback) {
|
|
152998
152988
|
this.isInitializing = true;
|
|
152999
152989
|
if (typeof options === "function") {
|
|
153000
152990
|
callback = options;
|
|
153001
152991
|
options = {};
|
|
153002
152992
|
}
|
|
153003
|
-
if (
|
|
152993
|
+
if (options.defaultNS == null && options.ns) {
|
|
153004
152994
|
if (isString2(options.ns)) {
|
|
153005
152995
|
options.defaultNS = options.ns;
|
|
153006
|
-
} else if (options.ns.
|
|
152996
|
+
} else if (!options.ns.includes("translation")) {
|
|
153007
152997
|
options.defaultNS = options.ns[0];
|
|
153008
152998
|
}
|
|
153009
152999
|
}
|
|
153000
|
+
const fallbackLngIsDefault = options.fallbackLng === undefined && this.options.fallbackLng === undefined;
|
|
153010
153001
|
const defOpts = get2();
|
|
153011
153002
|
this.options = {
|
|
153012
153003
|
...defOpts,
|
|
153013
153004
|
...this.options,
|
|
153014
153005
|
...transformOptions(options)
|
|
153015
153006
|
};
|
|
153016
|
-
|
|
153017
|
-
|
|
153018
|
-
|
|
153019
|
-
|
|
153020
|
-
};
|
|
153021
|
-
}
|
|
153007
|
+
this.options.interpolation = {
|
|
153008
|
+
...defOpts.interpolation,
|
|
153009
|
+
...this.options.interpolation
|
|
153010
|
+
};
|
|
153022
153011
|
if (options.keySeparator !== undefined) {
|
|
153023
153012
|
this.options.userDefinedKeySeparator = options.keySeparator;
|
|
153024
153013
|
}
|
|
153025
153014
|
if (options.nsSeparator !== undefined) {
|
|
153026
153015
|
this.options.userDefinedNsSeparator = options.nsSeparator;
|
|
153027
153016
|
}
|
|
153017
|
+
if (typeof this.options.overloadTranslationOptionHandler !== "function") {
|
|
153018
|
+
this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
|
|
153019
|
+
}
|
|
153028
153020
|
const createClassOnDemand = (ClassOrObject) => {
|
|
153029
153021
|
if (!ClassOrObject)
|
|
153030
153022
|
return null;
|
|
@@ -153033,15 +153025,21 @@ var init_i18next = __esm(() => {
|
|
|
153033
153025
|
return ClassOrObject;
|
|
153034
153026
|
};
|
|
153035
153027
|
if (!this.options.isClone) {
|
|
153028
|
+
if (loggerOwner && loggerOwner !== this && loggerOwner.modules.logger !== this.modules.logger) {
|
|
153029
|
+
baseLogger.deprecate("init: this init() replaces the logger another i18next instance set with use(), as the logger is shared in v26; from v27 each instance keeps its own logger");
|
|
153030
|
+
}
|
|
153031
|
+
loggerOwner = this.modules.logger ? this : undefined;
|
|
153036
153032
|
if (this.modules.logger) {
|
|
153037
153033
|
baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
|
|
153038
153034
|
} else {
|
|
153039
153035
|
baseLogger.init(null, this.options);
|
|
153040
153036
|
}
|
|
153037
|
+
this.pendingWarnings?.forEach((msg) => this.logger.warn(msg));
|
|
153038
|
+
this.pendingWarnings = undefined;
|
|
153041
153039
|
let formatter;
|
|
153042
153040
|
if (this.modules.formatter) {
|
|
153043
153041
|
formatter = this.modules.formatter;
|
|
153044
|
-
} else
|
|
153042
|
+
} else {
|
|
153045
153043
|
formatter = Formatter2;
|
|
153046
153044
|
}
|
|
153047
153045
|
const lu = new LanguageUtil(this.options);
|
|
@@ -153051,30 +153049,31 @@ var init_i18next = __esm(() => {
|
|
|
153051
153049
|
s.resourceStore = this.store;
|
|
153052
153050
|
s.languageUtils = lu;
|
|
153053
153051
|
s.pluralResolver = new PluralResolver(lu, {
|
|
153054
|
-
prepend: this.options.pluralSeparator
|
|
153055
|
-
compatibilityJSON: this.options.compatibilityJSON,
|
|
153056
|
-
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
153052
|
+
prepend: this.options.pluralSeparator
|
|
153057
153053
|
});
|
|
153058
|
-
if (formatter
|
|
153054
|
+
if (formatter) {
|
|
153059
153055
|
s.formatter = createClassOnDemand(formatter);
|
|
153060
|
-
s.formatter.init
|
|
153056
|
+
if (s.formatter.init)
|
|
153057
|
+
s.formatter.init(s, this.options);
|
|
153061
153058
|
this.options.interpolation.format = s.formatter.format.bind(s.formatter);
|
|
153062
153059
|
}
|
|
153063
153060
|
s.interpolator = new Interpolator(this.options);
|
|
153064
153061
|
s.utils = {
|
|
153065
|
-
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
153062
|
+
hasLoadedNamespace: this.hasLoadedNamespace.bind(this),
|
|
153063
|
+
reloadResources: this.reloadResources.bind(this)
|
|
153066
153064
|
};
|
|
153067
153065
|
s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
|
|
153068
|
-
s.backendConnector.
|
|
153069
|
-
|
|
153070
|
-
|
|
153071
|
-
}
|
|
153072
|
-
_this.emit(event, ...args);
|
|
153066
|
+
s.backendConnector.devIsDefaultFallback = fallbackLngIsDefault;
|
|
153067
|
+
s.backendConnector.on("*", (event, ...args) => {
|
|
153068
|
+
this.emit(event, ...args);
|
|
153073
153069
|
});
|
|
153074
153070
|
if (this.modules.languageDetector) {
|
|
153075
153071
|
s.languageDetector = createClassOnDemand(this.modules.languageDetector);
|
|
153076
153072
|
if (s.languageDetector.init)
|
|
153077
153073
|
s.languageDetector.init(s, this.options.detection, this.options);
|
|
153074
|
+
if (s.languageDetector.async && callbackApiOf(s.languageDetector) === undefined) {
|
|
153075
|
+
this.logger.deprecate("languageDetector: set callbackApi to declare how the async detect() answers (true: detect(callback); false: detect() returns a promise); guessing it from the number of parameters is deprecated");
|
|
153076
|
+
}
|
|
153078
153077
|
}
|
|
153079
153078
|
if (this.modules.i18nFormat) {
|
|
153080
153079
|
s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
|
|
@@ -153082,11 +153081,8 @@ var init_i18next = __esm(() => {
|
|
|
153082
153081
|
s.i18nFormat.init(this);
|
|
153083
153082
|
}
|
|
153084
153083
|
this.translator = new Translator(this.services, this.options);
|
|
153085
|
-
this.translator.on("*",
|
|
153086
|
-
|
|
153087
|
-
args[_key2 - 1] = arguments[_key2];
|
|
153088
|
-
}
|
|
153089
|
-
_this.emit(event, ...args);
|
|
153084
|
+
this.translator.on("*", (event, ...args) => {
|
|
153085
|
+
this.emit(event, ...args);
|
|
153090
153086
|
});
|
|
153091
153087
|
this.modules.external.forEach((m) => {
|
|
153092
153088
|
if (m.init)
|
|
@@ -153106,15 +153102,13 @@ var init_i18next = __esm(() => {
|
|
|
153106
153102
|
}
|
|
153107
153103
|
const storeApi = ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"];
|
|
153108
153104
|
storeApi.forEach((fcName) => {
|
|
153109
|
-
this[fcName] =
|
|
153110
|
-
return _this.store[fcName](...arguments);
|
|
153111
|
-
};
|
|
153105
|
+
this[fcName] = (...args) => this.store[fcName](...args);
|
|
153112
153106
|
});
|
|
153113
153107
|
const storeApiChained = ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"];
|
|
153114
153108
|
storeApiChained.forEach((fcName) => {
|
|
153115
|
-
this[fcName] =
|
|
153116
|
-
|
|
153117
|
-
return
|
|
153109
|
+
this[fcName] = (...args) => {
|
|
153110
|
+
this.store[fcName](...args);
|
|
153111
|
+
return this;
|
|
153118
153112
|
};
|
|
153119
153113
|
});
|
|
153120
153114
|
const deferred = defer2();
|
|
@@ -153130,25 +153124,24 @@ var init_i18next = __esm(() => {
|
|
|
153130
153124
|
deferred.resolve(t);
|
|
153131
153125
|
callback(err, t);
|
|
153132
153126
|
};
|
|
153133
|
-
if (this.languages
|
|
153127
|
+
if ((this.languages || this.isLanguageChangingTo) && !this.isInitialized)
|
|
153134
153128
|
return finish(null, this.t.bind(this));
|
|
153135
153129
|
this.changeLanguage(this.options.lng, finish);
|
|
153136
153130
|
};
|
|
153137
|
-
if (this.options.resources || !this.options.
|
|
153131
|
+
if (this.options.resources || !this.options.initAsync) {
|
|
153138
153132
|
load();
|
|
153139
153133
|
} else {
|
|
153140
153134
|
setTimeout(load, 0);
|
|
153141
153135
|
}
|
|
153142
153136
|
return deferred;
|
|
153143
153137
|
}
|
|
153144
|
-
loadResources(language) {
|
|
153145
|
-
let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop2;
|
|
153138
|
+
loadResources(language, callback = noop2) {
|
|
153146
153139
|
let usedCallback = callback;
|
|
153147
153140
|
const usedLng = isString2(language) ? language : this.language;
|
|
153148
153141
|
if (typeof language === "function")
|
|
153149
153142
|
usedCallback = language;
|
|
153150
153143
|
if (!this.options.resources || this.options.partialBundledLanguages) {
|
|
153151
|
-
if (usedLng
|
|
153144
|
+
if (usedLng?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0))
|
|
153152
153145
|
return usedCallback();
|
|
153153
153146
|
const toLoad = [];
|
|
153154
153147
|
const append = (lng) => {
|
|
@@ -153160,7 +153153,7 @@ var init_i18next = __esm(() => {
|
|
|
153160
153153
|
lngs.forEach((l) => {
|
|
153161
153154
|
if (l === "cimode")
|
|
153162
153155
|
return;
|
|
153163
|
-
if (toLoad.
|
|
153156
|
+
if (!toLoad.includes(l))
|
|
153164
153157
|
toLoad.push(l);
|
|
153165
153158
|
});
|
|
153166
153159
|
};
|
|
@@ -153170,9 +153163,7 @@ var init_i18next = __esm(() => {
|
|
|
153170
153163
|
} else {
|
|
153171
153164
|
append(usedLng);
|
|
153172
153165
|
}
|
|
153173
|
-
|
|
153174
|
-
this.options.preload.forEach((l) => append(l));
|
|
153175
|
-
}
|
|
153166
|
+
this.options.preload?.forEach?.((l) => append(l));
|
|
153176
153167
|
this.services.backendConnector.load(toLoad, this.options.ns, (e) => {
|
|
153177
153168
|
if (!e && !this.resolvedLanguage && this.language)
|
|
153178
153169
|
this.setResolvedLanguage(this.language);
|
|
@@ -153192,8 +153183,10 @@ var init_i18next = __esm(() => {
|
|
|
153192
153183
|
callback = ns;
|
|
153193
153184
|
ns = undefined;
|
|
153194
153185
|
}
|
|
153195
|
-
if (!lngs)
|
|
153196
|
-
|
|
153186
|
+
if (!lngs) {
|
|
153187
|
+
const requested = Object.keys(this.services.backendConnector.state).map((name) => name.split("|")[0]);
|
|
153188
|
+
lngs = [...new Set([...this.languages || [], ...requested])].filter((l) => l !== "cimode");
|
|
153189
|
+
}
|
|
153197
153190
|
if (!ns)
|
|
153198
153191
|
ns = this.options.ns;
|
|
153199
153192
|
if (!callback)
|
|
@@ -153209,46 +153202,84 @@ var init_i18next = __esm(() => {
|
|
|
153209
153202
|
throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
|
|
153210
153203
|
if (!module.type)
|
|
153211
153204
|
throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
|
|
153205
|
+
const setModule = (type) => {
|
|
153206
|
+
if (this.modules[type] && this.modules[type] !== module) {
|
|
153207
|
+
const msg = `use: this ${type} replaces the ${type} passed to an earlier use() call; only one ${type} is used per instance`;
|
|
153208
|
+
if (this.isInitializing || this.isInitialized)
|
|
153209
|
+
this.logger.warn(msg);
|
|
153210
|
+
else
|
|
153211
|
+
(this.pendingWarnings = this.pendingWarnings || []).push(msg);
|
|
153212
|
+
}
|
|
153213
|
+
this.modules[type] = module;
|
|
153214
|
+
};
|
|
153212
153215
|
if (module.type === "backend") {
|
|
153213
|
-
|
|
153216
|
+
setModule("backend");
|
|
153214
153217
|
}
|
|
153215
153218
|
if (module.type === "logger" || module.log && module.warn && module.error) {
|
|
153216
153219
|
this.modules.logger = module;
|
|
153217
153220
|
}
|
|
153218
153221
|
if (module.type === "languageDetector") {
|
|
153219
|
-
|
|
153222
|
+
setModule("languageDetector");
|
|
153220
153223
|
}
|
|
153221
153224
|
if (module.type === "i18nFormat") {
|
|
153222
|
-
|
|
153225
|
+
setModule("i18nFormat");
|
|
153223
153226
|
}
|
|
153224
153227
|
if (module.type === "postProcessor") {
|
|
153225
153228
|
postProcessor.addPostProcessor(module);
|
|
153229
|
+
this.services.ownPostProcessors?.add(module.name);
|
|
153226
153230
|
}
|
|
153227
153231
|
if (module.type === "formatter") {
|
|
153228
|
-
|
|
153232
|
+
setModule("formatter");
|
|
153229
153233
|
}
|
|
153230
153234
|
if (module.type === "3rdParty") {
|
|
153231
153235
|
this.modules.external.push(module);
|
|
153232
153236
|
}
|
|
153233
153237
|
return this;
|
|
153234
153238
|
}
|
|
153239
|
+
hydrate(resources, lng) {
|
|
153240
|
+
if (this.options.isClone)
|
|
153241
|
+
return this;
|
|
153242
|
+
if (!this.services.resourceStore) {
|
|
153243
|
+
this.logger.warn("hydrate: call init() first, the instance has no resource store yet");
|
|
153244
|
+
return this;
|
|
153245
|
+
}
|
|
153246
|
+
if (resources && !this.initializedStoreOnce) {
|
|
153247
|
+
this.services.resourceStore.data = resources;
|
|
153248
|
+
Object.values(resources).forEach((lngResources) => {
|
|
153249
|
+
Object.keys(lngResources).forEach((ns) => {
|
|
153250
|
+
if (!this.options.ns.includes(ns))
|
|
153251
|
+
this.options.ns.push(ns);
|
|
153252
|
+
});
|
|
153253
|
+
});
|
|
153254
|
+
this.initializedStoreOnce = true;
|
|
153255
|
+
this.isInitialized = true;
|
|
153256
|
+
}
|
|
153257
|
+
if (lng && !this.initializedLanguageOnce) {
|
|
153258
|
+
this.changeLanguage(lng);
|
|
153259
|
+
this.initializedLanguageOnce = true;
|
|
153260
|
+
}
|
|
153261
|
+
return this;
|
|
153262
|
+
}
|
|
153235
153263
|
setResolvedLanguage(l) {
|
|
153236
153264
|
if (!l || !this.languages)
|
|
153237
153265
|
return;
|
|
153238
|
-
if (["cimode", "dev"].
|
|
153266
|
+
if (["cimode", "dev"].includes(l))
|
|
153239
153267
|
return;
|
|
153240
153268
|
for (let li = 0;li < this.languages.length; li++) {
|
|
153241
153269
|
const lngInLngs = this.languages[li];
|
|
153242
|
-
if (["cimode", "dev"].
|
|
153270
|
+
if (["cimode", "dev"].includes(lngInLngs))
|
|
153243
153271
|
continue;
|
|
153244
153272
|
if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
|
|
153245
153273
|
this.resolvedLanguage = lngInLngs;
|
|
153246
153274
|
break;
|
|
153247
153275
|
}
|
|
153248
153276
|
}
|
|
153277
|
+
if (!this.resolvedLanguage && !this.languages.includes(l) && this.store.hasLanguageSomeTranslations(l)) {
|
|
153278
|
+
this.resolvedLanguage = l;
|
|
153279
|
+
this.languages.unshift(l);
|
|
153280
|
+
}
|
|
153249
153281
|
}
|
|
153250
153282
|
changeLanguage(lng, callback) {
|
|
153251
|
-
var _this2 = this;
|
|
153252
153283
|
this.isLanguageChangingTo = lng;
|
|
153253
153284
|
const deferred = defer2();
|
|
153254
153285
|
this.emit("languageChanging", lng);
|
|
@@ -153260,34 +153291,38 @@ var init_i18next = __esm(() => {
|
|
|
153260
153291
|
};
|
|
153261
153292
|
const done = (err, l) => {
|
|
153262
153293
|
if (l) {
|
|
153263
|
-
|
|
153264
|
-
|
|
153265
|
-
|
|
153266
|
-
|
|
153267
|
-
|
|
153294
|
+
if (this.isLanguageChangingTo === lng) {
|
|
153295
|
+
setLngProps(l);
|
|
153296
|
+
this.translator.changeLanguage(l);
|
|
153297
|
+
this.isLanguageChangingTo = undefined;
|
|
153298
|
+
this.emit("languageChanged", l);
|
|
153299
|
+
this.logger.log("languageChanged", l);
|
|
153300
|
+
}
|
|
153268
153301
|
} else {
|
|
153269
153302
|
this.isLanguageChangingTo = undefined;
|
|
153270
153303
|
}
|
|
153271
|
-
deferred.resolve(
|
|
153272
|
-
return _this2.t(...arguments);
|
|
153273
|
-
});
|
|
153304
|
+
deferred.resolve((...args) => this.t(...args));
|
|
153274
153305
|
if (callback)
|
|
153275
|
-
callback(err,
|
|
153276
|
-
return _this2.t(...arguments);
|
|
153277
|
-
});
|
|
153306
|
+
callback(err, (...args) => this.t(...args));
|
|
153278
153307
|
};
|
|
153279
153308
|
const setLng = (lngs) => {
|
|
153280
153309
|
if (!lng && !lngs && this.services.languageDetector)
|
|
153281
153310
|
lngs = [];
|
|
153282
|
-
const
|
|
153311
|
+
const fl = isString2(lngs) ? lngs : lngs && lngs[0];
|
|
153312
|
+
const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString2(lngs) ? [lngs] : lngs);
|
|
153313
|
+
if (l && this.logger.debug && !isSafeLanguageCode(l)) {
|
|
153314
|
+
const configured = [].concat(this.options.supportedLngs || [], this.services.languageUtils.getFallbackCodes(this.options.fallbackLng, l), this.options.preload || []);
|
|
153315
|
+
if (!configured.includes(l) && !Object.prototype.hasOwnProperty.call(this.store.data, l)) {
|
|
153316
|
+
this.logger.once(`lng:${l}`, "deprecate", `changeLanguage: the language code '${l.slice(0, 64)}' comes from lng, changeLanguage() or the language detector and is not configured; from v27 such a code is refused unless it has only letters, digits, '-', '_', '@' and '.' (no '..'), at most 128 characters. Set supportedLngs, or check the code before passing it on`);
|
|
153317
|
+
}
|
|
153318
|
+
}
|
|
153283
153319
|
if (l) {
|
|
153284
153320
|
if (!this.language) {
|
|
153285
153321
|
setLngProps(l);
|
|
153286
153322
|
}
|
|
153287
153323
|
if (!this.translator.language)
|
|
153288
153324
|
this.translator.changeLanguage(l);
|
|
153289
|
-
|
|
153290
|
-
this.services.languageDetector.cacheUserLanguage(l);
|
|
153325
|
+
this.services.languageDetector?.cacheUserLanguage?.(l);
|
|
153291
153326
|
}
|
|
153292
153327
|
this.loadResources(l, (err) => {
|
|
153293
153328
|
done(err, l);
|
|
@@ -153296,7 +153331,8 @@ var init_i18next = __esm(() => {
|
|
|
153296
153331
|
if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
|
|
153297
153332
|
setLng(this.services.languageDetector.detect());
|
|
153298
153333
|
} else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
|
|
153299
|
-
|
|
153334
|
+
const callbackApi = callbackApiOf(this.services.languageDetector);
|
|
153335
|
+
if (callbackApi === false || callbackApi === undefined && this.services.languageDetector.detect.length === 0) {
|
|
153300
153336
|
this.services.languageDetector.detect().then(setLng);
|
|
153301
153337
|
} else {
|
|
153302
153338
|
this.services.languageDetector.detect(setLng);
|
|
@@ -153306,33 +153342,45 @@ var init_i18next = __esm(() => {
|
|
|
153306
153342
|
}
|
|
153307
153343
|
return deferred;
|
|
153308
153344
|
}
|
|
153309
|
-
getFixedT(lng, ns, keyPrefix) {
|
|
153310
|
-
|
|
153311
|
-
const fixedT =
|
|
153312
|
-
let
|
|
153345
|
+
getFixedT(lng, ns, keyPrefix, fixedOpts) {
|
|
153346
|
+
const scopeNs = fixedOpts?.scopeNs;
|
|
153347
|
+
const fixedT = (key, opts, ...rest) => {
|
|
153348
|
+
let o;
|
|
153313
153349
|
if (typeof opts !== "object") {
|
|
153314
|
-
|
|
153315
|
-
rest[_key3 - 2] = arguments[_key3];
|
|
153316
|
-
}
|
|
153317
|
-
options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
|
153350
|
+
o = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
|
153318
153351
|
} else {
|
|
153319
|
-
|
|
153352
|
+
o = {
|
|
153320
153353
|
...opts
|
|
153321
153354
|
};
|
|
153322
153355
|
}
|
|
153323
|
-
|
|
153324
|
-
|
|
153325
|
-
|
|
153326
|
-
|
|
153327
|
-
|
|
153328
|
-
|
|
153356
|
+
o.lng = o.lng || fixedT.lng;
|
|
153357
|
+
o.lngs = o.lngs || fixedT.lngs;
|
|
153358
|
+
const explicitCallNs = o.ns !== undefined && o.ns !== null;
|
|
153359
|
+
o.ns = o.ns || fixedT.ns;
|
|
153360
|
+
if (o.keyPrefix !== "")
|
|
153361
|
+
o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
|
|
153362
|
+
const selectorOpts = {
|
|
153363
|
+
...this.options,
|
|
153364
|
+
...o
|
|
153365
|
+
};
|
|
153366
|
+
if (Array.isArray(scopeNs) && !explicitCallNs)
|
|
153367
|
+
selectorOpts.ns = scopeNs;
|
|
153368
|
+
if (typeof o.keyPrefix === "function")
|
|
153369
|
+
o.keyPrefix = keysFromSelector(o.keyPrefix, selectorOpts);
|
|
153370
|
+
const keySeparator = this.options.keySeparator || ".";
|
|
153329
153371
|
let resultKey;
|
|
153330
|
-
if (
|
|
153331
|
-
resultKey = key.map((k) =>
|
|
153372
|
+
if (o.keyPrefix && Array.isArray(key)) {
|
|
153373
|
+
resultKey = key.map((k) => {
|
|
153374
|
+
if (typeof k === "function")
|
|
153375
|
+
k = keysFromSelector(k, selectorOpts);
|
|
153376
|
+
return `${o.keyPrefix}${keySeparator}${k}`;
|
|
153377
|
+
});
|
|
153332
153378
|
} else {
|
|
153333
|
-
|
|
153379
|
+
if (typeof key === "function")
|
|
153380
|
+
key = keysFromSelector(key, selectorOpts);
|
|
153381
|
+
resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
|
|
153334
153382
|
}
|
|
153335
|
-
return
|
|
153383
|
+
return this.t(resultKey, o);
|
|
153336
153384
|
};
|
|
153337
153385
|
if (isString2(lng)) {
|
|
153338
153386
|
fixedT.lng = lng;
|
|
@@ -153343,17 +153391,20 @@ var init_i18next = __esm(() => {
|
|
|
153343
153391
|
fixedT.keyPrefix = keyPrefix;
|
|
153344
153392
|
return fixedT;
|
|
153345
153393
|
}
|
|
153346
|
-
t() {
|
|
153347
|
-
|
|
153394
|
+
t(...args) {
|
|
153395
|
+
if (!this.translator) {
|
|
153396
|
+
this.logger.warn("t: called before init(); returning an empty string");
|
|
153397
|
+
return "";
|
|
153398
|
+
}
|
|
153399
|
+
return this.translator.translate(...args);
|
|
153348
153400
|
}
|
|
153349
|
-
exists() {
|
|
153350
|
-
return this.translator
|
|
153401
|
+
exists(...args) {
|
|
153402
|
+
return this.translator?.exists(...args);
|
|
153351
153403
|
}
|
|
153352
153404
|
setDefaultNamespace(ns) {
|
|
153353
153405
|
this.options.defaultNS = ns;
|
|
153354
153406
|
}
|
|
153355
|
-
hasLoadedNamespace(ns) {
|
|
153356
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
153407
|
+
hasLoadedNamespace(ns, options = {}) {
|
|
153357
153408
|
if (!this.isInitialized) {
|
|
153358
153409
|
this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
|
|
153359
153410
|
return false;
|
|
@@ -153380,7 +153431,11 @@ var init_i18next = __esm(() => {
|
|
|
153380
153431
|
return true;
|
|
153381
153432
|
if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages)
|
|
153382
153433
|
return true;
|
|
153383
|
-
|
|
153434
|
+
const {
|
|
153435
|
+
languageUtils
|
|
153436
|
+
} = this.services;
|
|
153437
|
+
const loadLng = !options.lng ? lng : languageUtils.isSupportedCode(lng) && languageUtils.toResolveHierarchy(lng, false)[0];
|
|
153438
|
+
if ((!loadLng || loadNotPending(loadLng, ns)) && (!fallbackLng || loadNotPending(lastLng, ns)))
|
|
153384
153439
|
return true;
|
|
153385
153440
|
return false;
|
|
153386
153441
|
}
|
|
@@ -153394,7 +153449,7 @@ var init_i18next = __esm(() => {
|
|
|
153394
153449
|
if (isString2(ns))
|
|
153395
153450
|
ns = [ns];
|
|
153396
153451
|
ns.forEach((n) => {
|
|
153397
|
-
if (this.options.ns.
|
|
153452
|
+
if (!this.options.ns.includes(n))
|
|
153398
153453
|
this.options.ns.push(n);
|
|
153399
153454
|
});
|
|
153400
153455
|
this.loadResources((err) => {
|
|
@@ -153409,7 +153464,7 @@ var init_i18next = __esm(() => {
|
|
|
153409
153464
|
if (isString2(lngs))
|
|
153410
153465
|
lngs = [lngs];
|
|
153411
153466
|
const preloaded = this.options.preload || [];
|
|
153412
|
-
const newLngs = lngs.filter((lng) => preloaded.
|
|
153467
|
+
const newLngs = lngs.filter((lng) => !preloaded.includes(lng) && this.services.languageUtils.isSupportedCode(lng));
|
|
153413
153468
|
if (!newLngs.length) {
|
|
153414
153469
|
if (callback)
|
|
153415
153470
|
callback();
|
|
@@ -153425,26 +153480,39 @@ var init_i18next = __esm(() => {
|
|
|
153425
153480
|
}
|
|
153426
153481
|
dir(lng) {
|
|
153427
153482
|
if (!lng)
|
|
153428
|
-
lng = this.resolvedLanguage || (this.languages
|
|
153483
|
+
lng = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language);
|
|
153429
153484
|
if (!lng)
|
|
153430
|
-
return "
|
|
153485
|
+
return "ltr";
|
|
153486
|
+
try {
|
|
153487
|
+
const l = new Intl.Locale(lng);
|
|
153488
|
+
if (l && l.getTextInfo) {
|
|
153489
|
+
const ti = l.getTextInfo();
|
|
153490
|
+
if (ti && ti.direction)
|
|
153491
|
+
return ti.direction;
|
|
153492
|
+
}
|
|
153493
|
+
} catch (e) {}
|
|
153431
153494
|
const rtlLngs = ["ar", "shu", "sqr", "ssh", "xaa", "yhd", "yud", "aao", "abh", "abv", "acm", "acq", "acw", "acx", "acy", "adf", "ads", "aeb", "aec", "afb", "ajp", "apc", "apd", "arb", "arq", "ars", "ary", "arz", "auz", "avl", "ayh", "ayl", "ayn", "ayp", "bbz", "pga", "he", "iw", "ps", "pbt", "pbu", "pst", "prp", "prd", "ug", "ur", "ydd", "yds", "yih", "ji", "yi", "hbo", "men", "xmn", "fa", "jpr", "peo", "pes", "prs", "dv", "sam", "ckb"];
|
|
153432
|
-
const languageUtils = this.services
|
|
153433
|
-
|
|
153434
|
-
|
|
153435
|
-
|
|
153436
|
-
|
|
153437
|
-
|
|
153438
|
-
|
|
153495
|
+
const languageUtils = this.services?.languageUtils || new LanguageUtil(get2());
|
|
153496
|
+
if (lng.toLowerCase().indexOf("-latn") > 1)
|
|
153497
|
+
return "ltr";
|
|
153498
|
+
return rtlLngs.includes(languageUtils.getLanguagePartFromCode(lng)) || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
|
|
153499
|
+
}
|
|
153500
|
+
static createInstance(options = {}, callback) {
|
|
153501
|
+
const instance = new I18n(options, callback);
|
|
153502
|
+
instance.createInstance = I18n.createInstance;
|
|
153503
|
+
return instance;
|
|
153439
153504
|
}
|
|
153440
|
-
cloneInstance() {
|
|
153441
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
153442
|
-
let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop2;
|
|
153505
|
+
cloneInstance(options = {}, callback = noop2) {
|
|
153443
153506
|
const forkResourceStore = options.forkResourceStore;
|
|
153444
|
-
if (forkResourceStore)
|
|
153507
|
+
if (forkResourceStore) {
|
|
153508
|
+
options = {
|
|
153509
|
+
...options
|
|
153510
|
+
};
|
|
153445
153511
|
delete options.forkResourceStore;
|
|
153512
|
+
}
|
|
153446
153513
|
const mergedOptions = {
|
|
153447
153514
|
...this.options,
|
|
153515
|
+
preload: false,
|
|
153448
153516
|
...options,
|
|
153449
153517
|
...{
|
|
153450
153518
|
isClone: true
|
|
@@ -153462,24 +153530,45 @@ var init_i18next = __esm(() => {
|
|
|
153462
153530
|
...this.services
|
|
153463
153531
|
};
|
|
153464
153532
|
clone.services.utils = {
|
|
153465
|
-
|
|
153533
|
+
...clone.services.utils,
|
|
153534
|
+
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone),
|
|
153535
|
+
reloadResources: clone.reloadResources.bind(clone)
|
|
153466
153536
|
};
|
|
153467
153537
|
if (forkResourceStore) {
|
|
153468
|
-
|
|
153538
|
+
const copyData = (obj) => {
|
|
153539
|
+
const copied = Array.isArray(obj) ? [...obj] : {
|
|
153540
|
+
...obj
|
|
153541
|
+
};
|
|
153542
|
+
Object.keys(copied).forEach((k) => {
|
|
153543
|
+
if (copied[k] && typeof copied[k] === "object")
|
|
153544
|
+
copied[k] = copyData(copied[k]);
|
|
153545
|
+
});
|
|
153546
|
+
return copied;
|
|
153547
|
+
};
|
|
153548
|
+
const clonedData = copyData(this.store.data);
|
|
153549
|
+
clone.store = new ResourceStore(clonedData, mergedOptions);
|
|
153469
153550
|
clone.services.resourceStore = clone.store;
|
|
153470
153551
|
}
|
|
153552
|
+
if (options.interpolation) {
|
|
153553
|
+
const defOpts = get2();
|
|
153554
|
+
const mergedInterpolation = {
|
|
153555
|
+
...defOpts.interpolation,
|
|
153556
|
+
...this.options.interpolation,
|
|
153557
|
+
...options.interpolation
|
|
153558
|
+
};
|
|
153559
|
+
const mergedForInterpolator = {
|
|
153560
|
+
...mergedOptions,
|
|
153561
|
+
interpolation: mergedInterpolation
|
|
153562
|
+
};
|
|
153563
|
+
clone.services.interpolator = new Interpolator(mergedForInterpolator);
|
|
153564
|
+
}
|
|
153471
153565
|
clone.translator = new Translator(clone.services, mergedOptions);
|
|
153472
|
-
clone.translator.on("*",
|
|
153473
|
-
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1;_key4 < _len4; _key4++) {
|
|
153474
|
-
args[_key4 - 1] = arguments[_key4];
|
|
153475
|
-
}
|
|
153566
|
+
clone.translator.on("*", (event, ...args) => {
|
|
153476
153567
|
clone.emit(event, ...args);
|
|
153477
153568
|
});
|
|
153478
153569
|
clone.init(mergedOptions, callback);
|
|
153479
153570
|
clone.translator.options = mergedOptions;
|
|
153480
|
-
clone.translator.backendConnector.
|
|
153481
|
-
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
|
153482
|
-
};
|
|
153571
|
+
clone.translator.backendConnector.newestCloneHasLoadedNamespace = clone.hasLoadedNamespace.bind(clone);
|
|
153483
153572
|
return clone;
|
|
153484
153573
|
}
|
|
153485
153574
|
toJSON() {
|
|
@@ -153493,7 +153582,6 @@ var init_i18next = __esm(() => {
|
|
|
153493
153582
|
}
|
|
153494
153583
|
};
|
|
153495
153584
|
instance = I18n.createInstance();
|
|
153496
|
-
instance.createInstance = I18n.createInstance;
|
|
153497
153585
|
createInstance = instance.createInstance;
|
|
153498
153586
|
dir = instance.dir;
|
|
153499
153587
|
init = instance.init;
|
|
@@ -265517,4 +265605,4 @@ export {
|
|
|
265517
265605
|
studioCatalogTypeCache
|
|
265518
265606
|
};
|
|
265519
265607
|
|
|
265520
|
-
//# debugId=
|
|
265608
|
+
//# debugId=AB14E8F76C8898D564756E2164756E21
|