gantt-task-react-v 1.0.35 → 1.0.36
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/gantt-task-react.es.js +305 -324
- package/dist/gantt-task-react.umd.js +305 -324
- package/dist/helpers/use-element-width.d.ts +1 -0
- package/dist/style.css +30 -43
- package/package.json +8 -7
|
@@ -170,8 +170,7 @@ const looksLikeObjectPath = (key2, nsSeparator, keySeparator) => {
|
|
|
170
170
|
}
|
|
171
171
|
return matched;
|
|
172
172
|
};
|
|
173
|
-
const deepFind =
|
|
174
|
-
let keySeparator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
|
|
173
|
+
const deepFind = (obj, path, keySeparator = ".") => {
|
|
175
174
|
if (!obj)
|
|
176
175
|
return void 0;
|
|
177
176
|
if (obj[path]) {
|
|
@@ -223,39 +222,25 @@ const consoleLogger = {
|
|
|
223
222
|
}
|
|
224
223
|
};
|
|
225
224
|
class Logger {
|
|
226
|
-
constructor(concreteLogger) {
|
|
227
|
-
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
225
|
+
constructor(concreteLogger, options = {}) {
|
|
228
226
|
this.init(concreteLogger, options);
|
|
229
227
|
}
|
|
230
|
-
init(concreteLogger) {
|
|
231
|
-
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
228
|
+
init(concreteLogger, options = {}) {
|
|
232
229
|
this.prefix = options.prefix || "i18next:";
|
|
233
230
|
this.logger = concreteLogger || consoleLogger;
|
|
234
231
|
this.options = options;
|
|
235
232
|
this.debug = options.debug;
|
|
236
233
|
}
|
|
237
|
-
log() {
|
|
238
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
239
|
-
args[_key] = arguments[_key];
|
|
240
|
-
}
|
|
234
|
+
log(...args) {
|
|
241
235
|
return this.forward(args, "log", "", true);
|
|
242
236
|
}
|
|
243
|
-
warn() {
|
|
244
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
245
|
-
args[_key2] = arguments[_key2];
|
|
246
|
-
}
|
|
237
|
+
warn(...args) {
|
|
247
238
|
return this.forward(args, "warn", "", true);
|
|
248
239
|
}
|
|
249
|
-
error() {
|
|
250
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
251
|
-
args[_key3] = arguments[_key3];
|
|
252
|
-
}
|
|
240
|
+
error(...args) {
|
|
253
241
|
return this.forward(args, "error", "");
|
|
254
242
|
}
|
|
255
|
-
deprecate() {
|
|
256
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
257
|
-
args[_key4] = arguments[_key4];
|
|
258
|
-
}
|
|
243
|
+
deprecate(...args) {
|
|
259
244
|
return this.forward(args, "warn", "WARNING DEPRECATED: ", true);
|
|
260
245
|
}
|
|
261
246
|
forward(args, lvl, prefix, debugOnly) {
|
|
@@ -302,14 +287,10 @@ class EventEmitter {
|
|
|
302
287
|
}
|
|
303
288
|
this.observers[event].delete(listener);
|
|
304
289
|
}
|
|
305
|
-
emit(event) {
|
|
306
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
307
|
-
args[_key - 1] = arguments[_key];
|
|
308
|
-
}
|
|
290
|
+
emit(event, ...args) {
|
|
309
291
|
if (this.observers[event]) {
|
|
310
292
|
const cloned = Array.from(this.observers[event].entries());
|
|
311
|
-
cloned.forEach((
|
|
312
|
-
let [observer, numTimesAdded] = _ref;
|
|
293
|
+
cloned.forEach(([observer, numTimesAdded]) => {
|
|
313
294
|
for (let i = 0; i < numTimesAdded; i++) {
|
|
314
295
|
observer(...args);
|
|
315
296
|
}
|
|
@@ -317,8 +298,7 @@ class EventEmitter {
|
|
|
317
298
|
}
|
|
318
299
|
if (this.observers["*"]) {
|
|
319
300
|
const cloned = Array.from(this.observers["*"].entries());
|
|
320
|
-
cloned.forEach((
|
|
321
|
-
let [observer, numTimesAdded] = _ref2;
|
|
301
|
+
cloned.forEach(([observer, numTimesAdded]) => {
|
|
322
302
|
for (let i = 0; i < numTimesAdded; i++) {
|
|
323
303
|
observer.apply(observer, [event, ...args]);
|
|
324
304
|
}
|
|
@@ -327,11 +307,10 @@ class EventEmitter {
|
|
|
327
307
|
}
|
|
328
308
|
}
|
|
329
309
|
class ResourceStore extends EventEmitter {
|
|
330
|
-
constructor(data
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
};
|
|
310
|
+
constructor(data, options = {
|
|
311
|
+
ns: ["translation"],
|
|
312
|
+
defaultNS: "translation"
|
|
313
|
+
}) {
|
|
335
314
|
super();
|
|
336
315
|
this.data = data || {};
|
|
337
316
|
this.options = options;
|
|
@@ -353,9 +332,8 @@ class ResourceStore extends EventEmitter {
|
|
|
353
332
|
this.options.ns.splice(index2, 1);
|
|
354
333
|
}
|
|
355
334
|
}
|
|
356
|
-
getResource(lng, ns, key2) {
|
|
335
|
+
getResource(lng, ns, key2, options = {}) {
|
|
357
336
|
var _a, _b;
|
|
358
|
-
let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
359
337
|
const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
|
|
360
338
|
const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
361
339
|
let path;
|
|
@@ -383,10 +361,9 @@ class ResourceStore extends EventEmitter {
|
|
|
383
361
|
return result;
|
|
384
362
|
return deepFind((_b = (_a = this.data) == null ? void 0 : _a[lng]) == null ? void 0 : _b[ns], key2, keySeparator);
|
|
385
363
|
}
|
|
386
|
-
addResource(lng, ns, key2, value
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
};
|
|
364
|
+
addResource(lng, ns, key2, value, options = {
|
|
365
|
+
silent: false
|
|
366
|
+
}) {
|
|
390
367
|
const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
|
|
391
368
|
let path = [lng, ns];
|
|
392
369
|
if (key2)
|
|
@@ -401,10 +378,9 @@ class ResourceStore extends EventEmitter {
|
|
|
401
378
|
if (!options.silent)
|
|
402
379
|
this.emit("added", lng, ns, key2, value);
|
|
403
380
|
}
|
|
404
|
-
addResources(lng, ns, resources
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
};
|
|
381
|
+
addResources(lng, ns, resources, options = {
|
|
382
|
+
silent: false
|
|
383
|
+
}) {
|
|
408
384
|
for (const m in resources) {
|
|
409
385
|
if (isString$1(resources[m]) || Array.isArray(resources[m]))
|
|
410
386
|
this.addResource(lng, ns, m, resources[m], {
|
|
@@ -414,11 +390,10 @@ class ResourceStore extends EventEmitter {
|
|
|
414
390
|
if (!options.silent)
|
|
415
391
|
this.emit("added", lng, ns, resources);
|
|
416
392
|
}
|
|
417
|
-
addResourceBundle(lng, ns, resources, deep, overwrite
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
};
|
|
393
|
+
addResourceBundle(lng, ns, resources, deep, overwrite, options = {
|
|
394
|
+
silent: false,
|
|
395
|
+
skipCopy: false
|
|
396
|
+
}) {
|
|
422
397
|
let path = [lng, ns];
|
|
423
398
|
if (lng.indexOf(".") > -1) {
|
|
424
399
|
path = lng.split(".");
|
|
@@ -482,11 +457,32 @@ var postProcessor = {
|
|
|
482
457
|
return value;
|
|
483
458
|
}
|
|
484
459
|
};
|
|
460
|
+
const PATH_KEY = Symbol("i18next/PATH_KEY");
|
|
461
|
+
function createProxy() {
|
|
462
|
+
const state = [];
|
|
463
|
+
const handler = /* @__PURE__ */ Object.create(null);
|
|
464
|
+
let proxy;
|
|
465
|
+
handler.get = (target, key2) => {
|
|
466
|
+
var _a;
|
|
467
|
+
(_a = proxy == null ? void 0 : proxy.revoke) == null ? void 0 : _a.call(proxy);
|
|
468
|
+
if (key2 === PATH_KEY)
|
|
469
|
+
return state;
|
|
470
|
+
state.push(key2);
|
|
471
|
+
proxy = Proxy.revocable(target, handler);
|
|
472
|
+
return proxy.proxy;
|
|
473
|
+
};
|
|
474
|
+
return Proxy.revocable(/* @__PURE__ */ Object.create(null), handler).proxy;
|
|
475
|
+
}
|
|
476
|
+
function keysFromSelector(selector, opts) {
|
|
477
|
+
const {
|
|
478
|
+
[PATH_KEY]: path
|
|
479
|
+
} = selector(createProxy());
|
|
480
|
+
return path.join((opts == null ? void 0 : opts.keySeparator) ?? ".");
|
|
481
|
+
}
|
|
485
482
|
const checkedLoadedFor = {};
|
|
486
483
|
const shouldHandleAsObject = (res) => !isString$1(res) && typeof res !== "boolean" && typeof res !== "number";
|
|
487
484
|
class Translator extends EventEmitter {
|
|
488
|
-
constructor(services) {
|
|
489
|
-
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
485
|
+
constructor(services, options = {}) {
|
|
490
486
|
super();
|
|
491
487
|
copy(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], services, this);
|
|
492
488
|
this.options = options;
|
|
@@ -499,24 +495,25 @@ class Translator extends EventEmitter {
|
|
|
499
495
|
if (lng)
|
|
500
496
|
this.language = lng;
|
|
501
497
|
}
|
|
502
|
-
exists(key2
|
|
503
|
-
|
|
504
|
-
|
|
498
|
+
exists(key2, o = {
|
|
499
|
+
interpolation: {}
|
|
500
|
+
}) {
|
|
501
|
+
const opt = {
|
|
502
|
+
...o
|
|
505
503
|
};
|
|
506
|
-
if (key2 == null)
|
|
504
|
+
if (key2 == null)
|
|
507
505
|
return false;
|
|
508
|
-
|
|
509
|
-
const resolved = this.resolve(key2, options);
|
|
506
|
+
const resolved = this.resolve(key2, opt);
|
|
510
507
|
return (resolved == null ? void 0 : resolved.res) !== void 0;
|
|
511
508
|
}
|
|
512
|
-
extractFromKey(key2,
|
|
513
|
-
let nsSeparator =
|
|
509
|
+
extractFromKey(key2, opt) {
|
|
510
|
+
let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
|
|
514
511
|
if (nsSeparator === void 0)
|
|
515
512
|
nsSeparator = ":";
|
|
516
|
-
const keySeparator =
|
|
517
|
-
let namespaces =
|
|
513
|
+
const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
|
|
514
|
+
let namespaces = opt.ns || this.options.defaultNS || [];
|
|
518
515
|
const wouldCheckForNsInKey = nsSeparator && key2.indexOf(nsSeparator) > -1;
|
|
519
|
-
const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !
|
|
516
|
+
const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key2, nsSeparator, keySeparator);
|
|
520
517
|
if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
|
|
521
518
|
const m = key2.match(this.interpolator.nestingRegexp);
|
|
522
519
|
if (m && m.length > 0) {
|
|
@@ -535,32 +532,42 @@ class Translator extends EventEmitter {
|
|
|
535
532
|
namespaces: isString$1(namespaces) ? [namespaces] : namespaces
|
|
536
533
|
};
|
|
537
534
|
}
|
|
538
|
-
translate(keys,
|
|
539
|
-
|
|
540
|
-
|
|
535
|
+
translate(keys, o, lastKey) {
|
|
536
|
+
let opt = typeof o === "object" ? {
|
|
537
|
+
...o
|
|
538
|
+
} : o;
|
|
539
|
+
if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) {
|
|
540
|
+
opt = this.options.overloadTranslationOptionHandler(arguments);
|
|
541
541
|
}
|
|
542
|
-
if (typeof
|
|
543
|
-
|
|
544
|
-
...
|
|
542
|
+
if (typeof opt === "object")
|
|
543
|
+
opt = {
|
|
544
|
+
...opt
|
|
545
545
|
};
|
|
546
|
-
if (!
|
|
547
|
-
|
|
546
|
+
if (!opt)
|
|
547
|
+
opt = {};
|
|
548
548
|
if (keys == null)
|
|
549
549
|
return "";
|
|
550
|
+
if (typeof keys === "function")
|
|
551
|
+
keys = keysFromSelector(keys, {
|
|
552
|
+
...this.options,
|
|
553
|
+
...opt
|
|
554
|
+
});
|
|
550
555
|
if (!Array.isArray(keys))
|
|
551
556
|
keys = [String(keys)];
|
|
552
|
-
const returnDetails =
|
|
553
|
-
const keySeparator =
|
|
557
|
+
const returnDetails = opt.returnDetails !== void 0 ? opt.returnDetails : this.options.returnDetails;
|
|
558
|
+
const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
|
|
554
559
|
const {
|
|
555
560
|
key: key2,
|
|
556
561
|
namespaces
|
|
557
|
-
} = this.extractFromKey(keys[keys.length - 1],
|
|
562
|
+
} = this.extractFromKey(keys[keys.length - 1], opt);
|
|
558
563
|
const namespace = namespaces[namespaces.length - 1];
|
|
559
|
-
|
|
560
|
-
|
|
564
|
+
let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
|
|
565
|
+
if (nsSeparator === void 0)
|
|
566
|
+
nsSeparator = ":";
|
|
567
|
+
const lng = opt.lng || this.language;
|
|
568
|
+
const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
561
569
|
if ((lng == null ? void 0 : lng.toLowerCase()) === "cimode") {
|
|
562
570
|
if (appendNamespaceToCIMode) {
|
|
563
|
-
const nsSeparator = options.nsSeparator || this.options.nsSeparator;
|
|
564
571
|
if (returnDetails) {
|
|
565
572
|
return {
|
|
566
573
|
res: `${namespace}${nsSeparator}${key2}`,
|
|
@@ -568,7 +575,7 @@ class Translator extends EventEmitter {
|
|
|
568
575
|
exactUsedKey: key2,
|
|
569
576
|
usedLng: lng,
|
|
570
577
|
usedNS: namespace,
|
|
571
|
-
usedParams: this.getUsedParamsDetails(
|
|
578
|
+
usedParams: this.getUsedParamsDetails(opt)
|
|
572
579
|
};
|
|
573
580
|
}
|
|
574
581
|
return `${namespace}${nsSeparator}${key2}`;
|
|
@@ -580,26 +587,26 @@ class Translator extends EventEmitter {
|
|
|
580
587
|
exactUsedKey: key2,
|
|
581
588
|
usedLng: lng,
|
|
582
589
|
usedNS: namespace,
|
|
583
|
-
usedParams: this.getUsedParamsDetails(
|
|
590
|
+
usedParams: this.getUsedParamsDetails(opt)
|
|
584
591
|
};
|
|
585
592
|
}
|
|
586
593
|
return key2;
|
|
587
594
|
}
|
|
588
|
-
const resolved = this.resolve(keys,
|
|
595
|
+
const resolved = this.resolve(keys, opt);
|
|
589
596
|
let res = resolved == null ? void 0 : resolved.res;
|
|
590
597
|
const resUsedKey = (resolved == null ? void 0 : resolved.usedKey) || key2;
|
|
591
598
|
const resExactUsedKey = (resolved == null ? void 0 : resolved.exactUsedKey) || key2;
|
|
592
599
|
const noObject = ["[object Number]", "[object Function]", "[object RegExp]"];
|
|
593
|
-
const joinArrays =
|
|
600
|
+
const joinArrays = opt.joinArrays !== void 0 ? opt.joinArrays : this.options.joinArrays;
|
|
594
601
|
const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
|
595
|
-
const needsPluralHandling =
|
|
596
|
-
const hasDefaultValue = Translator.hasDefaultValue(
|
|
597
|
-
const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng,
|
|
598
|
-
const defaultValueSuffixOrdinalFallback =
|
|
602
|
+
const needsPluralHandling = opt.count !== void 0 && !isString$1(opt.count);
|
|
603
|
+
const hasDefaultValue = Translator.hasDefaultValue(opt);
|
|
604
|
+
const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : "";
|
|
605
|
+
const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, {
|
|
599
606
|
ordinal: false
|
|
600
607
|
}) : "";
|
|
601
|
-
const needsZeroSuffixLookup = needsPluralHandling && !
|
|
602
|
-
const defaultValue2 = needsZeroSuffixLookup &&
|
|
608
|
+
const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
|
|
609
|
+
const defaultValue2 = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
|
|
603
610
|
let resForObjHndl = res;
|
|
604
611
|
if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
|
|
605
612
|
resForObjHndl = defaultValue2;
|
|
@@ -607,17 +614,17 @@ class Translator extends EventEmitter {
|
|
|
607
614
|
const handleAsObject = shouldHandleAsObject(resForObjHndl);
|
|
608
615
|
const resType = Object.prototype.toString.apply(resForObjHndl);
|
|
609
616
|
if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString$1(joinArrays) && Array.isArray(resForObjHndl))) {
|
|
610
|
-
if (!
|
|
617
|
+
if (!opt.returnObjects && !this.options.returnObjects) {
|
|
611
618
|
if (!this.options.returnedObjectHandler) {
|
|
612
619
|
this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
613
620
|
}
|
|
614
621
|
const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
|
|
615
|
-
...
|
|
622
|
+
...opt,
|
|
616
623
|
ns: namespaces
|
|
617
624
|
}) : `key '${key2} (${this.language})' returned an object instead of string.`;
|
|
618
625
|
if (returnDetails) {
|
|
619
626
|
resolved.res = r;
|
|
620
|
-
resolved.usedParams = this.getUsedParamsDetails(
|
|
627
|
+
resolved.usedParams = this.getUsedParamsDetails(opt);
|
|
621
628
|
return resolved;
|
|
622
629
|
}
|
|
623
630
|
return r;
|
|
@@ -631,7 +638,7 @@ class Translator extends EventEmitter {
|
|
|
631
638
|
const deepKey = `${newKeyToUse}${keySeparator}${m}`;
|
|
632
639
|
if (hasDefaultValue && !res) {
|
|
633
640
|
copy2[m] = this.translate(deepKey, {
|
|
634
|
-
...
|
|
641
|
+
...opt,
|
|
635
642
|
defaultValue: shouldHandleAsObject(defaultValue2) ? defaultValue2[m] : void 0,
|
|
636
643
|
...{
|
|
637
644
|
joinArrays: false,
|
|
@@ -640,7 +647,7 @@ class Translator extends EventEmitter {
|
|
|
640
647
|
});
|
|
641
648
|
} else {
|
|
642
649
|
copy2[m] = this.translate(deepKey, {
|
|
643
|
-
...
|
|
650
|
+
...opt,
|
|
644
651
|
...{
|
|
645
652
|
joinArrays: false,
|
|
646
653
|
ns: namespaces
|
|
@@ -656,7 +663,7 @@ class Translator extends EventEmitter {
|
|
|
656
663
|
} else if (handleAsObjectInI18nFormat && isString$1(joinArrays) && Array.isArray(res)) {
|
|
657
664
|
res = res.join(joinArrays);
|
|
658
665
|
if (res)
|
|
659
|
-
res = this.extendTranslation(res, keys,
|
|
666
|
+
res = this.extendTranslation(res, keys, opt, lastKey);
|
|
660
667
|
} else {
|
|
661
668
|
let usedDefault = false;
|
|
662
669
|
let usedKey = false;
|
|
@@ -668,49 +675,49 @@ class Translator extends EventEmitter {
|
|
|
668
675
|
usedKey = true;
|
|
669
676
|
res = key2;
|
|
670
677
|
}
|
|
671
|
-
const missingKeyNoValueFallbackToKey =
|
|
678
|
+
const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
|
|
672
679
|
const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? void 0 : res;
|
|
673
680
|
const updateMissing = hasDefaultValue && defaultValue2 !== res && this.options.updateMissing;
|
|
674
681
|
if (usedKey || usedDefault || updateMissing) {
|
|
675
682
|
this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, key2, updateMissing ? defaultValue2 : res);
|
|
676
683
|
if (keySeparator) {
|
|
677
684
|
const fk = this.resolve(key2, {
|
|
678
|
-
...
|
|
685
|
+
...opt,
|
|
679
686
|
keySeparator: false
|
|
680
687
|
});
|
|
681
688
|
if (fk && fk.res)
|
|
682
689
|
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.");
|
|
683
690
|
}
|
|
684
691
|
let lngs = [];
|
|
685
|
-
const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng,
|
|
692
|
+
const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
|
|
686
693
|
if (this.options.saveMissingTo === "fallback" && fallbackLngs && fallbackLngs[0]) {
|
|
687
694
|
for (let i = 0; i < fallbackLngs.length; i++) {
|
|
688
695
|
lngs.push(fallbackLngs[i]);
|
|
689
696
|
}
|
|
690
697
|
} else if (this.options.saveMissingTo === "all") {
|
|
691
|
-
lngs = this.languageUtils.toResolveHierarchy(
|
|
698
|
+
lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
|
|
692
699
|
} else {
|
|
693
|
-
lngs.push(
|
|
700
|
+
lngs.push(opt.lng || this.language);
|
|
694
701
|
}
|
|
695
702
|
const send = (l, k, specificDefaultValue) => {
|
|
696
703
|
var _a;
|
|
697
704
|
const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
|
|
698
705
|
if (this.options.missingKeyHandler) {
|
|
699
|
-
this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing,
|
|
706
|
+
this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
|
|
700
707
|
} else if ((_a = this.backendConnector) == null ? void 0 : _a.saveMissing) {
|
|
701
|
-
this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing,
|
|
708
|
+
this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
|
|
702
709
|
}
|
|
703
710
|
this.emit("missingKey", l, namespace, k, res);
|
|
704
711
|
};
|
|
705
712
|
if (this.options.saveMissing) {
|
|
706
713
|
if (this.options.saveMissingPlurals && needsPluralHandling) {
|
|
707
714
|
lngs.forEach((language) => {
|
|
708
|
-
const suffixes = this.pluralResolver.getSuffixes(language,
|
|
709
|
-
if (needsZeroSuffixLookup &&
|
|
715
|
+
const suffixes = this.pluralResolver.getSuffixes(language, opt);
|
|
716
|
+
if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
|
|
710
717
|
suffixes.push(`${this.options.pluralSeparator}zero`);
|
|
711
718
|
}
|
|
712
719
|
suffixes.forEach((suffix) => {
|
|
713
|
-
send([language], key2 + suffix,
|
|
720
|
+
send([language], key2 + suffix, opt[`defaultValue${suffix}`] || defaultValue2);
|
|
714
721
|
});
|
|
715
722
|
});
|
|
716
723
|
} else {
|
|
@@ -718,91 +725,87 @@ class Translator extends EventEmitter {
|
|
|
718
725
|
}
|
|
719
726
|
}
|
|
720
727
|
}
|
|
721
|
-
res = this.extendTranslation(res, keys,
|
|
722
|
-
if (usedKey && res === key2 && this.options.appendNamespaceToMissingKey)
|
|
723
|
-
res = `${namespace}
|
|
728
|
+
res = this.extendTranslation(res, keys, opt, resolved, lastKey);
|
|
729
|
+
if (usedKey && res === key2 && this.options.appendNamespaceToMissingKey) {
|
|
730
|
+
res = `${namespace}${nsSeparator}${key2}`;
|
|
731
|
+
}
|
|
724
732
|
if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
|
|
725
|
-
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}
|
|
733
|
+
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key2}` : key2, usedDefault ? res : void 0, opt);
|
|
726
734
|
}
|
|
727
735
|
}
|
|
728
736
|
if (returnDetails) {
|
|
729
737
|
resolved.res = res;
|
|
730
|
-
resolved.usedParams = this.getUsedParamsDetails(
|
|
738
|
+
resolved.usedParams = this.getUsedParamsDetails(opt);
|
|
731
739
|
return resolved;
|
|
732
740
|
}
|
|
733
741
|
return res;
|
|
734
742
|
}
|
|
735
|
-
extendTranslation(res, key2,
|
|
743
|
+
extendTranslation(res, key2, opt, resolved, lastKey) {
|
|
736
744
|
var _a, _b;
|
|
737
|
-
var _this = this;
|
|
738
745
|
if ((_a = this.i18nFormat) == null ? void 0 : _a.parse) {
|
|
739
746
|
res = this.i18nFormat.parse(res, {
|
|
740
747
|
...this.options.interpolation.defaultVariables,
|
|
741
|
-
...
|
|
742
|
-
},
|
|
748
|
+
...opt
|
|
749
|
+
}, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
|
|
743
750
|
resolved
|
|
744
751
|
});
|
|
745
|
-
} else if (!
|
|
746
|
-
if (
|
|
752
|
+
} else if (!opt.skipInterpolation) {
|
|
753
|
+
if (opt.interpolation)
|
|
747
754
|
this.interpolator.init({
|
|
748
|
-
...
|
|
755
|
+
...opt,
|
|
749
756
|
...{
|
|
750
757
|
interpolation: {
|
|
751
758
|
...this.options.interpolation,
|
|
752
|
-
...
|
|
759
|
+
...opt.interpolation
|
|
753
760
|
}
|
|
754
761
|
}
|
|
755
762
|
});
|
|
756
|
-
const skipOnVariables = isString$1(res) && (((_b =
|
|
763
|
+
const skipOnVariables = isString$1(res) && (((_b = opt == null ? void 0 : opt.interpolation) == null ? void 0 : _b.skipOnVariables) !== void 0 ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
757
764
|
let nestBef;
|
|
758
765
|
if (skipOnVariables) {
|
|
759
766
|
const nb = res.match(this.interpolator.nestingRegexp);
|
|
760
767
|
nestBef = nb && nb.length;
|
|
761
768
|
}
|
|
762
|
-
let data =
|
|
769
|
+
let data = opt.replace && !isString$1(opt.replace) ? opt.replace : opt;
|
|
763
770
|
if (this.options.interpolation.defaultVariables)
|
|
764
771
|
data = {
|
|
765
772
|
...this.options.interpolation.defaultVariables,
|
|
766
773
|
...data
|
|
767
774
|
};
|
|
768
|
-
res = this.interpolator.interpolate(res, data,
|
|
775
|
+
res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
|
|
769
776
|
if (skipOnVariables) {
|
|
770
777
|
const na = res.match(this.interpolator.nestingRegexp);
|
|
771
778
|
const nestAft = na && na.length;
|
|
772
779
|
if (nestBef < nestAft)
|
|
773
|
-
|
|
774
|
-
}
|
|
775
|
-
if (!
|
|
776
|
-
|
|
777
|
-
if (
|
|
778
|
-
res = this.interpolator.nest(res,
|
|
779
|
-
|
|
780
|
-
args[
|
|
781
|
-
}
|
|
782
|
-
if ((lastKey == null ? void 0 : lastKey[0]) === args[0] && !options.context) {
|
|
783
|
-
_this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key2[0]}`);
|
|
780
|
+
opt.nest = false;
|
|
781
|
+
}
|
|
782
|
+
if (!opt.lng && resolved && resolved.res)
|
|
783
|
+
opt.lng = this.language || resolved.usedLng;
|
|
784
|
+
if (opt.nest !== false)
|
|
785
|
+
res = this.interpolator.nest(res, (...args) => {
|
|
786
|
+
if ((lastKey == null ? void 0 : lastKey[0]) === args[0] && !opt.context) {
|
|
787
|
+
this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key2[0]}`);
|
|
784
788
|
return null;
|
|
785
789
|
}
|
|
786
|
-
return
|
|
787
|
-
},
|
|
788
|
-
if (
|
|
790
|
+
return this.translate(...args, key2);
|
|
791
|
+
}, opt);
|
|
792
|
+
if (opt.interpolation)
|
|
789
793
|
this.interpolator.reset();
|
|
790
794
|
}
|
|
791
|
-
const postProcess =
|
|
795
|
+
const postProcess = opt.postProcess || this.options.postProcess;
|
|
792
796
|
const postProcessorNames = isString$1(postProcess) ? [postProcess] : postProcess;
|
|
793
|
-
if (res != null && (postProcessorNames == null ? void 0 : postProcessorNames.length) &&
|
|
797
|
+
if (res != null && (postProcessorNames == null ? void 0 : postProcessorNames.length) && opt.applyPostProcessor !== false) {
|
|
794
798
|
res = postProcessor.handle(postProcessorNames, res, key2, this.options && this.options.postProcessPassResolved ? {
|
|
795
799
|
i18nResolved: {
|
|
796
800
|
...resolved,
|
|
797
|
-
usedParams: this.getUsedParamsDetails(
|
|
801
|
+
usedParams: this.getUsedParamsDetails(opt)
|
|
798
802
|
},
|
|
799
|
-
...
|
|
800
|
-
} :
|
|
803
|
+
...opt
|
|
804
|
+
} : opt, this);
|
|
801
805
|
}
|
|
802
806
|
return res;
|
|
803
807
|
}
|
|
804
|
-
resolve(keys) {
|
|
805
|
-
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
808
|
+
resolve(keys, opt = {}) {
|
|
806
809
|
let found;
|
|
807
810
|
let usedKey;
|
|
808
811
|
let exactUsedKey;
|
|
@@ -813,16 +816,16 @@ class Translator extends EventEmitter {
|
|
|
813
816
|
keys.forEach((k) => {
|
|
814
817
|
if (this.isValidLookup(found))
|
|
815
818
|
return;
|
|
816
|
-
const extracted = this.extractFromKey(k,
|
|
819
|
+
const extracted = this.extractFromKey(k, opt);
|
|
817
820
|
const key2 = extracted.key;
|
|
818
821
|
usedKey = key2;
|
|
819
822
|
let namespaces = extracted.namespaces;
|
|
820
823
|
if (this.options.fallbackNS)
|
|
821
824
|
namespaces = namespaces.concat(this.options.fallbackNS);
|
|
822
|
-
const needsPluralHandling =
|
|
823
|
-
const needsZeroSuffixLookup = needsPluralHandling && !
|
|
824
|
-
const needsContextHandling =
|
|
825
|
-
const codes =
|
|
825
|
+
const needsPluralHandling = opt.count !== void 0 && !isString$1(opt.count);
|
|
826
|
+
const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
|
|
827
|
+
const needsContextHandling = opt.context !== void 0 && (isString$1(opt.context) || typeof opt.context === "number") && opt.context !== "";
|
|
828
|
+
const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
|
|
826
829
|
namespaces.forEach((ns) => {
|
|
827
830
|
var _a, _b;
|
|
828
831
|
if (this.isValidLookup(found))
|
|
@@ -839,30 +842,30 @@ class Translator extends EventEmitter {
|
|
|
839
842
|
usedLng = code;
|
|
840
843
|
const finalKeys = [key2];
|
|
841
844
|
if ((_a2 = this.i18nFormat) == null ? void 0 : _a2.addLookupKeys) {
|
|
842
|
-
this.i18nFormat.addLookupKeys(finalKeys, key2, code, ns,
|
|
845
|
+
this.i18nFormat.addLookupKeys(finalKeys, key2, code, ns, opt);
|
|
843
846
|
} else {
|
|
844
847
|
let pluralSuffix;
|
|
845
848
|
if (needsPluralHandling)
|
|
846
|
-
pluralSuffix = this.pluralResolver.getSuffix(code,
|
|
849
|
+
pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
|
|
847
850
|
const zeroSuffix = `${this.options.pluralSeparator}zero`;
|
|
848
851
|
const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
849
852
|
if (needsPluralHandling) {
|
|
850
|
-
|
|
851
|
-
if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
|
|
853
|
+
if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
|
|
852
854
|
finalKeys.push(key2 + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
|
853
855
|
}
|
|
856
|
+
finalKeys.push(key2 + pluralSuffix);
|
|
854
857
|
if (needsZeroSuffixLookup) {
|
|
855
858
|
finalKeys.push(key2 + zeroSuffix);
|
|
856
859
|
}
|
|
857
860
|
}
|
|
858
861
|
if (needsContextHandling) {
|
|
859
|
-
const contextKey = `${key2}${this.options.contextSeparator}${
|
|
862
|
+
const contextKey = `${key2}${this.options.contextSeparator || "_"}${opt.context}`;
|
|
860
863
|
finalKeys.push(contextKey);
|
|
861
864
|
if (needsPluralHandling) {
|
|
862
|
-
|
|
863
|
-
if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
|
|
865
|
+
if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
|
|
864
866
|
finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
|
865
867
|
}
|
|
868
|
+
finalKeys.push(contextKey + pluralSuffix);
|
|
866
869
|
if (needsZeroSuffixLookup) {
|
|
867
870
|
finalKeys.push(contextKey + zeroSuffix);
|
|
868
871
|
}
|
|
@@ -873,7 +876,7 @@ class Translator extends EventEmitter {
|
|
|
873
876
|
while (possibleKey = finalKeys.pop()) {
|
|
874
877
|
if (!this.isValidLookup(found)) {
|
|
875
878
|
exactUsedKey = possibleKey;
|
|
876
|
-
found = this.getResource(code, ns, possibleKey,
|
|
879
|
+
found = this.getResource(code, ns, possibleKey, opt);
|
|
877
880
|
}
|
|
878
881
|
}
|
|
879
882
|
});
|
|
@@ -890,15 +893,13 @@ class Translator extends EventEmitter {
|
|
|
890
893
|
isValidLookup(res) {
|
|
891
894
|
return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
|
|
892
895
|
}
|
|
893
|
-
getResource(code, ns, key2) {
|
|
896
|
+
getResource(code, ns, key2, options = {}) {
|
|
894
897
|
var _a;
|
|
895
|
-
let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
896
898
|
if ((_a = this.i18nFormat) == null ? void 0 : _a.getResource)
|
|
897
899
|
return this.i18nFormat.getResource(code, ns, key2, options);
|
|
898
900
|
return this.resourceStore.getResource(code, ns, key2, options);
|
|
899
901
|
}
|
|
900
|
-
getUsedParamsDetails() {
|
|
901
|
-
let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
902
|
+
getUsedParamsDetails(options = {}) {
|
|
902
903
|
const optionsKeys = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"];
|
|
903
904
|
const useOptionsReplaceForData = options.replace && !isString$1(options.replace);
|
|
904
905
|
let data = useOptionsReplaceForData ? options.replace : options;
|
|
@@ -996,6 +997,9 @@ class LanguageUtil {
|
|
|
996
997
|
codes.forEach((code) => {
|
|
997
998
|
if (found)
|
|
998
999
|
return;
|
|
1000
|
+
const lngScOnly = this.getScriptPartFromCode(code);
|
|
1001
|
+
if (this.isSupportedCode(lngScOnly))
|
|
1002
|
+
return found = lngScOnly;
|
|
999
1003
|
const lngOnly = this.getLanguagePartFromCode(code);
|
|
1000
1004
|
if (this.isSupportedCode(lngOnly))
|
|
1001
1005
|
return found = lngOnly;
|
|
@@ -1038,7 +1042,7 @@ class LanguageUtil {
|
|
|
1038
1042
|
return found || [];
|
|
1039
1043
|
}
|
|
1040
1044
|
toResolveHierarchy(code, fallbackCode) {
|
|
1041
|
-
const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
|
|
1045
|
+
const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
|
|
1042
1046
|
const codes = [];
|
|
1043
1047
|
const addCode = (c) => {
|
|
1044
1048
|
if (!c)
|
|
@@ -1081,8 +1085,7 @@ const dummyRule = {
|
|
|
1081
1085
|
})
|
|
1082
1086
|
};
|
|
1083
1087
|
class PluralResolver {
|
|
1084
|
-
constructor(languageUtils) {
|
|
1085
|
-
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1088
|
+
constructor(languageUtils, options = {}) {
|
|
1086
1089
|
this.languageUtils = languageUtils;
|
|
1087
1090
|
this.options = options;
|
|
1088
1091
|
this.logger = baseLogger.create("pluralResolver");
|
|
@@ -1094,8 +1097,7 @@ class PluralResolver {
|
|
|
1094
1097
|
clearCache() {
|
|
1095
1098
|
this.pluralRulesCache = {};
|
|
1096
1099
|
}
|
|
1097
|
-
getRule(code) {
|
|
1098
|
-
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1100
|
+
getRule(code, options = {}) {
|
|
1099
1101
|
const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
|
|
1100
1102
|
const type = options.ordinal ? "ordinal" : "cardinal";
|
|
1101
1103
|
const cacheKey = JSON.stringify({
|
|
@@ -1123,19 +1125,16 @@ class PluralResolver {
|
|
|
1123
1125
|
this.pluralRulesCache[cacheKey] = rule;
|
|
1124
1126
|
return rule;
|
|
1125
1127
|
}
|
|
1126
|
-
needsPlural(code) {
|
|
1127
|
-
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1128
|
+
needsPlural(code, options = {}) {
|
|
1128
1129
|
let rule = this.getRule(code, options);
|
|
1129
1130
|
if (!rule)
|
|
1130
1131
|
rule = this.getRule("dev", options);
|
|
1131
1132
|
return (rule == null ? void 0 : rule.resolvedOptions().pluralCategories.length) > 1;
|
|
1132
1133
|
}
|
|
1133
|
-
getPluralFormsOfKey(code, key2) {
|
|
1134
|
-
let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1134
|
+
getPluralFormsOfKey(code, key2, options = {}) {
|
|
1135
1135
|
return this.getSuffixes(code, options).map((suffix) => `${key2}${suffix}`);
|
|
1136
1136
|
}
|
|
1137
|
-
getSuffixes(code) {
|
|
1138
|
-
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1137
|
+
getSuffixes(code, options = {}) {
|
|
1139
1138
|
let rule = this.getRule(code, options);
|
|
1140
1139
|
if (!rule)
|
|
1141
1140
|
rule = this.getRule("dev", options);
|
|
@@ -1143,8 +1142,7 @@ class PluralResolver {
|
|
|
1143
1142
|
return [];
|
|
1144
1143
|
return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
|
|
1145
1144
|
}
|
|
1146
|
-
getSuffix(code, count2) {
|
|
1147
|
-
let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1145
|
+
getSuffix(code, count2, options = {}) {
|
|
1148
1146
|
const rule = this.getRule(code, options);
|
|
1149
1147
|
if (rule) {
|
|
1150
1148
|
return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count2)}`;
|
|
@@ -1153,9 +1151,7 @@ class PluralResolver {
|
|
|
1153
1151
|
return this.getSuffix("dev", count2, options);
|
|
1154
1152
|
}
|
|
1155
1153
|
}
|
|
1156
|
-
const deepFindWithDefaults =
|
|
1157
|
-
let keySeparator = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".";
|
|
1158
|
-
let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : true;
|
|
1154
|
+
const deepFindWithDefaults = (data, defaultData2, key2, keySeparator = ".", ignoreJSONStructure = true) => {
|
|
1159
1155
|
let path = getPathWithDefaults(data, defaultData2, key2);
|
|
1160
1156
|
if (!path && ignoreJSONStructure && isString$1(key2)) {
|
|
1161
1157
|
path = deepFind(data, key2, keySeparator);
|
|
@@ -1166,16 +1162,14 @@ const deepFindWithDefaults = function(data, defaultData2, key2) {
|
|
|
1166
1162
|
};
|
|
1167
1163
|
const regexSafe = (val) => val.replace(/\$/g, "$$$$");
|
|
1168
1164
|
class Interpolator {
|
|
1169
|
-
constructor() {
|
|
1165
|
+
constructor(options = {}) {
|
|
1170
1166
|
var _a;
|
|
1171
|
-
let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1172
1167
|
this.logger = baseLogger.create("interpolator");
|
|
1173
1168
|
this.options = options;
|
|
1174
1169
|
this.format = ((_a = options == null ? void 0 : options.interpolation) == null ? void 0 : _a.format) || ((value) => value);
|
|
1175
1170
|
this.init(options);
|
|
1176
1171
|
}
|
|
1177
|
-
init() {
|
|
1178
|
-
let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1172
|
+
init(options = {}) {
|
|
1179
1173
|
if (!options.interpolation)
|
|
1180
1174
|
options.interpolation = {
|
|
1181
1175
|
escapeValue: true
|
|
@@ -1228,7 +1222,7 @@ class Interpolator {
|
|
|
1228
1222
|
};
|
|
1229
1223
|
this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
|
|
1230
1224
|
this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
|
|
1231
|
-
this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(
|
|
1225
|
+
this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
|
|
1232
1226
|
}
|
|
1233
1227
|
interpolate(str, data, lng, options) {
|
|
1234
1228
|
var _a;
|
|
@@ -1301,8 +1295,7 @@ class Interpolator {
|
|
|
1301
1295
|
});
|
|
1302
1296
|
return str;
|
|
1303
1297
|
}
|
|
1304
|
-
nest(str, fc) {
|
|
1305
|
-
let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1298
|
+
nest(str, fc, options = {}) {
|
|
1306
1299
|
let match2;
|
|
1307
1300
|
let value;
|
|
1308
1301
|
let clonedOptions;
|
|
@@ -1342,12 +1335,10 @@ class Interpolator {
|
|
|
1342
1335
|
clonedOptions = clonedOptions.replace && !isString$1(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
|
|
1343
1336
|
clonedOptions.applyPostProcessor = false;
|
|
1344
1337
|
delete clonedOptions.defaultValue;
|
|
1345
|
-
|
|
1346
|
-
if (
|
|
1347
|
-
|
|
1348
|
-
match2[1] =
|
|
1349
|
-
formatters2 = r;
|
|
1350
|
-
doReduce = true;
|
|
1338
|
+
const keyEndIndex = /{.*}/.test(match2[1]) ? match2[1].lastIndexOf("}") + 1 : match2[1].indexOf(this.formatSeparator);
|
|
1339
|
+
if (keyEndIndex !== -1) {
|
|
1340
|
+
formatters2 = match2[1].slice(keyEndIndex).split(this.formatSeparator).map((elem) => elem.trim()).filter(Boolean);
|
|
1341
|
+
match2[1] = match2[1].slice(0, keyEndIndex);
|
|
1351
1342
|
}
|
|
1352
1343
|
value = fc(handleHasOptions.call(this, match2[1].trim(), clonedOptions), clonedOptions);
|
|
1353
1344
|
if (value && match2[0] === str && !isString$1(value))
|
|
@@ -1358,7 +1349,7 @@ class Interpolator {
|
|
|
1358
1349
|
this.logger.warn(`missed to resolve ${match2[1]} for nesting ${str}`);
|
|
1359
1350
|
value = "";
|
|
1360
1351
|
}
|
|
1361
|
-
if (
|
|
1352
|
+
if (formatters2.length) {
|
|
1362
1353
|
value = formatters2.reduce((v, f) => this.format(v, f, options.lng, {
|
|
1363
1354
|
...options,
|
|
1364
1355
|
interpolationkey: match2[1].trim()
|
|
@@ -1409,68 +1400,68 @@ const parseFormatStr = (formatStr) => {
|
|
|
1409
1400
|
};
|
|
1410
1401
|
const createCachedFormatter = (fn) => {
|
|
1411
1402
|
const cache = {};
|
|
1412
|
-
return (
|
|
1413
|
-
let optForCache =
|
|
1414
|
-
if (
|
|
1403
|
+
return (v, l, o) => {
|
|
1404
|
+
let optForCache = o;
|
|
1405
|
+
if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) {
|
|
1415
1406
|
optForCache = {
|
|
1416
1407
|
...optForCache,
|
|
1417
|
-
[
|
|
1408
|
+
[o.interpolationkey]: void 0
|
|
1418
1409
|
};
|
|
1419
1410
|
}
|
|
1420
|
-
const key2 =
|
|
1421
|
-
let
|
|
1422
|
-
if (!
|
|
1423
|
-
|
|
1424
|
-
cache[key2] =
|
|
1411
|
+
const key2 = l + JSON.stringify(optForCache);
|
|
1412
|
+
let frm = cache[key2];
|
|
1413
|
+
if (!frm) {
|
|
1414
|
+
frm = fn(getCleanedCode(l), o);
|
|
1415
|
+
cache[key2] = frm;
|
|
1425
1416
|
}
|
|
1426
|
-
return
|
|
1417
|
+
return frm(v);
|
|
1427
1418
|
};
|
|
1428
1419
|
};
|
|
1420
|
+
const createNonCachedFormatter = (fn) => (v, l, o) => fn(getCleanedCode(l), o)(v);
|
|
1429
1421
|
class Formatter {
|
|
1430
|
-
constructor() {
|
|
1431
|
-
let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1422
|
+
constructor(options = {}) {
|
|
1432
1423
|
this.logger = baseLogger.create("formatter");
|
|
1433
1424
|
this.options = options;
|
|
1425
|
+
this.init(options);
|
|
1426
|
+
}
|
|
1427
|
+
init(services, options = {
|
|
1428
|
+
interpolation: {}
|
|
1429
|
+
}) {
|
|
1430
|
+
this.formatSeparator = options.interpolation.formatSeparator || ",";
|
|
1431
|
+
const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
|
|
1434
1432
|
this.formats = {
|
|
1435
|
-
number:
|
|
1433
|
+
number: cf((lng, opt) => {
|
|
1436
1434
|
const formatter = new Intl.NumberFormat(lng, {
|
|
1437
1435
|
...opt
|
|
1438
1436
|
});
|
|
1439
1437
|
return (val) => formatter.format(val);
|
|
1440
1438
|
}),
|
|
1441
|
-
currency:
|
|
1439
|
+
currency: cf((lng, opt) => {
|
|
1442
1440
|
const formatter = new Intl.NumberFormat(lng, {
|
|
1443
1441
|
...opt,
|
|
1444
1442
|
style: "currency"
|
|
1445
1443
|
});
|
|
1446
1444
|
return (val) => formatter.format(val);
|
|
1447
1445
|
}),
|
|
1448
|
-
datetime:
|
|
1446
|
+
datetime: cf((lng, opt) => {
|
|
1449
1447
|
const formatter = new Intl.DateTimeFormat(lng, {
|
|
1450
1448
|
...opt
|
|
1451
1449
|
});
|
|
1452
1450
|
return (val) => formatter.format(val);
|
|
1453
1451
|
}),
|
|
1454
|
-
relativetime:
|
|
1452
|
+
relativetime: cf((lng, opt) => {
|
|
1455
1453
|
const formatter = new Intl.RelativeTimeFormat(lng, {
|
|
1456
1454
|
...opt
|
|
1457
1455
|
});
|
|
1458
1456
|
return (val) => formatter.format(val, opt.range || "day");
|
|
1459
1457
|
}),
|
|
1460
|
-
list:
|
|
1458
|
+
list: cf((lng, opt) => {
|
|
1461
1459
|
const formatter = new Intl.ListFormat(lng, {
|
|
1462
1460
|
...opt
|
|
1463
1461
|
});
|
|
1464
1462
|
return (val) => formatter.format(val);
|
|
1465
1463
|
})
|
|
1466
1464
|
};
|
|
1467
|
-
this.init(options);
|
|
1468
|
-
}
|
|
1469
|
-
init(services) {
|
|
1470
|
-
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
1471
|
-
interpolation: {}
|
|
1472
|
-
};
|
|
1473
|
-
this.formatSeparator = options.interpolation.formatSeparator || ",";
|
|
1474
1465
|
}
|
|
1475
1466
|
add(name, fc) {
|
|
1476
1467
|
this.formats[name.toLowerCase().trim()] = fc;
|
|
@@ -1478,8 +1469,7 @@ class Formatter {
|
|
|
1478
1469
|
addCached(name, fc) {
|
|
1479
1470
|
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
1480
1471
|
}
|
|
1481
|
-
format(value, format2, lng) {
|
|
1482
|
-
let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
1472
|
+
format(value, format2, lng, options = {}) {
|
|
1483
1473
|
const formats = format2.split(this.formatSeparator);
|
|
1484
1474
|
if (formats.length > 1 && formats[0].indexOf("(") > 1 && formats[0].indexOf(")") < 0 && formats.find((f) => f.indexOf(")") > -1)) {
|
|
1485
1475
|
const lastIndex = formats.findIndex((f) => f.indexOf(")") > -1);
|
|
@@ -1520,9 +1510,8 @@ const removePending = (q, name) => {
|
|
|
1520
1510
|
}
|
|
1521
1511
|
};
|
|
1522
1512
|
class Connector extends EventEmitter {
|
|
1523
|
-
constructor(backend, store, services) {
|
|
1513
|
+
constructor(backend, store, services, options = {}) {
|
|
1524
1514
|
var _a, _b;
|
|
1525
|
-
let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
1526
1515
|
super();
|
|
1527
1516
|
this.backend = backend;
|
|
1528
1517
|
this.store = store;
|
|
@@ -1628,10 +1617,7 @@ class Connector extends EventEmitter {
|
|
|
1628
1617
|
this.emit("loaded", loaded);
|
|
1629
1618
|
this.queue = this.queue.filter((q) => !q.done);
|
|
1630
1619
|
}
|
|
1631
|
-
read(lng, ns, fcName) {
|
|
1632
|
-
let tried = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
|
|
1633
|
-
let wait = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : this.retryTimeout;
|
|
1634
|
-
let callback = arguments.length > 5 ? arguments[5] : void 0;
|
|
1620
|
+
read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
|
|
1635
1621
|
if (!lng.length)
|
|
1636
1622
|
return callback(null, {});
|
|
1637
1623
|
if (this.readingCalls >= this.maxParallelReads) {
|
|
@@ -1676,9 +1662,7 @@ class Connector extends EventEmitter {
|
|
|
1676
1662
|
}
|
|
1677
1663
|
return fc(lng, ns, resolver);
|
|
1678
1664
|
}
|
|
1679
|
-
prepareLoading(languages, namespaces) {
|
|
1680
|
-
let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1681
|
-
let callback = arguments.length > 3 ? arguments[3] : void 0;
|
|
1665
|
+
prepareLoading(languages, namespaces, options = {}, callback) {
|
|
1682
1666
|
if (!this.backend) {
|
|
1683
1667
|
this.logger.warn("No backend was added via i18next.use. Will not load resources.");
|
|
1684
1668
|
return callback && callback();
|
|
@@ -1705,8 +1689,7 @@ class Connector extends EventEmitter {
|
|
|
1705
1689
|
reload: true
|
|
1706
1690
|
}, callback);
|
|
1707
1691
|
}
|
|
1708
|
-
loadOne(name) {
|
|
1709
|
-
let prefix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
1692
|
+
loadOne(name, prefix = "") {
|
|
1710
1693
|
const s = name.split("|");
|
|
1711
1694
|
const lng = s[0];
|
|
1712
1695
|
const ns = s[1];
|
|
@@ -1718,11 +1701,9 @@ class Connector extends EventEmitter {
|
|
|
1718
1701
|
this.loaded(name, err, data);
|
|
1719
1702
|
});
|
|
1720
1703
|
}
|
|
1721
|
-
saveMissing(languages, namespace, key2, fallbackValue, isUpdate) {
|
|
1704
|
+
saveMissing(languages, namespace, key2, fallbackValue, isUpdate, options = {}, clb = () => {
|
|
1705
|
+
}) {
|
|
1722
1706
|
var _a, _b, _c, _d, _e;
|
|
1723
|
-
let options = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {};
|
|
1724
|
-
let clb = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : () => {
|
|
1725
|
-
};
|
|
1726
1707
|
if (((_b = (_a = this.services) == null ? void 0 : _a.utils) == null ? void 0 : _b.hasLoadedNamespace) && !((_d = (_c = this.services) == null ? void 0 : _c.utils) == null ? void 0 : _d.hasLoadedNamespace(namespace))) {
|
|
1727
1708
|
this.logger.warn(`did not save key "${key2}" 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!!!");
|
|
1728
1709
|
return;
|
|
@@ -1821,7 +1802,8 @@ const get = () => ({
|
|
|
1821
1802
|
nestingOptionsSeparator: ",",
|
|
1822
1803
|
maxReplaces: 1e3,
|
|
1823
1804
|
skipOnVariables: true
|
|
1824
|
-
}
|
|
1805
|
+
},
|
|
1806
|
+
cacheInBuiltFormats: true
|
|
1825
1807
|
});
|
|
1826
1808
|
const transformOptions = (options) => {
|
|
1827
1809
|
var _a, _b;
|
|
@@ -1849,9 +1831,7 @@ const bindMemberFunctions = (inst) => {
|
|
|
1849
1831
|
});
|
|
1850
1832
|
};
|
|
1851
1833
|
class I18n extends EventEmitter {
|
|
1852
|
-
constructor() {
|
|
1853
|
-
let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1854
|
-
let callback = arguments.length > 1 ? arguments[1] : void 0;
|
|
1834
|
+
constructor(options = {}, callback) {
|
|
1855
1835
|
super();
|
|
1856
1836
|
this.options = transformOptions(options);
|
|
1857
1837
|
this.services = {};
|
|
@@ -1870,10 +1850,7 @@ class I18n extends EventEmitter {
|
|
|
1870
1850
|
}, 0);
|
|
1871
1851
|
}
|
|
1872
1852
|
}
|
|
1873
|
-
init() {
|
|
1874
|
-
var _this = this;
|
|
1875
|
-
let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1876
|
-
let callback = arguments.length > 1 ? arguments[1] : void 0;
|
|
1853
|
+
init(options = {}, callback) {
|
|
1877
1854
|
this.isInitializing = true;
|
|
1878
1855
|
if (typeof options === "function") {
|
|
1879
1856
|
callback = options;
|
|
@@ -1931,9 +1908,14 @@ class I18n extends EventEmitter {
|
|
|
1931
1908
|
prepend: this.options.pluralSeparator,
|
|
1932
1909
|
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
1933
1910
|
});
|
|
1911
|
+
const usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
|
|
1912
|
+
if (usingLegacyFormatFunction) {
|
|
1913
|
+
this.logger.deprecate(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
|
|
1914
|
+
}
|
|
1934
1915
|
if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
|
|
1935
1916
|
s.formatter = createClassOnDemand(formatter);
|
|
1936
|
-
s.formatter.init
|
|
1917
|
+
if (s.formatter.init)
|
|
1918
|
+
s.formatter.init(s, this.options);
|
|
1937
1919
|
this.options.interpolation.format = s.formatter.format.bind(s.formatter);
|
|
1938
1920
|
}
|
|
1939
1921
|
s.interpolator = new Interpolator(this.options);
|
|
@@ -1941,11 +1923,8 @@ class I18n extends EventEmitter {
|
|
|
1941
1923
|
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
1942
1924
|
};
|
|
1943
1925
|
s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
|
|
1944
|
-
s.backendConnector.on("*",
|
|
1945
|
-
|
|
1946
|
-
args[_key - 1] = arguments[_key];
|
|
1947
|
-
}
|
|
1948
|
-
_this.emit(event, ...args);
|
|
1926
|
+
s.backendConnector.on("*", (event, ...args) => {
|
|
1927
|
+
this.emit(event, ...args);
|
|
1949
1928
|
});
|
|
1950
1929
|
if (this.modules.languageDetector) {
|
|
1951
1930
|
s.languageDetector = createClassOnDemand(this.modules.languageDetector);
|
|
@@ -1958,11 +1937,8 @@ class I18n extends EventEmitter {
|
|
|
1958
1937
|
s.i18nFormat.init(this);
|
|
1959
1938
|
}
|
|
1960
1939
|
this.translator = new Translator(this.services, this.options);
|
|
1961
|
-
this.translator.on("*",
|
|
1962
|
-
|
|
1963
|
-
args[_key2 - 1] = arguments[_key2];
|
|
1964
|
-
}
|
|
1965
|
-
_this.emit(event, ...args);
|
|
1940
|
+
this.translator.on("*", (event, ...args) => {
|
|
1941
|
+
this.emit(event, ...args);
|
|
1966
1942
|
});
|
|
1967
1943
|
this.modules.external.forEach((m) => {
|
|
1968
1944
|
if (m.init)
|
|
@@ -1982,15 +1958,13 @@ class I18n extends EventEmitter {
|
|
|
1982
1958
|
}
|
|
1983
1959
|
const storeApi = ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"];
|
|
1984
1960
|
storeApi.forEach((fcName) => {
|
|
1985
|
-
this[fcName] =
|
|
1986
|
-
return _this.store[fcName](...arguments);
|
|
1987
|
-
};
|
|
1961
|
+
this[fcName] = (...args) => this.store[fcName](...args);
|
|
1988
1962
|
});
|
|
1989
1963
|
const storeApiChained = ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"];
|
|
1990
1964
|
storeApiChained.forEach((fcName) => {
|
|
1991
|
-
this[fcName] =
|
|
1992
|
-
|
|
1993
|
-
return
|
|
1965
|
+
this[fcName] = (...args) => {
|
|
1966
|
+
this.store[fcName](...args);
|
|
1967
|
+
return this;
|
|
1994
1968
|
};
|
|
1995
1969
|
});
|
|
1996
1970
|
const deferred = defer();
|
|
@@ -2017,9 +1991,8 @@ class I18n extends EventEmitter {
|
|
|
2017
1991
|
}
|
|
2018
1992
|
return deferred;
|
|
2019
1993
|
}
|
|
2020
|
-
loadResources(language) {
|
|
1994
|
+
loadResources(language, callback = noop$1) {
|
|
2021
1995
|
var _a, _b;
|
|
2022
|
-
let callback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop$1;
|
|
2023
1996
|
let usedCallback = callback;
|
|
2024
1997
|
const usedLng = isString$1(language) ? language : this.language;
|
|
2025
1998
|
if (typeof language === "function")
|
|
@@ -2121,9 +2094,12 @@ class I18n extends EventEmitter {
|
|
|
2121
2094
|
break;
|
|
2122
2095
|
}
|
|
2123
2096
|
}
|
|
2097
|
+
if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
|
|
2098
|
+
this.resolvedLanguage = l;
|
|
2099
|
+
this.languages.unshift(l);
|
|
2100
|
+
}
|
|
2124
2101
|
}
|
|
2125
2102
|
changeLanguage(lng, callback) {
|
|
2126
|
-
var _this2 = this;
|
|
2127
2103
|
this.isLanguageChangingTo = lng;
|
|
2128
2104
|
const deferred = defer();
|
|
2129
2105
|
this.emit("languageChanging", lng);
|
|
@@ -2135,27 +2111,26 @@ class I18n extends EventEmitter {
|
|
|
2135
2111
|
};
|
|
2136
2112
|
const done = (err, l) => {
|
|
2137
2113
|
if (l) {
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2114
|
+
if (this.isLanguageChangingTo === lng) {
|
|
2115
|
+
setLngProps(l);
|
|
2116
|
+
this.translator.changeLanguage(l);
|
|
2117
|
+
this.isLanguageChangingTo = void 0;
|
|
2118
|
+
this.emit("languageChanged", l);
|
|
2119
|
+
this.logger.log("languageChanged", l);
|
|
2120
|
+
}
|
|
2143
2121
|
} else {
|
|
2144
2122
|
this.isLanguageChangingTo = void 0;
|
|
2145
2123
|
}
|
|
2146
|
-
deferred.resolve(
|
|
2147
|
-
return _this2.t(...arguments);
|
|
2148
|
-
});
|
|
2124
|
+
deferred.resolve((...args) => this.t(...args));
|
|
2149
2125
|
if (callback)
|
|
2150
|
-
callback(err,
|
|
2151
|
-
return _this2.t(...arguments);
|
|
2152
|
-
});
|
|
2126
|
+
callback(err, (...args) => this.t(...args));
|
|
2153
2127
|
};
|
|
2154
2128
|
const setLng = (lngs) => {
|
|
2155
2129
|
var _a, _b;
|
|
2156
2130
|
if (!lng && !lngs && this.services.languageDetector)
|
|
2157
2131
|
lngs = [];
|
|
2158
|
-
const
|
|
2132
|
+
const fl = isString$1(lngs) ? lngs : lngs && lngs[0];
|
|
2133
|
+
const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString$1(lngs) ? [lngs] : lngs);
|
|
2159
2134
|
if (l) {
|
|
2160
2135
|
if (!this.language) {
|
|
2161
2136
|
setLngProps(l);
|
|
@@ -2182,32 +2157,40 @@ class I18n extends EventEmitter {
|
|
|
2182
2157
|
return deferred;
|
|
2183
2158
|
}
|
|
2184
2159
|
getFixedT(lng, ns, keyPrefix) {
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
let options;
|
|
2160
|
+
const fixedT = (key2, opts, ...rest) => {
|
|
2161
|
+
let o;
|
|
2188
2162
|
if (typeof opts !== "object") {
|
|
2189
|
-
|
|
2190
|
-
rest[_key3 - 2] = arguments[_key3];
|
|
2191
|
-
}
|
|
2192
|
-
options = _this3.options.overloadTranslationOptionHandler([key2, opts].concat(rest));
|
|
2163
|
+
o = this.options.overloadTranslationOptionHandler([key2, opts].concat(rest));
|
|
2193
2164
|
} else {
|
|
2194
|
-
|
|
2165
|
+
o = {
|
|
2195
2166
|
...opts
|
|
2196
2167
|
};
|
|
2197
2168
|
}
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
if (
|
|
2202
|
-
|
|
2203
|
-
const keySeparator =
|
|
2169
|
+
o.lng = o.lng || fixedT.lng;
|
|
2170
|
+
o.lngs = o.lngs || fixedT.lngs;
|
|
2171
|
+
o.ns = o.ns || fixedT.ns;
|
|
2172
|
+
if (o.keyPrefix !== "")
|
|
2173
|
+
o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
|
|
2174
|
+
const keySeparator = this.options.keySeparator || ".";
|
|
2204
2175
|
let resultKey;
|
|
2205
|
-
if (
|
|
2206
|
-
resultKey = key2.map((k) =>
|
|
2176
|
+
if (o.keyPrefix && Array.isArray(key2)) {
|
|
2177
|
+
resultKey = key2.map((k) => {
|
|
2178
|
+
if (typeof k === "function")
|
|
2179
|
+
k = keysFromSelector(k, {
|
|
2180
|
+
...this.options,
|
|
2181
|
+
...opts
|
|
2182
|
+
});
|
|
2183
|
+
return `${o.keyPrefix}${keySeparator}${k}`;
|
|
2184
|
+
});
|
|
2207
2185
|
} else {
|
|
2208
|
-
|
|
2186
|
+
if (typeof key2 === "function")
|
|
2187
|
+
key2 = keysFromSelector(key2, {
|
|
2188
|
+
...this.options,
|
|
2189
|
+
...opts
|
|
2190
|
+
});
|
|
2191
|
+
resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key2}` : key2;
|
|
2209
2192
|
}
|
|
2210
|
-
return
|
|
2193
|
+
return this.t(resultKey, o);
|
|
2211
2194
|
};
|
|
2212
2195
|
if (isString$1(lng)) {
|
|
2213
2196
|
fixedT.lng = lng;
|
|
@@ -2218,25 +2201,18 @@ class I18n extends EventEmitter {
|
|
|
2218
2201
|
fixedT.keyPrefix = keyPrefix;
|
|
2219
2202
|
return fixedT;
|
|
2220
2203
|
}
|
|
2221
|
-
t() {
|
|
2204
|
+
t(...args) {
|
|
2222
2205
|
var _a;
|
|
2223
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
2224
|
-
args[_key4] = arguments[_key4];
|
|
2225
|
-
}
|
|
2226
2206
|
return (_a = this.translator) == null ? void 0 : _a.translate(...args);
|
|
2227
2207
|
}
|
|
2228
|
-
exists() {
|
|
2208
|
+
exists(...args) {
|
|
2229
2209
|
var _a;
|
|
2230
|
-
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
2231
|
-
args[_key5] = arguments[_key5];
|
|
2232
|
-
}
|
|
2233
2210
|
return (_a = this.translator) == null ? void 0 : _a.exists(...args);
|
|
2234
2211
|
}
|
|
2235
2212
|
setDefaultNamespace(ns) {
|
|
2236
2213
|
this.options.defaultNS = ns;
|
|
2237
2214
|
}
|
|
2238
|
-
hasLoadedNamespace(ns) {
|
|
2239
|
-
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
2215
|
+
hasLoadedNamespace(ns, options = {}) {
|
|
2240
2216
|
if (!this.isInitialized) {
|
|
2241
2217
|
this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
|
|
2242
2218
|
return false;
|
|
@@ -2312,18 +2288,25 @@ class I18n extends EventEmitter {
|
|
|
2312
2288
|
lng = this.resolvedLanguage || (((_a = this.languages) == null ? void 0 : _a.length) > 0 ? this.languages[0] : this.language);
|
|
2313
2289
|
if (!lng)
|
|
2314
2290
|
return "rtl";
|
|
2291
|
+
try {
|
|
2292
|
+
const l = new Intl.Locale(lng);
|
|
2293
|
+
if (l && l.getTextInfo) {
|
|
2294
|
+
const ti = l.getTextInfo();
|
|
2295
|
+
if (ti && ti.direction)
|
|
2296
|
+
return ti.direction;
|
|
2297
|
+
}
|
|
2298
|
+
} catch (e) {
|
|
2299
|
+
}
|
|
2315
2300
|
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"];
|
|
2316
2301
|
const languageUtils = ((_b = this.services) == null ? void 0 : _b.languageUtils) || new LanguageUtil(get());
|
|
2302
|
+
if (lng.toLowerCase().indexOf("-latn") > 1)
|
|
2303
|
+
return "ltr";
|
|
2317
2304
|
return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
|
|
2318
2305
|
}
|
|
2319
|
-
static createInstance() {
|
|
2320
|
-
let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2321
|
-
let callback = arguments.length > 1 ? arguments[1] : void 0;
|
|
2306
|
+
static createInstance(options = {}, callback) {
|
|
2322
2307
|
return new I18n(options, callback);
|
|
2323
2308
|
}
|
|
2324
|
-
cloneInstance() {
|
|
2325
|
-
let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2326
|
-
let callback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop$1;
|
|
2309
|
+
cloneInstance(options = {}, callback = noop$1) {
|
|
2327
2310
|
const forkResourceStore = options.forkResourceStore;
|
|
2328
2311
|
if (forkResourceStore)
|
|
2329
2312
|
delete options.forkResourceStore;
|
|
@@ -2353,21 +2336,19 @@ class I18n extends EventEmitter {
|
|
|
2353
2336
|
prev[l] = {
|
|
2354
2337
|
...this.store.data[l]
|
|
2355
2338
|
};
|
|
2356
|
-
|
|
2339
|
+
prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
|
|
2357
2340
|
acc[n] = {
|
|
2358
2341
|
...prev[l][n]
|
|
2359
2342
|
};
|
|
2360
2343
|
return acc;
|
|
2361
|
-
},
|
|
2344
|
+
}, prev[l]);
|
|
2345
|
+
return prev;
|
|
2362
2346
|
}, {});
|
|
2363
2347
|
clone.store = new ResourceStore(clonedData, mergedOptions);
|
|
2364
2348
|
clone.services.resourceStore = clone.store;
|
|
2365
2349
|
}
|
|
2366
2350
|
clone.translator = new Translator(clone.services, mergedOptions);
|
|
2367
|
-
clone.translator.on("*",
|
|
2368
|
-
for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
|
|
2369
|
-
args[_key6 - 1] = arguments[_key6];
|
|
2370
|
-
}
|
|
2351
|
+
clone.translator.on("*", (event, ...args) => {
|
|
2371
2352
|
clone.emit(event, ...args);
|
|
2372
2353
|
});
|
|
2373
2354
|
clone.init(mergedOptions, callback);
|
|
@@ -10656,14 +10637,14 @@ const TaskListTableDefaultInner = ({
|
|
|
10656
10637
|
);
|
|
10657
10638
|
};
|
|
10658
10639
|
const TaskListTable = memo(TaskListTableDefaultInner);
|
|
10659
|
-
const taskListRoot = "
|
|
10660
|
-
const taskListHorizontalScroll = "
|
|
10661
|
-
const taskListResizer = "
|
|
10662
|
-
const horizontalContainer$1 = "
|
|
10663
|
-
const tableWrapper = "
|
|
10664
|
-
const scrollToTop = "
|
|
10665
|
-
const scrollToBottom = "
|
|
10666
|
-
const hidden = "
|
|
10640
|
+
const taskListRoot = "_taskListRoot_1x5nq_1";
|
|
10641
|
+
const taskListHorizontalScroll = "_taskListHorizontalScroll_1x5nq_25";
|
|
10642
|
+
const taskListResizer = "_taskListResizer_1x5nq_89";
|
|
10643
|
+
const horizontalContainer$1 = "_horizontalContainer_1x5nq_153";
|
|
10644
|
+
const tableWrapper = "_tableWrapper_1x5nq_171";
|
|
10645
|
+
const scrollToTop = "_scrollToTop_1x5nq_183";
|
|
10646
|
+
const scrollToBottom = "_scrollToBottom_1x5nq_199";
|
|
10647
|
+
const hidden = "_hidden_1x5nq_215";
|
|
10667
10648
|
const styles$d = {
|
|
10668
10649
|
taskListRoot,
|
|
10669
10650
|
taskListHorizontalScroll,
|
|
@@ -13146,12 +13127,12 @@ const TaskGanttContentInner = (props) => {
|
|
|
13146
13127
|
] });
|
|
13147
13128
|
};
|
|
13148
13129
|
const TaskGanttContent = memo(TaskGanttContentInner);
|
|
13149
|
-
const ganttVerticalContainer = "
|
|
13150
|
-
const horizontalContainer = "
|
|
13151
|
-
const ganttHeader = "
|
|
13152
|
-
const ganttBodyScroll = "
|
|
13153
|
-
const wrapper = "
|
|
13154
|
-
const calendarDragging = "
|
|
13130
|
+
const ganttVerticalContainer = "_ganttVerticalContainer_1xboz_1";
|
|
13131
|
+
const horizontalContainer = "_horizontalContainer_1xboz_81";
|
|
13132
|
+
const ganttHeader = "_ganttHeader_1xboz_97";
|
|
13133
|
+
const ganttBodyScroll = "_ganttBodyScroll_1xboz_107";
|
|
13134
|
+
const wrapper = "_wrapper_1xboz_123";
|
|
13135
|
+
const calendarDragging = "_calendarDragging_1xboz_153";
|
|
13155
13136
|
const styles$2 = {
|
|
13156
13137
|
ganttVerticalContainer,
|
|
13157
13138
|
horizontalContainer,
|
|
@@ -18769,8 +18750,8 @@ const Gantt = (props) => {
|
|
|
18769
18750
|
[renderedColumnIndexes]
|
|
18770
18751
|
);
|
|
18771
18752
|
const svgWidth = useMemo(
|
|
18772
|
-
() =>
|
|
18773
|
-
[datesLength, distances
|
|
18753
|
+
() => datesLength * distances.columnWidth,
|
|
18754
|
+
[datesLength, distances]
|
|
18774
18755
|
);
|
|
18775
18756
|
const countTaskCoordinates$1 = useCallback(
|
|
18776
18757
|
(task) => countTaskCoordinates(
|