@spscommerce/i18n 3.12.3 → 3.15.4
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/lib/SpsLanguage.d.ts +2 -4
- package/lib/index.cjs.js +249 -444
- package/lib/index.d.ts +3 -3
- package/lib/index.esm.js +249 -444
- package/lib/localize.d.ts +1 -1
- package/lib/useSpsLanguage.d.ts +1 -1
- package/locales/en-US/design-system.json +1 -0
- package/package.json +2 -2
- package/rollup.config.js +24 -0
package/lib/SpsLanguage.d.ts
CHANGED
package/lib/index.cjs.js
CHANGED
|
@@ -77,23 +77,23 @@ function __rest(s, e) {
|
|
|
77
77
|
return t;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
function _typeof$
|
|
80
|
+
function _typeof$2(obj) {
|
|
81
81
|
"@babel/helpers - typeof";
|
|
82
82
|
|
|
83
83
|
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
84
|
-
_typeof$
|
|
84
|
+
_typeof$2 = function _typeof(obj) {
|
|
85
85
|
return typeof obj;
|
|
86
86
|
};
|
|
87
87
|
} else {
|
|
88
|
-
_typeof$
|
|
88
|
+
_typeof$2 = function _typeof(obj) {
|
|
89
89
|
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
return _typeof$
|
|
93
|
+
return _typeof$2(obj);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
function _defineProperty$
|
|
96
|
+
function _defineProperty$1(obj, key, value) {
|
|
97
97
|
if (key in obj) {
|
|
98
98
|
Object.defineProperty(obj, key, {
|
|
99
99
|
value: value,
|
|
@@ -120,20 +120,20 @@ function _objectSpread$3(target) {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
ownKeys.forEach(function (key) {
|
|
123
|
-
_defineProperty$
|
|
123
|
+
_defineProperty$1(target, key, source[key]);
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
return target;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
function _classCallCheck$
|
|
130
|
+
function _classCallCheck$1(instance, Constructor) {
|
|
131
131
|
if (!(instance instanceof Constructor)) {
|
|
132
132
|
throw new TypeError("Cannot call a class as a function");
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
function _defineProperties$
|
|
136
|
+
function _defineProperties$1(target, props) {
|
|
137
137
|
for (var i = 0; i < props.length; i++) {
|
|
138
138
|
var descriptor = props[i];
|
|
139
139
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -143,9 +143,9 @@ function _defineProperties$3(target, props) {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
function _createClass$
|
|
147
|
-
if (protoProps) _defineProperties$
|
|
148
|
-
if (staticProps) _defineProperties$
|
|
146
|
+
function _createClass$1(Constructor, protoProps, staticProps) {
|
|
147
|
+
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
148
|
+
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
149
149
|
return Constructor;
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -158,7 +158,7 @@ function _assertThisInitialized(self) {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
function _possibleConstructorReturn(self, call) {
|
|
161
|
-
if (call && (_typeof$
|
|
161
|
+
if (call && (_typeof$2(call) === "object" || typeof call === "function")) {
|
|
162
162
|
return call;
|
|
163
163
|
}
|
|
164
164
|
|
|
@@ -216,12 +216,12 @@ var Logger = function () {
|
|
|
216
216
|
function Logger(concreteLogger) {
|
|
217
217
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
218
218
|
|
|
219
|
-
_classCallCheck$
|
|
219
|
+
_classCallCheck$1(this, Logger);
|
|
220
220
|
|
|
221
221
|
this.init(concreteLogger, options);
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
_createClass$
|
|
224
|
+
_createClass$1(Logger, [{
|
|
225
225
|
key: "init",
|
|
226
226
|
value: function init(concreteLogger) {
|
|
227
227
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -294,12 +294,12 @@ var baseLogger = new Logger();
|
|
|
294
294
|
|
|
295
295
|
var EventEmitter = function () {
|
|
296
296
|
function EventEmitter() {
|
|
297
|
-
_classCallCheck$
|
|
297
|
+
_classCallCheck$1(this, EventEmitter);
|
|
298
298
|
|
|
299
299
|
this.observers = {};
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
_createClass$
|
|
302
|
+
_createClass$1(EventEmitter, [{
|
|
303
303
|
key: "on",
|
|
304
304
|
value: function on(events, listener) {
|
|
305
305
|
var _this = this;
|
|
@@ -388,7 +388,12 @@ function getLastOfPath(object, path, Empty) {
|
|
|
388
388
|
if (canNotTraverseDeeper()) return {};
|
|
389
389
|
var key = cleanKey(stack.shift());
|
|
390
390
|
if (!object[key] && Empty) object[key] = new Empty();
|
|
391
|
-
|
|
391
|
+
|
|
392
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
393
|
+
object = object[key];
|
|
394
|
+
} else {
|
|
395
|
+
object = {};
|
|
396
|
+
}
|
|
392
397
|
}
|
|
393
398
|
|
|
394
399
|
if (canNotTraverseDeeper()) return {};
|
|
@@ -481,7 +486,7 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
481
486
|
defaultNS: 'translation'
|
|
482
487
|
};
|
|
483
488
|
|
|
484
|
-
_classCallCheck$
|
|
489
|
+
_classCallCheck$1(this, ResourceStore);
|
|
485
490
|
|
|
486
491
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(ResourceStore).call(this));
|
|
487
492
|
|
|
@@ -499,7 +504,7 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
499
504
|
return _this;
|
|
500
505
|
}
|
|
501
506
|
|
|
502
|
-
_createClass$
|
|
507
|
+
_createClass$1(ResourceStore, [{
|
|
503
508
|
key: "addNamespaces",
|
|
504
509
|
value: function addNamespaces(ns) {
|
|
505
510
|
if (this.options.ns.indexOf(ns) < 0) {
|
|
@@ -655,7 +660,7 @@ var Translator = function (_EventEmitter) {
|
|
|
655
660
|
|
|
656
661
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
657
662
|
|
|
658
|
-
_classCallCheck$
|
|
663
|
+
_classCallCheck$1(this, Translator);
|
|
659
664
|
|
|
660
665
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(Translator).call(this));
|
|
661
666
|
|
|
@@ -674,7 +679,7 @@ var Translator = function (_EventEmitter) {
|
|
|
674
679
|
return _this;
|
|
675
680
|
}
|
|
676
681
|
|
|
677
|
-
_createClass$
|
|
682
|
+
_createClass$1(Translator, [{
|
|
678
683
|
key: "changeLanguage",
|
|
679
684
|
value: function changeLanguage(lng) {
|
|
680
685
|
if (lng) this.language = lng;
|
|
@@ -722,7 +727,7 @@ var Translator = function (_EventEmitter) {
|
|
|
722
727
|
value: function translate(keys, options, lastKey) {
|
|
723
728
|
var _this2 = this;
|
|
724
729
|
|
|
725
|
-
if (_typeof$
|
|
730
|
+
if (_typeof$2(options) !== 'object' && this.options.overloadTranslationOptionHandler) {
|
|
726
731
|
options = this.options.overloadTranslationOptionHandler(arguments);
|
|
727
732
|
}
|
|
728
733
|
|
|
@@ -766,21 +771,21 @@ var Translator = function (_EventEmitter) {
|
|
|
766
771
|
|
|
767
772
|
if (keySeparator) {
|
|
768
773
|
var resTypeIsArray = resType === '[object Array]';
|
|
769
|
-
var copy
|
|
774
|
+
var copy = resTypeIsArray ? [] : {};
|
|
770
775
|
var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
|
|
771
776
|
|
|
772
777
|
for (var m in res) {
|
|
773
778
|
if (Object.prototype.hasOwnProperty.call(res, m)) {
|
|
774
779
|
var deepKey = "".concat(newKeyToUse).concat(keySeparator).concat(m);
|
|
775
|
-
copy
|
|
780
|
+
copy[m] = this.translate(deepKey, _objectSpread$3({}, options, {
|
|
776
781
|
joinArrays: false,
|
|
777
782
|
ns: namespaces
|
|
778
783
|
}));
|
|
779
|
-
if (copy
|
|
784
|
+
if (copy[m] === deepKey) copy[m] = res[m];
|
|
780
785
|
}
|
|
781
786
|
}
|
|
782
787
|
|
|
783
|
-
res = copy
|
|
788
|
+
res = copy;
|
|
784
789
|
}
|
|
785
790
|
} else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
|
|
786
791
|
res = res.join(joinArrays);
|
|
@@ -788,16 +793,14 @@ var Translator = function (_EventEmitter) {
|
|
|
788
793
|
} else {
|
|
789
794
|
var usedDefault = false;
|
|
790
795
|
var usedKey = false;
|
|
796
|
+
var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
|
|
797
|
+
var hasDefaultValue = Translator.hasDefaultValue(options);
|
|
798
|
+
var defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count) : '';
|
|
799
|
+
var defaultValue = options["defaultValue".concat(defaultValueSuffix)] || options.defaultValue;
|
|
791
800
|
|
|
792
|
-
if (!this.isValidLookup(res) &&
|
|
801
|
+
if (!this.isValidLookup(res) && hasDefaultValue) {
|
|
793
802
|
usedDefault = true;
|
|
794
|
-
|
|
795
|
-
if (options.count !== undefined) {
|
|
796
|
-
var suffix = this.pluralResolver.getSuffix(lng, options.count);
|
|
797
|
-
res = options["defaultValue".concat(suffix)];
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
if (!res) res = options.defaultValue;
|
|
803
|
+
res = defaultValue;
|
|
801
804
|
}
|
|
802
805
|
|
|
803
806
|
if (!this.isValidLookup(res)) {
|
|
@@ -805,10 +808,10 @@ var Translator = function (_EventEmitter) {
|
|
|
805
808
|
res = key;
|
|
806
809
|
}
|
|
807
810
|
|
|
808
|
-
var updateMissing =
|
|
811
|
+
var updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
|
|
809
812
|
|
|
810
813
|
if (usedKey || usedDefault || updateMissing) {
|
|
811
|
-
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ?
|
|
814
|
+
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
|
|
812
815
|
|
|
813
816
|
if (keySeparator) {
|
|
814
817
|
var fk = this.resolve(key, _objectSpread$3({}, options, {
|
|
@@ -830,29 +833,25 @@ var Translator = function (_EventEmitter) {
|
|
|
830
833
|
lngs.push(options.lng || this.language);
|
|
831
834
|
}
|
|
832
835
|
|
|
833
|
-
var send = function send(l, k) {
|
|
836
|
+
var send = function send(l, k, fallbackValue) {
|
|
834
837
|
if (_this2.options.missingKeyHandler) {
|
|
835
|
-
_this2.options.missingKeyHandler(l, namespace, k, updateMissing ?
|
|
838
|
+
_this2.options.missingKeyHandler(l, namespace, k, updateMissing ? fallbackValue : res, updateMissing, options);
|
|
836
839
|
} else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {
|
|
837
|
-
_this2.backendConnector.saveMissing(l, namespace, k, updateMissing ?
|
|
840
|
+
_this2.backendConnector.saveMissing(l, namespace, k, updateMissing ? fallbackValue : res, updateMissing, options);
|
|
838
841
|
}
|
|
839
842
|
|
|
840
843
|
_this2.emit('missingKey', l, namespace, k, res);
|
|
841
844
|
};
|
|
842
845
|
|
|
843
846
|
if (this.options.saveMissing) {
|
|
844
|
-
var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
|
|
845
|
-
|
|
846
847
|
if (this.options.saveMissingPlurals && needsPluralHandling) {
|
|
847
|
-
lngs.forEach(function (
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
plurals.forEach(function (p) {
|
|
851
|
-
return send([l], p);
|
|
848
|
+
lngs.forEach(function (language) {
|
|
849
|
+
_this2.pluralResolver.getSuffixes(language).forEach(function (suffix) {
|
|
850
|
+
send([language], key + suffix, options["defaultValue".concat(suffix)] || defaultValue);
|
|
852
851
|
});
|
|
853
852
|
});
|
|
854
853
|
} else {
|
|
855
|
-
send(lngs, key);
|
|
854
|
+
send(lngs, key, defaultValue);
|
|
856
855
|
}
|
|
857
856
|
}
|
|
858
857
|
}
|
|
@@ -1003,6 +1002,19 @@ var Translator = function (_EventEmitter) {
|
|
|
1003
1002
|
if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
|
|
1004
1003
|
return this.resourceStore.getResource(code, ns, key, options);
|
|
1005
1004
|
}
|
|
1005
|
+
}], [{
|
|
1006
|
+
key: "hasDefaultValue",
|
|
1007
|
+
value: function hasDefaultValue(options) {
|
|
1008
|
+
var prefix = 'defaultValue';
|
|
1009
|
+
|
|
1010
|
+
for (var option in options) {
|
|
1011
|
+
if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
|
|
1012
|
+
return true;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
return false;
|
|
1017
|
+
}
|
|
1006
1018
|
}]);
|
|
1007
1019
|
|
|
1008
1020
|
return Translator;
|
|
@@ -1014,7 +1026,7 @@ function capitalize(string) {
|
|
|
1014
1026
|
|
|
1015
1027
|
var LanguageUtil = function () {
|
|
1016
1028
|
function LanguageUtil(options) {
|
|
1017
|
-
_classCallCheck$
|
|
1029
|
+
_classCallCheck$1(this, LanguageUtil);
|
|
1018
1030
|
|
|
1019
1031
|
this.options = options;
|
|
1020
1032
|
this.whitelist = this.options.supportedLngs || false;
|
|
@@ -1022,7 +1034,7 @@ var LanguageUtil = function () {
|
|
|
1022
1034
|
this.logger = baseLogger.create('languageUtils');
|
|
1023
1035
|
}
|
|
1024
1036
|
|
|
1025
|
-
_createClass$
|
|
1037
|
+
_createClass$1(LanguageUtil, [{
|
|
1026
1038
|
key: "getScriptPartFromCode",
|
|
1027
1039
|
value: function getScriptPartFromCode(code) {
|
|
1028
1040
|
if (!code || code.indexOf('-') < 0) return null;
|
|
@@ -1165,7 +1177,7 @@ var LanguageUtil = function () {
|
|
|
1165
1177
|
}();
|
|
1166
1178
|
|
|
1167
1179
|
var sets = [{
|
|
1168
|
-
lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'ti', 'tr', 'uz', 'wa'],
|
|
1180
|
+
lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
|
|
1169
1181
|
nr: [1, 2],
|
|
1170
1182
|
fc: 1
|
|
1171
1183
|
}, {
|
|
@@ -1343,7 +1355,7 @@ var PluralResolver = function () {
|
|
|
1343
1355
|
function PluralResolver(languageUtils) {
|
|
1344
1356
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1345
1357
|
|
|
1346
|
-
_classCallCheck$
|
|
1358
|
+
_classCallCheck$1(this, PluralResolver);
|
|
1347
1359
|
|
|
1348
1360
|
this.languageUtils = languageUtils;
|
|
1349
1361
|
this.options = options;
|
|
@@ -1351,7 +1363,7 @@ var PluralResolver = function () {
|
|
|
1351
1363
|
this.rules = createRules();
|
|
1352
1364
|
}
|
|
1353
1365
|
|
|
1354
|
-
_createClass$
|
|
1366
|
+
_createClass$1(PluralResolver, [{
|
|
1355
1367
|
key: "addRule",
|
|
1356
1368
|
value: function addRule(lng, obj) {
|
|
1357
1369
|
this.rules[lng] = obj;
|
|
@@ -1370,17 +1382,24 @@ var PluralResolver = function () {
|
|
|
1370
1382
|
}, {
|
|
1371
1383
|
key: "getPluralFormsOfKey",
|
|
1372
1384
|
value: function getPluralFormsOfKey(code, key) {
|
|
1385
|
+
return this.getSuffixes(code).map(function (suffix) {
|
|
1386
|
+
return key + suffix;
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
}, {
|
|
1390
|
+
key: "getSuffixes",
|
|
1391
|
+
value: function getSuffixes(code) {
|
|
1373
1392
|
var _this = this;
|
|
1374
1393
|
|
|
1375
|
-
var ret = [];
|
|
1376
1394
|
var rule = this.getRule(code);
|
|
1377
|
-
if (!rule) return ret;
|
|
1378
|
-
rule.numbers.forEach(function (n) {
|
|
1379
|
-
var suffix = _this.getSuffix(code, n);
|
|
1380
1395
|
|
|
1381
|
-
|
|
1396
|
+
if (!rule) {
|
|
1397
|
+
return [];
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
return rule.numbers.map(function (number) {
|
|
1401
|
+
return _this.getSuffix(code, number);
|
|
1382
1402
|
});
|
|
1383
|
-
return ret;
|
|
1384
1403
|
}
|
|
1385
1404
|
}, {
|
|
1386
1405
|
key: "getSuffix",
|
|
@@ -1430,7 +1449,7 @@ var Interpolator = function () {
|
|
|
1430
1449
|
function Interpolator() {
|
|
1431
1450
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1432
1451
|
|
|
1433
|
-
_classCallCheck$
|
|
1452
|
+
_classCallCheck$1(this, Interpolator);
|
|
1434
1453
|
|
|
1435
1454
|
this.logger = baseLogger.create('interpolator');
|
|
1436
1455
|
this.options = options;
|
|
@@ -1442,7 +1461,7 @@ var Interpolator = function () {
|
|
|
1442
1461
|
this.init(options);
|
|
1443
1462
|
}
|
|
1444
1463
|
|
|
1445
|
-
_createClass$
|
|
1464
|
+
_createClass$1(Interpolator, [{
|
|
1446
1465
|
key: "init",
|
|
1447
1466
|
value: function init() {
|
|
1448
1467
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -1644,7 +1663,7 @@ var Connector = function (_EventEmitter) {
|
|
|
1644
1663
|
|
|
1645
1664
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1646
1665
|
|
|
1647
|
-
_classCallCheck$
|
|
1666
|
+
_classCallCheck$1(this, Connector);
|
|
1648
1667
|
|
|
1649
1668
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(Connector).call(this));
|
|
1650
1669
|
|
|
@@ -1668,7 +1687,7 @@ var Connector = function (_EventEmitter) {
|
|
|
1668
1687
|
return _this;
|
|
1669
1688
|
}
|
|
1670
1689
|
|
|
1671
|
-
_createClass$
|
|
1690
|
+
_createClass$1(Connector, [{
|
|
1672
1691
|
key: "queueLoad",
|
|
1673
1692
|
value: function queueLoad(languages, namespaces, options, callback) {
|
|
1674
1693
|
var _this2 = this;
|
|
@@ -1894,11 +1913,11 @@ function get() {
|
|
|
1894
1913
|
appendNamespaceToCIMode: false,
|
|
1895
1914
|
overloadTranslationOptionHandler: function handle(args) {
|
|
1896
1915
|
var ret = {};
|
|
1897
|
-
if (_typeof$
|
|
1916
|
+
if (_typeof$2(args[1]) === 'object') ret = args[1];
|
|
1898
1917
|
if (typeof args[1] === 'string') ret.defaultValue = args[1];
|
|
1899
1918
|
if (typeof args[2] === 'string') ret.tDescription = args[2];
|
|
1900
1919
|
|
|
1901
|
-
if (_typeof$
|
|
1920
|
+
if (_typeof$2(args[2]) === 'object' || _typeof$2(args[3]) === 'object') {
|
|
1902
1921
|
var options = args[3] || args[2];
|
|
1903
1922
|
Object.keys(options).forEach(function (key) {
|
|
1904
1923
|
ret[key] = options[key];
|
|
@@ -1959,7 +1978,7 @@ var I18n = function (_EventEmitter) {
|
|
|
1959
1978
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1960
1979
|
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
1961
1980
|
|
|
1962
|
-
_classCallCheck$
|
|
1981
|
+
_classCallCheck$1(this, I18n);
|
|
1963
1982
|
|
|
1964
1983
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(I18n).call(this));
|
|
1965
1984
|
|
|
@@ -1989,7 +2008,7 @@ var I18n = function (_EventEmitter) {
|
|
|
1989
2008
|
return _this;
|
|
1990
2009
|
}
|
|
1991
2010
|
|
|
1992
|
-
_createClass$
|
|
2011
|
+
_createClass$1(I18n, [{
|
|
1993
2012
|
key: "init",
|
|
1994
2013
|
value: function init() {
|
|
1995
2014
|
var _this2 = this;
|
|
@@ -2074,6 +2093,11 @@ var I18n = function (_EventEmitter) {
|
|
|
2074
2093
|
});
|
|
2075
2094
|
}
|
|
2076
2095
|
|
|
2096
|
+
if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
2097
|
+
var codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
2098
|
+
if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2077
2101
|
if (!this.services.languageDetector && !this.options.lng) {
|
|
2078
2102
|
this.logger.warn('init: no languageDetector is used and no lng is defined');
|
|
2079
2103
|
}
|
|
@@ -2099,7 +2123,8 @@ var I18n = function (_EventEmitter) {
|
|
|
2099
2123
|
var deferred = defer();
|
|
2100
2124
|
|
|
2101
2125
|
var load = function load() {
|
|
2102
|
-
|
|
2126
|
+
var finish = function finish(err, t) {
|
|
2127
|
+
if (_this2.isInitialized) _this2.logger.warn('init: i18next is already initialized. You should call init just once!');
|
|
2103
2128
|
_this2.isInitialized = true;
|
|
2104
2129
|
if (!_this2.options.isClone) _this2.logger.log('initialized', _this2.options);
|
|
2105
2130
|
|
|
@@ -2107,7 +2132,11 @@ var I18n = function (_EventEmitter) {
|
|
|
2107
2132
|
|
|
2108
2133
|
deferred.resolve(t);
|
|
2109
2134
|
callback(err, t);
|
|
2110
|
-
}
|
|
2135
|
+
};
|
|
2136
|
+
|
|
2137
|
+
if (_this2.languages && _this2.options.compatibilityAPI !== 'v1' && !_this2.isInitialized) return finish(null, _this2.t.bind(_this2));
|
|
2138
|
+
|
|
2139
|
+
_this2.changeLanguage(_this2.options.lng, finish);
|
|
2111
2140
|
};
|
|
2112
2141
|
|
|
2113
2142
|
if (this.options.resources || !this.options.initImmediate) {
|
|
@@ -2276,7 +2305,7 @@ var I18n = function (_EventEmitter) {
|
|
|
2276
2305
|
var fixedT = function fixedT(key, opts) {
|
|
2277
2306
|
var options;
|
|
2278
2307
|
|
|
2279
|
-
if (_typeof$
|
|
2308
|
+
if (_typeof$2(opts) !== 'object') {
|
|
2280
2309
|
for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
2281
2310
|
rest[_key3 - 2] = arguments[_key3];
|
|
2282
2311
|
}
|
|
@@ -2460,27 +2489,6 @@ var I18n = function (_EventEmitter) {
|
|
|
2460
2489
|
|
|
2461
2490
|
var i18next = new I18n();
|
|
2462
2491
|
|
|
2463
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2464
|
-
|
|
2465
|
-
function getAugmentedNamespace(n) {
|
|
2466
|
-
if (n.__esModule) return n;
|
|
2467
|
-
var a = Object.defineProperty({}, '__esModule', {value: true});
|
|
2468
|
-
Object.keys(n).forEach(function (k) {
|
|
2469
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
2470
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
2471
|
-
enumerable: true,
|
|
2472
|
-
get: function () {
|
|
2473
|
-
return n[k];
|
|
2474
|
-
}
|
|
2475
|
-
});
|
|
2476
|
-
});
|
|
2477
|
-
return a;
|
|
2478
|
-
}
|
|
2479
|
-
|
|
2480
|
-
function commonjsRequire (path) {
|
|
2481
|
-
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
2482
|
-
}
|
|
2483
|
-
|
|
2484
2492
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
2485
2493
|
if (source == null) return {};
|
|
2486
2494
|
var target = {};
|
|
@@ -2496,13 +2504,9 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
2496
2504
|
return target;
|
|
2497
2505
|
}
|
|
2498
2506
|
|
|
2499
|
-
var objectWithoutPropertiesLoose$1 = _objectWithoutPropertiesLoose;
|
|
2500
|
-
|
|
2501
|
-
var objectWithoutPropertiesLoose = objectWithoutPropertiesLoose$1;
|
|
2502
|
-
|
|
2503
2507
|
function _objectWithoutProperties(source, excluded) {
|
|
2504
2508
|
if (source == null) return {};
|
|
2505
|
-
var target =
|
|
2509
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
2506
2510
|
var key, i;
|
|
2507
2511
|
|
|
2508
2512
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -2519,51 +2523,33 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
2519
2523
|
return target;
|
|
2520
2524
|
}
|
|
2521
2525
|
|
|
2522
|
-
var
|
|
2523
|
-
|
|
2524
|
-
function _typeof$1(obj) {
|
|
2525
|
-
"@babel/helpers - typeof";
|
|
2526
|
-
|
|
2527
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
2528
|
-
_typeof_1 = _typeof$1 = function _typeof(obj) {
|
|
2529
|
-
return typeof obj;
|
|
2530
|
-
};
|
|
2531
|
-
} else {
|
|
2532
|
-
_typeof_1 = _typeof$1 = function _typeof(obj) {
|
|
2533
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
2534
|
-
};
|
|
2535
|
-
}
|
|
2526
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2536
2527
|
|
|
2537
|
-
|
|
2528
|
+
function getAugmentedNamespace(n) {
|
|
2529
|
+
if (n.__esModule) return n;
|
|
2530
|
+
var a = Object.defineProperty({}, '__esModule', {value: true});
|
|
2531
|
+
Object.keys(n).forEach(function (k) {
|
|
2532
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
2533
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
2534
|
+
enumerable: true,
|
|
2535
|
+
get: function () {
|
|
2536
|
+
return n[k];
|
|
2537
|
+
}
|
|
2538
|
+
});
|
|
2539
|
+
});
|
|
2540
|
+
return a;
|
|
2538
2541
|
}
|
|
2539
2542
|
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
var _typeof$2 = _typeof_1;
|
|
2543
|
-
|
|
2544
|
-
function _defineProperty$1(obj, key, value) {
|
|
2545
|
-
if (key in obj) {
|
|
2546
|
-
Object.defineProperty(obj, key, {
|
|
2547
|
-
value: value,
|
|
2548
|
-
enumerable: true,
|
|
2549
|
-
configurable: true,
|
|
2550
|
-
writable: true
|
|
2551
|
-
});
|
|
2552
|
-
} else {
|
|
2553
|
-
obj[key] = value;
|
|
2554
|
-
}
|
|
2555
|
-
|
|
2556
|
-
return obj;
|
|
2543
|
+
function commonjsRequire (path) {
|
|
2544
|
+
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
2557
2545
|
}
|
|
2558
2546
|
|
|
2559
|
-
var defineProperty = _defineProperty$1;
|
|
2560
|
-
|
|
2561
2547
|
/**
|
|
2562
2548
|
* This file automatically generated from `pre-publish.js`.
|
|
2563
2549
|
* Do not manually edit.
|
|
2564
2550
|
*/
|
|
2565
2551
|
|
|
2566
|
-
var voidElements
|
|
2552
|
+
var voidElements = {
|
|
2567
2553
|
"area": true,
|
|
2568
2554
|
"base": true,
|
|
2569
2555
|
"br": true,
|
|
@@ -2572,9 +2558,7 @@ var voidElements$1 = {
|
|
|
2572
2558
|
"hr": true,
|
|
2573
2559
|
"img": true,
|
|
2574
2560
|
"input": true,
|
|
2575
|
-
"keygen": true,
|
|
2576
2561
|
"link": true,
|
|
2577
|
-
"menuitem": true,
|
|
2578
2562
|
"meta": true,
|
|
2579
2563
|
"param": true,
|
|
2580
2564
|
"source": true,
|
|
@@ -2582,225 +2566,17 @@ var voidElements$1 = {
|
|
|
2582
2566
|
"wbr": true
|
|
2583
2567
|
};
|
|
2584
2568
|
|
|
2585
|
-
var
|
|
2586
|
-
var voidElements = voidElements$1;
|
|
2587
|
-
|
|
2588
|
-
var parseTag$1 = function (tag) {
|
|
2589
|
-
var i = 0;
|
|
2590
|
-
var key;
|
|
2591
|
-
var expectingValueAfterEquals = true;
|
|
2592
|
-
var res = {
|
|
2593
|
-
type: 'tag',
|
|
2594
|
-
name: '',
|
|
2595
|
-
voidElement: false,
|
|
2596
|
-
attrs: {},
|
|
2597
|
-
children: []
|
|
2598
|
-
};
|
|
2599
|
-
|
|
2600
|
-
tag.replace(attrRE, function (match) {
|
|
2601
|
-
if (match === '=') {
|
|
2602
|
-
expectingValueAfterEquals = true;
|
|
2603
|
-
i++;
|
|
2604
|
-
return;
|
|
2605
|
-
}
|
|
2606
|
-
|
|
2607
|
-
if (!expectingValueAfterEquals) {
|
|
2608
|
-
if (key) {
|
|
2609
|
-
res.attrs[key] = key; // boolean attribute
|
|
2610
|
-
}
|
|
2611
|
-
key=match;
|
|
2612
|
-
} else {
|
|
2613
|
-
if (i === 0) {
|
|
2614
|
-
if (voidElements[match] || tag.charAt(tag.length - 2) === '/') {
|
|
2615
|
-
res.voidElement = true;
|
|
2616
|
-
}
|
|
2617
|
-
res.name = match;
|
|
2618
|
-
} else {
|
|
2619
|
-
res.attrs[key] = match.replace(/^['"]|['"]$/g, '');
|
|
2620
|
-
key=undefined;
|
|
2621
|
-
}
|
|
2622
|
-
}
|
|
2623
|
-
i++;
|
|
2624
|
-
expectingValueAfterEquals = false;
|
|
2625
|
-
});
|
|
2626
|
-
|
|
2627
|
-
return res;
|
|
2628
|
-
};
|
|
2629
|
-
|
|
2630
|
-
/*jshint -W030 */
|
|
2631
|
-
|
|
2632
|
-
var tagRE = /(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g;
|
|
2633
|
-
var parseTag = parseTag$1;
|
|
2634
|
-
// re-used obj for quick lookups of components
|
|
2635
|
-
var empty = Object.create ? Object.create(null) : {};
|
|
2636
|
-
// common logic for pushing a child node onto a list
|
|
2637
|
-
function pushTextNode(list, html, level, start, ignoreWhitespace) {
|
|
2638
|
-
// calculate correct end of the content slice in case there's
|
|
2639
|
-
// no tag after the text node.
|
|
2640
|
-
var end = html.indexOf('<', start);
|
|
2641
|
-
var content = html.slice(start, end === -1 ? undefined : end);
|
|
2642
|
-
// if a node is nothing but whitespace, collapse it as the spec states:
|
|
2643
|
-
// https://www.w3.org/TR/html4/struct/text.html#h-9.1
|
|
2644
|
-
if (/^\s*$/.test(content)) {
|
|
2645
|
-
content = ' ';
|
|
2646
|
-
}
|
|
2647
|
-
// don't add whitespace-only text nodes if they would be trailing text nodes
|
|
2648
|
-
// or if they would be leading whitespace-only text nodes:
|
|
2649
|
-
// * end > -1 indicates this is not a trailing text node
|
|
2650
|
-
// * leading node is when level is -1 and list has length 0
|
|
2651
|
-
if ((!ignoreWhitespace && end > -1 && level + list.length >= 0) || content !== ' ') {
|
|
2652
|
-
list.push({
|
|
2653
|
-
type: 'text',
|
|
2654
|
-
content: content
|
|
2655
|
-
});
|
|
2656
|
-
}
|
|
2657
|
-
}
|
|
2658
|
-
|
|
2659
|
-
var parse = function parse(html, options) {
|
|
2660
|
-
options || (options = {});
|
|
2661
|
-
options.components || (options.components = empty);
|
|
2662
|
-
var result = [];
|
|
2663
|
-
var current;
|
|
2664
|
-
var level = -1;
|
|
2665
|
-
var arr = [];
|
|
2666
|
-
var byTag = {};
|
|
2667
|
-
var inComponent = false;
|
|
2668
|
-
|
|
2669
|
-
html.replace(tagRE, function (tag, index) {
|
|
2670
|
-
if (inComponent) {
|
|
2671
|
-
if (tag !== ('</' + current.name + '>')) {
|
|
2672
|
-
return;
|
|
2673
|
-
} else {
|
|
2674
|
-
inComponent = false;
|
|
2675
|
-
}
|
|
2676
|
-
}
|
|
2677
|
-
|
|
2678
|
-
var isOpen = tag.charAt(1) !== '/';
|
|
2679
|
-
var isComment = tag.indexOf('<!--') === 0;
|
|
2680
|
-
var start = index + tag.length;
|
|
2681
|
-
var nextChar = html.charAt(start);
|
|
2682
|
-
var parent;
|
|
2683
|
-
|
|
2684
|
-
if (isOpen && !isComment) {
|
|
2685
|
-
level++;
|
|
2686
|
-
|
|
2687
|
-
current = parseTag(tag);
|
|
2688
|
-
if (current.type === 'tag' && options.components[current.name]) {
|
|
2689
|
-
current.type = 'component';
|
|
2690
|
-
inComponent = true;
|
|
2691
|
-
}
|
|
2692
|
-
|
|
2693
|
-
if (!current.voidElement && !inComponent && nextChar && nextChar !== '<') {
|
|
2694
|
-
pushTextNode(current.children, html, level, start, options.ignoreWhitespace);
|
|
2695
|
-
}
|
|
2696
|
-
|
|
2697
|
-
byTag[current.tagName] = current;
|
|
2698
|
-
|
|
2699
|
-
// if we're at root, push new base node
|
|
2700
|
-
if (level === 0) {
|
|
2701
|
-
result.push(current);
|
|
2702
|
-
}
|
|
2703
|
-
|
|
2704
|
-
parent = arr[level - 1];
|
|
2705
|
-
|
|
2706
|
-
if (parent) {
|
|
2707
|
-
parent.children.push(current);
|
|
2708
|
-
}
|
|
2709
|
-
|
|
2710
|
-
arr[level] = current;
|
|
2711
|
-
}
|
|
2712
|
-
|
|
2713
|
-
if (isComment || !isOpen || current.voidElement) {
|
|
2714
|
-
if (!isComment) {
|
|
2715
|
-
level--;
|
|
2716
|
-
}
|
|
2717
|
-
if (!inComponent && nextChar !== '<' && nextChar) {
|
|
2718
|
-
// trailing text node
|
|
2719
|
-
// if we're at the root, push a base text node. otherwise add as
|
|
2720
|
-
// a child to the current node.
|
|
2721
|
-
parent = level === -1 ? result : arr[level].children;
|
|
2722
|
-
pushTextNode(parent, html, level, start, options.ignoreWhitespace);
|
|
2723
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
});
|
|
2726
|
-
|
|
2727
|
-
// If the "html" passed isn't actually html, add it as a text node.
|
|
2728
|
-
if (!result.length && html.length) {
|
|
2729
|
-
pushTextNode(result, html, 0, 0, options.ignoreWhitespace);
|
|
2730
|
-
}
|
|
2731
|
-
|
|
2732
|
-
return result;
|
|
2733
|
-
};
|
|
2734
|
-
|
|
2735
|
-
function attrString(attrs) {
|
|
2736
|
-
var buff = [];
|
|
2737
|
-
for (var key in attrs) {
|
|
2738
|
-
buff.push(key + '="' + attrs[key] + '"');
|
|
2739
|
-
}
|
|
2740
|
-
if (!buff.length) {
|
|
2741
|
-
return '';
|
|
2742
|
-
}
|
|
2743
|
-
return ' ' + buff.join(' ');
|
|
2744
|
-
}
|
|
2745
|
-
|
|
2746
|
-
function stringify(buff, doc) {
|
|
2747
|
-
switch (doc.type) {
|
|
2748
|
-
case 'text':
|
|
2749
|
-
return buff + doc.content;
|
|
2750
|
-
case 'tag':
|
|
2751
|
-
buff += '<' + doc.name + (doc.attrs ? attrString(doc.attrs) : '') + (doc.voidElement ? '/>' : '>');
|
|
2752
|
-
if (doc.voidElement) {
|
|
2753
|
-
return buff;
|
|
2754
|
-
}
|
|
2755
|
-
return buff + doc.children.reduce(stringify, '') + '</' + doc.name + '>';
|
|
2756
|
-
}
|
|
2757
|
-
}
|
|
2758
|
-
|
|
2759
|
-
var stringify_1 = function (doc) {
|
|
2760
|
-
return doc.reduce(function (token, rootEl) {
|
|
2761
|
-
return token + stringify('', rootEl);
|
|
2762
|
-
}, '');
|
|
2763
|
-
};
|
|
2764
|
-
|
|
2765
|
-
var htmlParseStringify2 = {
|
|
2766
|
-
parse: parse,
|
|
2767
|
-
stringify: stringify_1
|
|
2768
|
-
};
|
|
2769
|
-
|
|
2770
|
-
function _classCallCheck$2(instance, Constructor) {
|
|
2771
|
-
if (!(instance instanceof Constructor)) {
|
|
2772
|
-
throw new TypeError("Cannot call a class as a function");
|
|
2773
|
-
}
|
|
2774
|
-
}
|
|
2775
|
-
|
|
2776
|
-
var classCallCheck = _classCallCheck$2;
|
|
2777
|
-
|
|
2778
|
-
function _defineProperties$2(target, props) {
|
|
2779
|
-
for (var i = 0; i < props.length; i++) {
|
|
2780
|
-
var descriptor = props[i];
|
|
2781
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
2782
|
-
descriptor.configurable = true;
|
|
2783
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
2784
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
2785
|
-
}
|
|
2786
|
-
}
|
|
2787
|
-
|
|
2788
|
-
function _createClass$2(Constructor, protoProps, staticProps) {
|
|
2789
|
-
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
2790
|
-
if (staticProps) _defineProperties$2(Constructor, staticProps);
|
|
2791
|
-
return Constructor;
|
|
2792
|
-
}
|
|
2793
|
-
|
|
2794
|
-
var createClass = _createClass$2;
|
|
2569
|
+
var t=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function n(n){var r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},i=n.match(/<\/?([^\s]+?)[/\s>]/);if(i&&(r.name=i[1],(voidElements[i[1]]||"/"===n.charAt(n.length-2))&&(r.voidElement=!0),r.name.startsWith("!--"))){var s=n.indexOf("--\x3e");return {type:"comment",comment:-1!==s?n.slice(4,s):""}}for(var a=new RegExp(t),c=null;null!==(c=a.exec(n));)if(c[0].trim())if(c[1]){var o=c[1].trim(),l=[o,""];o.indexOf("=")>-1&&(l=o.split("=")),r.attrs[l[0]]=l[1],a.lastIndex--;}else c[2]&&(r.attrs[c[2]]=c[3].trim().substring(1,c[3].length-1));return r}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,i=/^\s*$/,s=Object.create(null);function a(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(a,"")+"</"+t.name+">";case"comment":return e+"\x3c!--"+t.comment+"--\x3e"}}var c={parse:function(e,t){t||(t={}),t.components||(t.components=s);var a,c=[],o=[],l=-1,m=!1;if(0!==e.indexOf("<")){var u=e.indexOf("<");c.push({type:"text",content:-1===u?e:e.substring(0,u)});}return e.replace(r,function(r,s){if(m){if(r!=="</"+a.name+">")return;m=!1;}var u,f="/"!==r.charAt(1),h=r.startsWith("\x3c!--"),p=s+r.length,d=e.charAt(p);if(h){var v=n(r);return l<0?(c.push(v),c):((u=o[l]).children.push(v),c)}if(f&&(l++,"tag"===(a=n(r)).type&&t.components[a.name]&&(a.type="component",m=!0),a.voidElement||m||!d||"<"===d||a.children.push({type:"text",content:e.slice(p,e.indexOf("<",p))}),0===l&&c.push(a),(u=o[l-1])&&u.children.push(a),o[l]=a),(!f||a.voidElement)&&(l>-1&&(a.voidElement||a.name===r.slice(2,-1))&&(l--,a=-1===l?c:o[l]),!m&&"<"!==d&&d)){u=-1===l?c:o[l].children;var x=e.indexOf("<",p),g=e.slice(p,-1===x?void 0:x);i.test(g)&&(g=" "),(x>-1&&l+u.length>=0||" "!==g)&&u.push({type:"text",content:g});}}),c},stringify:function(e){return e.reduce(function(e,t){return e+a("",t)},"")}};
|
|
2795
2570
|
|
|
2796
|
-
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
2571
|
+
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2797
2572
|
|
|
2798
|
-
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) {
|
|
2573
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2799
2574
|
var defaultOptions = {
|
|
2800
2575
|
bindI18n: 'languageChanged',
|
|
2801
2576
|
bindI18nStore: '',
|
|
2802
2577
|
transEmptyNodeValue: '',
|
|
2803
2578
|
transSupportBasicHtmlNodes: true,
|
|
2579
|
+
transWrapTextNodes: '',
|
|
2804
2580
|
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
|
|
2805
2581
|
useSuspense: true
|
|
2806
2582
|
};
|
|
@@ -2815,12 +2591,12 @@ function getDefaults$2() {
|
|
|
2815
2591
|
}
|
|
2816
2592
|
var ReportNamespaces = function () {
|
|
2817
2593
|
function ReportNamespaces() {
|
|
2818
|
-
|
|
2594
|
+
_classCallCheck$1(this, ReportNamespaces);
|
|
2819
2595
|
|
|
2820
2596
|
this.usedNamespaces = {};
|
|
2821
2597
|
}
|
|
2822
2598
|
|
|
2823
|
-
|
|
2599
|
+
_createClass$1(ReportNamespaces, [{
|
|
2824
2600
|
key: "addUsedNamespaces",
|
|
2825
2601
|
value: function addUsedNamespaces(namespaces) {
|
|
2826
2602
|
var _this = this;
|
|
@@ -2916,9 +2692,12 @@ function hasLoadedNamespace(ns, i18n) {
|
|
|
2916
2692
|
return false;
|
|
2917
2693
|
}
|
|
2918
2694
|
|
|
2919
|
-
|
|
2695
|
+
var _excluded = ["format"],
|
|
2696
|
+
_excluded2 = ["children", "count", "parent", "i18nKey", "tOptions", "values", "defaults", "components", "ns", "i18n", "t"];
|
|
2920
2697
|
|
|
2921
|
-
function
|
|
2698
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2699
|
+
|
|
2700
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2922
2701
|
|
|
2923
2702
|
function hasChildren(node, checkLength) {
|
|
2924
2703
|
if (!node) return false;
|
|
@@ -2975,9 +2754,11 @@ function nodesToString(children, i18nOptions) {
|
|
|
2975
2754
|
var content = nodesToString(childChildren, i18nOptions);
|
|
2976
2755
|
stringNode += "<".concat(childIndex, ">").concat(content, "</").concat(childIndex, ">");
|
|
2977
2756
|
}
|
|
2757
|
+
} else if (child === null) {
|
|
2758
|
+
warn("Trans: the passed in value is invalid - seems you passed in a null child.");
|
|
2978
2759
|
} else if (_typeof$2(child) === 'object') {
|
|
2979
2760
|
var format = child.format,
|
|
2980
|
-
clone =
|
|
2761
|
+
clone = _objectWithoutProperties(child, _excluded);
|
|
2981
2762
|
|
|
2982
2763
|
var keys = Object.keys(clone);
|
|
2983
2764
|
|
|
@@ -3011,7 +2792,7 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts) {
|
|
|
3011
2792
|
|
|
3012
2793
|
getData(children);
|
|
3013
2794
|
var interpolatedString = i18n.services.interpolator.interpolate(targetString, _objectSpread$1(_objectSpread$1({}, data), combinedTOpts), i18n.language);
|
|
3014
|
-
var ast =
|
|
2795
|
+
var ast = c.parse("<0>".concat(interpolatedString, "</0>"));
|
|
3015
2796
|
|
|
3016
2797
|
function renderInner(child, node, rootReactNode) {
|
|
3017
2798
|
var childs = getChildren(child);
|
|
@@ -3092,7 +2873,15 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts) {
|
|
|
3092
2873
|
})));
|
|
3093
2874
|
}
|
|
3094
2875
|
} else if (node.type === 'text') {
|
|
3095
|
-
|
|
2876
|
+
var wrapTextNodes = i18nOptions.transWrapTextNodes;
|
|
2877
|
+
|
|
2878
|
+
if (wrapTextNodes) {
|
|
2879
|
+
mem.push(React__default['default'].createElement(wrapTextNodes, {
|
|
2880
|
+
key: "".concat(node.name, "-").concat(i)
|
|
2881
|
+
}, node.content));
|
|
2882
|
+
} else {
|
|
2883
|
+
mem.push(node.content);
|
|
2884
|
+
}
|
|
3096
2885
|
}
|
|
3097
2886
|
|
|
3098
2887
|
return mem;
|
|
@@ -3119,7 +2908,7 @@ function Trans(_ref) {
|
|
|
3119
2908
|
ns = _ref.ns,
|
|
3120
2909
|
i18nFromProps = _ref.i18n,
|
|
3121
2910
|
tFromProps = _ref.t,
|
|
3122
|
-
additionalProps =
|
|
2911
|
+
additionalProps = _objectWithoutProperties(_ref, _excluded2);
|
|
3123
2912
|
|
|
3124
2913
|
var _ref2 = React.useContext(I18nContext) || {},
|
|
3125
2914
|
i18nFromContext = _ref2.i18n,
|
|
@@ -3167,17 +2956,18 @@ function _arrayWithHoles(arr) {
|
|
|
3167
2956
|
if (Array.isArray(arr)) return arr;
|
|
3168
2957
|
}
|
|
3169
2958
|
|
|
3170
|
-
var arrayWithHoles$1 = _arrayWithHoles;
|
|
3171
|
-
|
|
3172
2959
|
function _iterableToArrayLimit(arr, i) {
|
|
3173
|
-
|
|
2960
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
2961
|
+
|
|
2962
|
+
if (_i == null) return;
|
|
3174
2963
|
var _arr = [];
|
|
3175
2964
|
var _n = true;
|
|
3176
2965
|
var _d = false;
|
|
3177
|
-
|
|
2966
|
+
|
|
2967
|
+
var _s, _e;
|
|
3178
2968
|
|
|
3179
2969
|
try {
|
|
3180
|
-
for (
|
|
2970
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
3181
2971
|
_arr.push(_s.value);
|
|
3182
2972
|
|
|
3183
2973
|
if (i && _arr.length === i) break;
|
|
@@ -3196,8 +2986,6 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
3196
2986
|
return _arr;
|
|
3197
2987
|
}
|
|
3198
2988
|
|
|
3199
|
-
var iterableToArrayLimit$1 = _iterableToArrayLimit;
|
|
3200
|
-
|
|
3201
2989
|
function _arrayLikeToArray(arr, len) {
|
|
3202
2990
|
if (len == null || len > arr.length) len = arr.length;
|
|
3203
2991
|
|
|
@@ -3208,44 +2996,26 @@ function _arrayLikeToArray(arr, len) {
|
|
|
3208
2996
|
return arr2;
|
|
3209
2997
|
}
|
|
3210
2998
|
|
|
3211
|
-
var arrayLikeToArray$1 = _arrayLikeToArray;
|
|
3212
|
-
|
|
3213
|
-
var arrayLikeToArray = arrayLikeToArray$1;
|
|
3214
|
-
|
|
3215
2999
|
function _unsupportedIterableToArray(o, minLen) {
|
|
3216
3000
|
if (!o) return;
|
|
3217
|
-
if (typeof o === "string") return
|
|
3001
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
3218
3002
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
3219
3003
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
3220
3004
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
3221
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return
|
|
3005
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
3222
3006
|
}
|
|
3223
3007
|
|
|
3224
|
-
var unsupportedIterableToArray$1 = _unsupportedIterableToArray;
|
|
3225
|
-
|
|
3226
3008
|
function _nonIterableRest() {
|
|
3227
3009
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3228
3010
|
}
|
|
3229
3011
|
|
|
3230
|
-
var nonIterableRest$1 = _nonIterableRest;
|
|
3231
|
-
|
|
3232
|
-
var arrayWithHoles = arrayWithHoles$1;
|
|
3233
|
-
|
|
3234
|
-
var iterableToArrayLimit = iterableToArrayLimit$1;
|
|
3235
|
-
|
|
3236
|
-
var unsupportedIterableToArray = unsupportedIterableToArray$1;
|
|
3237
|
-
|
|
3238
|
-
var nonIterableRest = nonIterableRest$1;
|
|
3239
|
-
|
|
3240
3012
|
function _slicedToArray(arr, i) {
|
|
3241
|
-
return
|
|
3013
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
3242
3014
|
}
|
|
3243
3015
|
|
|
3244
|
-
var
|
|
3016
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
3245
3017
|
|
|
3246
|
-
function
|
|
3247
|
-
|
|
3248
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
3018
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
3249
3019
|
function useTranslation(ns) {
|
|
3250
3020
|
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3251
3021
|
var i18nFromProps = props.i18n;
|
|
@@ -3271,6 +3041,8 @@ function useTranslation(ns) {
|
|
|
3271
3041
|
return retNotReady;
|
|
3272
3042
|
}
|
|
3273
3043
|
|
|
3044
|
+
if (i18n.options.react && i18n.options.react.wait !== undefined) warnOnce('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
|
|
3045
|
+
|
|
3274
3046
|
var i18nOptions = _objectSpread(_objectSpread(_objectSpread({}, getDefaults$2()), i18n.options.react), props);
|
|
3275
3047
|
|
|
3276
3048
|
var useSuspense = i18nOptions.useSuspense;
|
|
@@ -3282,13 +3054,11 @@ function useTranslation(ns) {
|
|
|
3282
3054
|
});
|
|
3283
3055
|
|
|
3284
3056
|
function getT() {
|
|
3285
|
-
return
|
|
3286
|
-
t: i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0])
|
|
3287
|
-
};
|
|
3057
|
+
return i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0]);
|
|
3288
3058
|
}
|
|
3289
3059
|
|
|
3290
|
-
var _useState = React.useState(getT
|
|
3291
|
-
_useState2 =
|
|
3060
|
+
var _useState = React.useState(getT),
|
|
3061
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3292
3062
|
t = _useState2[0],
|
|
3293
3063
|
setT = _useState2[1];
|
|
3294
3064
|
|
|
@@ -3300,12 +3070,12 @@ function useTranslation(ns) {
|
|
|
3300
3070
|
|
|
3301
3071
|
if (!ready && !useSuspense) {
|
|
3302
3072
|
loadNamespaces(i18n, namespaces, function () {
|
|
3303
|
-
if (isMounted.current) setT(getT
|
|
3073
|
+
if (isMounted.current) setT(getT);
|
|
3304
3074
|
});
|
|
3305
3075
|
}
|
|
3306
3076
|
|
|
3307
3077
|
function boundReset() {
|
|
3308
|
-
if (isMounted.current) setT(getT
|
|
3078
|
+
if (isMounted.current) setT(getT);
|
|
3309
3079
|
}
|
|
3310
3080
|
|
|
3311
3081
|
if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
|
|
@@ -3319,9 +3089,17 @@ function useTranslation(ns) {
|
|
|
3319
3089
|
return i18n.store.off(e, boundReset);
|
|
3320
3090
|
});
|
|
3321
3091
|
};
|
|
3322
|
-
}, [namespaces.join()]);
|
|
3323
|
-
var
|
|
3324
|
-
|
|
3092
|
+
}, [i18n, namespaces.join()]);
|
|
3093
|
+
var isInitial = React.useRef(true);
|
|
3094
|
+
React.useEffect(function () {
|
|
3095
|
+
if (isMounted.current && !isInitial.current) {
|
|
3096
|
+
setT(getT);
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3099
|
+
isInitial.current = false;
|
|
3100
|
+
}, [i18n]);
|
|
3101
|
+
var ret = [t, i18n, ready];
|
|
3102
|
+
ret.t = t;
|
|
3325
3103
|
ret.i18n = i18n;
|
|
3326
3104
|
ret.ready = ready;
|
|
3327
3105
|
if (ready) return ret;
|
|
@@ -3333,6 +3111,8 @@ function useTranslation(ns) {
|
|
|
3333
3111
|
});
|
|
3334
3112
|
}
|
|
3335
3113
|
|
|
3114
|
+
function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
|
|
3115
|
+
|
|
3336
3116
|
var arr$1 = [];
|
|
3337
3117
|
var each$1 = arr$1.forEach;
|
|
3338
3118
|
var slice$1 = arr$1.slice;
|
|
@@ -3346,9 +3126,14 @@ function defaults$1(obj) {
|
|
|
3346
3126
|
});
|
|
3347
3127
|
return obj;
|
|
3348
3128
|
}
|
|
3129
|
+
function hasXMLHttpRequest() {
|
|
3130
|
+
return typeof XMLHttpRequest === 'function' || (typeof XMLHttpRequest === "undefined" ? "undefined" : _typeof$1(XMLHttpRequest)) === 'object';
|
|
3131
|
+
}
|
|
3349
3132
|
|
|
3350
3133
|
var getFetch$1 = {exports: {}};
|
|
3351
3134
|
|
|
3135
|
+
var nodePonyfill = {exports: {}};
|
|
3136
|
+
|
|
3352
3137
|
// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js
|
|
3353
3138
|
|
|
3354
3139
|
// fix for "Readable" isn't a named export issue
|
|
@@ -4990,6 +4775,31 @@ var lib = /*#__PURE__*/Object.freeze({
|
|
|
4990
4775
|
|
|
4991
4776
|
var require$$0 = /*@__PURE__*/getAugmentedNamespace(lib);
|
|
4992
4777
|
|
|
4778
|
+
(function (module, exports) {
|
|
4779
|
+
const nodeFetch = require$$0;
|
|
4780
|
+
const realFetch = nodeFetch.default || nodeFetch;
|
|
4781
|
+
|
|
4782
|
+
const fetch = function (url, options) {
|
|
4783
|
+
// Support schemaless URIs on the server for parity with the browser.
|
|
4784
|
+
// Ex: //github.com/ -> https://github.com/
|
|
4785
|
+
if (/^\/\//.test(url)) {
|
|
4786
|
+
url = 'https:' + url;
|
|
4787
|
+
}
|
|
4788
|
+
return realFetch.call(this, url, options)
|
|
4789
|
+
};
|
|
4790
|
+
|
|
4791
|
+
fetch.ponyfill = true;
|
|
4792
|
+
|
|
4793
|
+
module.exports = exports = fetch;
|
|
4794
|
+
exports.fetch = fetch;
|
|
4795
|
+
exports.Headers = nodeFetch.Headers;
|
|
4796
|
+
exports.Request = nodeFetch.Request;
|
|
4797
|
+
exports.Response = nodeFetch.Response;
|
|
4798
|
+
|
|
4799
|
+
// Needed for TypeScript consumers without esModuleInterop.
|
|
4800
|
+
exports.default = fetch;
|
|
4801
|
+
}(nodePonyfill, nodePonyfill.exports));
|
|
4802
|
+
|
|
4993
4803
|
(function (module, exports) {
|
|
4994
4804
|
var fetchApi;
|
|
4995
4805
|
if (typeof fetch === 'function') {
|
|
@@ -5001,7 +4811,7 @@ if (typeof fetch === 'function') {
|
|
|
5001
4811
|
}
|
|
5002
4812
|
|
|
5003
4813
|
if (typeof commonjsRequire !== 'undefined' && (typeof window === 'undefined' || typeof window.document === 'undefined')) {
|
|
5004
|
-
var f = fetchApi ||
|
|
4814
|
+
var f = fetchApi || nodePonyfill.exports;
|
|
5005
4815
|
if (f.default) f = f.default;
|
|
5006
4816
|
exports.default = f;
|
|
5007
4817
|
module.exports = exports.default;
|
|
@@ -5027,7 +4837,7 @@ if (typeof fetch === 'function') {
|
|
|
5027
4837
|
|
|
5028
4838
|
var XmlHttpRequestApi;
|
|
5029
4839
|
|
|
5030
|
-
if (
|
|
4840
|
+
if (hasXMLHttpRequest) {
|
|
5031
4841
|
if (typeof global !== 'undefined' && global.XMLHttpRequest) {
|
|
5032
4842
|
XmlHttpRequestApi = global.XMLHttpRequest;
|
|
5033
4843
|
} else if (typeof window !== 'undefined' && window.XMLHttpRequest) {
|
|
@@ -5155,16 +4965,16 @@ var request = function request(options, url, payload, callback) {
|
|
|
5155
4965
|
return requestWithFetch(options, url, payload, callback);
|
|
5156
4966
|
}
|
|
5157
4967
|
|
|
5158
|
-
if (
|
|
4968
|
+
if (hasXMLHttpRequest || typeof ActiveXObject === 'function') {
|
|
5159
4969
|
return requestWithXmlHttpRequest(options, url, payload, callback);
|
|
5160
4970
|
}
|
|
5161
4971
|
};
|
|
5162
4972
|
|
|
5163
|
-
function _classCallCheck
|
|
4973
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5164
4974
|
|
|
5165
|
-
function _defineProperties
|
|
4975
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
5166
4976
|
|
|
5167
|
-
function _createClass
|
|
4977
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
5168
4978
|
|
|
5169
4979
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5170
4980
|
|
|
@@ -5200,7 +5010,7 @@ var Backend = function () {
|
|
|
5200
5010
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5201
5011
|
var allOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
5202
5012
|
|
|
5203
|
-
_classCallCheck
|
|
5013
|
+
_classCallCheck(this, Backend);
|
|
5204
5014
|
|
|
5205
5015
|
this.services = services;
|
|
5206
5016
|
this.options = options;
|
|
@@ -5209,7 +5019,7 @@ var Backend = function () {
|
|
|
5209
5019
|
this.init(services, options, allOptions);
|
|
5210
5020
|
}
|
|
5211
5021
|
|
|
5212
|
-
_createClass
|
|
5022
|
+
_createClass(Backend, [{
|
|
5213
5023
|
key: "init",
|
|
5214
5024
|
value: function init(services) {
|
|
5215
5025
|
var _this = this;
|
|
@@ -5220,7 +5030,7 @@ var Backend = function () {
|
|
|
5220
5030
|
this.options = defaults$1(options, this.options || {}, getDefaults$1());
|
|
5221
5031
|
this.allOptions = allOptions;
|
|
5222
5032
|
|
|
5223
|
-
if (this.options.reloadInterval) {
|
|
5033
|
+
if (this.services && this.options.reloadInterval) {
|
|
5224
5034
|
setInterval(function () {
|
|
5225
5035
|
return _this.reload();
|
|
5226
5036
|
}, this.options.reloadInterval);
|
|
@@ -5262,9 +5072,9 @@ var Backend = function () {
|
|
|
5262
5072
|
var _this2 = this;
|
|
5263
5073
|
|
|
5264
5074
|
this.options.request(this.options, url, undefined, function (err, res) {
|
|
5265
|
-
if (res && (res.status >= 500 && res.status < 600 || !res.status)) return callback('failed loading ' + url, true);
|
|
5266
|
-
if (res && res.status >= 400 && res.status < 500) return callback('failed loading ' + url, false);
|
|
5267
|
-
if (!res && err && err.message && err.message.indexOf('Failed to fetch') > -1) return callback('failed loading ' + url, true);
|
|
5075
|
+
if (res && (res.status >= 500 && res.status < 600 || !res.status)) return callback('failed loading ' + url + '; status code: ' + res.status, true);
|
|
5076
|
+
if (res && res.status >= 400 && res.status < 500) return callback('failed loading ' + url + '; status code: ' + res.status, false);
|
|
5077
|
+
if (!res && err && err.message && err.message.indexOf('Failed to fetch') > -1) return callback('failed loading ' + url + ': ' + err.message, true);
|
|
5268
5078
|
if (err) return callback(err, false);
|
|
5269
5079
|
var ret, parseErr;
|
|
5270
5080
|
|
|
@@ -5284,19 +5094,36 @@ var Backend = function () {
|
|
|
5284
5094
|
}
|
|
5285
5095
|
}, {
|
|
5286
5096
|
key: "create",
|
|
5287
|
-
value: function create(languages, namespace, key, fallbackValue) {
|
|
5097
|
+
value: function create(languages, namespace, key, fallbackValue, callback) {
|
|
5288
5098
|
var _this3 = this;
|
|
5289
5099
|
|
|
5290
5100
|
if (!this.options.addPath) return;
|
|
5291
5101
|
if (typeof languages === 'string') languages = [languages];
|
|
5292
5102
|
var payload = this.options.parsePayload(namespace, key, fallbackValue);
|
|
5103
|
+
var finished = 0;
|
|
5104
|
+
var dataArray = [];
|
|
5105
|
+
var resArray = [];
|
|
5293
5106
|
languages.forEach(function (lng) {
|
|
5294
|
-
var
|
|
5107
|
+
var addPath = _this3.options.addPath;
|
|
5108
|
+
|
|
5109
|
+
if (typeof _this3.options.addPath === 'function') {
|
|
5110
|
+
addPath = _this3.options.addPath(lng, namespace);
|
|
5111
|
+
}
|
|
5112
|
+
|
|
5113
|
+
var url = _this3.services.interpolator.interpolate(addPath, {
|
|
5295
5114
|
lng: lng,
|
|
5296
5115
|
ns: namespace
|
|
5297
5116
|
});
|
|
5298
5117
|
|
|
5299
|
-
_this3.options.request(_this3.options, url, payload, function (data, res) {
|
|
5118
|
+
_this3.options.request(_this3.options, url, payload, function (data, res) {
|
|
5119
|
+
finished += 1;
|
|
5120
|
+
dataArray.push(data);
|
|
5121
|
+
resArray.push(res);
|
|
5122
|
+
|
|
5123
|
+
if (finished === languages.length) {
|
|
5124
|
+
if (callback) callback(dataArray, resArray);
|
|
5125
|
+
}
|
|
5126
|
+
});
|
|
5300
5127
|
});
|
|
5301
5128
|
}
|
|
5302
5129
|
}, {
|
|
@@ -5340,28 +5167,6 @@ var Backend = function () {
|
|
|
5340
5167
|
|
|
5341
5168
|
Backend.type = 'backend';
|
|
5342
5169
|
|
|
5343
|
-
function _classCallCheck(instance, Constructor) {
|
|
5344
|
-
if (!(instance instanceof Constructor)) {
|
|
5345
|
-
throw new TypeError("Cannot call a class as a function");
|
|
5346
|
-
}
|
|
5347
|
-
}
|
|
5348
|
-
|
|
5349
|
-
function _defineProperties(target, props) {
|
|
5350
|
-
for (var i = 0; i < props.length; i++) {
|
|
5351
|
-
var descriptor = props[i];
|
|
5352
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
5353
|
-
descriptor.configurable = true;
|
|
5354
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
5355
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
5356
|
-
}
|
|
5357
|
-
}
|
|
5358
|
-
|
|
5359
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
5360
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
5361
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
5362
|
-
return Constructor;
|
|
5363
|
-
}
|
|
5364
|
-
|
|
5365
5170
|
var arr = [];
|
|
5366
5171
|
var each = arr.forEach;
|
|
5367
5172
|
var slice = arr.slice;
|
|
@@ -5692,14 +5497,14 @@ function () {
|
|
|
5692
5497
|
function Browser(services) {
|
|
5693
5498
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5694
5499
|
|
|
5695
|
-
_classCallCheck(this, Browser);
|
|
5500
|
+
_classCallCheck$1(this, Browser);
|
|
5696
5501
|
|
|
5697
5502
|
this.type = 'languageDetector';
|
|
5698
5503
|
this.detectors = {};
|
|
5699
5504
|
this.init(services, options);
|
|
5700
5505
|
}
|
|
5701
5506
|
|
|
5702
|
-
_createClass(Browser, [{
|
|
5507
|
+
_createClass$1(Browser, [{
|
|
5703
5508
|
key: "init",
|
|
5704
5509
|
value: function init(services) {
|
|
5705
5510
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -5765,26 +5570,26 @@ function localize(_a) {
|
|
|
5765
5570
|
var detectorConfig = _a.detectorConfig, translationPath = _a.translationPath, i18nConfig = __rest(_a, ["detectorConfig", "translationPath"]);
|
|
5766
5571
|
var detectionObject = detectorConfig || {
|
|
5767
5572
|
// order and from where user language should be detected
|
|
5768
|
-
order: [
|
|
5573
|
+
order: ['querystring', 'cookie', 'localStorage'],
|
|
5769
5574
|
// keys or params to lookup language from
|
|
5770
|
-
lookupQuerystring:
|
|
5771
|
-
lookupCookie:
|
|
5772
|
-
lookupSessionStorage:
|
|
5773
|
-
lookupLocalStorage:
|
|
5575
|
+
lookupQuerystring: 'lang',
|
|
5576
|
+
lookupCookie: 'lang',
|
|
5577
|
+
lookupSessionStorage: 'lang',
|
|
5578
|
+
lookupLocalStorage: 'lang',
|
|
5774
5579
|
// cache user language on
|
|
5775
|
-
caches: [
|
|
5776
|
-
excludeCacheFor: [
|
|
5580
|
+
caches: ['localStorage', 'cookie'],
|
|
5581
|
+
excludeCacheFor: ['cimode'],
|
|
5777
5582
|
// optional set cookie options, reference:[MDN Set-Cookie docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie)
|
|
5778
|
-
cookieOptions: { path:
|
|
5583
|
+
cookieOptions: { path: '/', sameSite: 'strict' },
|
|
5779
5584
|
};
|
|
5780
|
-
var transPath = translationPath ||
|
|
5781
|
-
var mergedConfig = __assign({ fallbackLng:
|
|
5585
|
+
var transPath = translationPath || '/locales/{{lng}}/{{ns}}.json';
|
|
5586
|
+
var mergedConfig = __assign({ fallbackLng: 'en-US', debug: true, keySeparator: '.', backend: {
|
|
5782
5587
|
// this is the path to your translation files
|
|
5783
5588
|
// this can also take an absolute path as well as the current relative path
|
|
5784
5589
|
// relative path currently points to public/locales
|
|
5785
5590
|
loadPath: transPath,
|
|
5786
5591
|
}, interpolation: {
|
|
5787
|
-
escapeValue: false,
|
|
5592
|
+
escapeValue: false, // React takes care of interpolation for us
|
|
5788
5593
|
}, detection: detectionObject }, i18nConfig);
|
|
5789
5594
|
i18next.use(Backend) // used for loading external translation files
|
|
5790
5595
|
.use(Browser) // used to detect langage via cookie, local storage, or query param
|
|
@@ -5798,8 +5603,8 @@ function SpsLanguage(_a) {
|
|
|
5798
5603
|
}
|
|
5799
5604
|
|
|
5800
5605
|
function useSpsLanguage(ns, options) {
|
|
5801
|
-
if (ns === void 0) { ns =
|
|
5802
|
-
return useTranslation([ns,
|
|
5606
|
+
if (ns === void 0) { ns = 'translation'; }
|
|
5607
|
+
return useTranslation([ns, 'design-system'], options);
|
|
5803
5608
|
}
|
|
5804
5609
|
|
|
5805
5610
|
exports.SpsLanguage = SpsLanguage;
|