i18next 21.4.2 → 21.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/i18next.js +96 -45
- package/dist/esm/i18next.bundled.js +141 -62
- package/dist/esm/i18next.js +109 -43
- package/dist/esm/package.json +1 -0
- package/dist/umd/i18next.js +120 -88
- package/dist/umd/i18next.min.js +1 -1
- package/i18next.js +120 -88
- package/i18next.min.js +1 -1
- package/package.json +16 -10
- package/CHANGELOG.md +0 -1431
package/dist/esm/i18next.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import _typeof from '@babel/runtime/helpers/esm/typeof';
|
|
2
|
-
import _objectSpread from '@babel/runtime/helpers/esm/objectSpread';
|
|
3
2
|
import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';
|
|
4
3
|
import _createClass from '@babel/runtime/helpers/esm/createClass';
|
|
5
|
-
import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';
|
|
6
|
-
import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf';
|
|
7
4
|
import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';
|
|
8
5
|
import _inherits from '@babel/runtime/helpers/esm/inherits';
|
|
6
|
+
import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';
|
|
7
|
+
import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf';
|
|
8
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
9
9
|
import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
|
|
10
10
|
|
|
11
|
+
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; }
|
|
12
|
+
|
|
13
|
+
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; }
|
|
14
|
+
|
|
11
15
|
var consoleLogger = {
|
|
12
16
|
type: 'logger',
|
|
13
17
|
log: function log(args) {
|
|
@@ -93,9 +97,9 @@ var Logger = function () {
|
|
|
93
97
|
}, {
|
|
94
98
|
key: "create",
|
|
95
99
|
value: function create(moduleName) {
|
|
96
|
-
return new Logger(this.logger, _objectSpread({}, {
|
|
100
|
+
return new Logger(this.logger, _objectSpread(_objectSpread({}, {
|
|
97
101
|
prefix: "".concat(this.prefix, ":").concat(moduleName, ":")
|
|
98
|
-
}, this.options));
|
|
102
|
+
}), this.options));
|
|
99
103
|
}
|
|
100
104
|
}]);
|
|
101
105
|
|
|
@@ -310,6 +314,14 @@ function looksLikeObjectPath(key, nsSeparator, keySeparator) {
|
|
|
310
314
|
return matched;
|
|
311
315
|
}
|
|
312
316
|
|
|
317
|
+
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; }
|
|
318
|
+
|
|
319
|
+
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(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; }
|
|
320
|
+
|
|
321
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
322
|
+
|
|
323
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
324
|
+
|
|
313
325
|
function deepFind(obj, path) {
|
|
314
326
|
var keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
|
|
315
327
|
if (!obj) return undefined;
|
|
@@ -352,6 +364,8 @@ function deepFind(obj, path) {
|
|
|
352
364
|
var ResourceStore = function (_EventEmitter) {
|
|
353
365
|
_inherits(ResourceStore, _EventEmitter);
|
|
354
366
|
|
|
367
|
+
var _super = _createSuper(ResourceStore);
|
|
368
|
+
|
|
355
369
|
function ResourceStore(data) {
|
|
356
370
|
var _this;
|
|
357
371
|
|
|
@@ -362,7 +376,7 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
362
376
|
|
|
363
377
|
_classCallCheck(this, ResourceStore);
|
|
364
378
|
|
|
365
|
-
_this =
|
|
379
|
+
_this = _super.call(this);
|
|
366
380
|
|
|
367
381
|
if (isIE10) {
|
|
368
382
|
EventEmitter.call(_assertThisInitialized(_this));
|
|
@@ -473,7 +487,7 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
473
487
|
if (deep) {
|
|
474
488
|
deepExtend(pack, resources, overwrite);
|
|
475
489
|
} else {
|
|
476
|
-
pack = _objectSpread({}, pack, resources);
|
|
490
|
+
pack = _objectSpread$1(_objectSpread$1({}, pack), resources);
|
|
477
491
|
}
|
|
478
492
|
|
|
479
493
|
setPath(this.data, path, pack);
|
|
@@ -498,7 +512,7 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
498
512
|
key: "getResourceBundle",
|
|
499
513
|
value: function getResourceBundle(lng, ns) {
|
|
500
514
|
if (!ns) ns = this.options.defaultNS;
|
|
501
|
-
if (this.options.compatibilityAPI === 'v1') return _objectSpread({}, {}, this.getResource(lng, ns));
|
|
515
|
+
if (this.options.compatibilityAPI === 'v1') return _objectSpread$1(_objectSpread$1({}, {}), this.getResource(lng, ns));
|
|
502
516
|
return this.getResource(lng, ns);
|
|
503
517
|
}
|
|
504
518
|
}, {
|
|
@@ -540,11 +554,20 @@ var postProcessor = {
|
|
|
540
554
|
}
|
|
541
555
|
};
|
|
542
556
|
|
|
557
|
+
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; }
|
|
558
|
+
|
|
559
|
+
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(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; }
|
|
560
|
+
|
|
561
|
+
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
562
|
+
|
|
563
|
+
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
543
564
|
var checkedLoadedFor = {};
|
|
544
565
|
|
|
545
566
|
var Translator = function (_EventEmitter) {
|
|
546
567
|
_inherits(Translator, _EventEmitter);
|
|
547
568
|
|
|
569
|
+
var _super = _createSuper$1(Translator);
|
|
570
|
+
|
|
548
571
|
function Translator(services) {
|
|
549
572
|
var _this;
|
|
550
573
|
|
|
@@ -552,7 +575,7 @@ var Translator = function (_EventEmitter) {
|
|
|
552
575
|
|
|
553
576
|
_classCallCheck(this, Translator);
|
|
554
577
|
|
|
555
|
-
_this =
|
|
578
|
+
_this = _super.call(this);
|
|
556
579
|
|
|
557
580
|
if (isIE10) {
|
|
558
581
|
EventEmitter.call(_assertThisInitialized(_this));
|
|
@@ -666,7 +689,7 @@ var Translator = function (_EventEmitter) {
|
|
|
666
689
|
this.logger.warn('accessing an object - but returnObjects options is not enabled!');
|
|
667
690
|
}
|
|
668
691
|
|
|
669
|
-
return this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread({}, options, {
|
|
692
|
+
return this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread$2(_objectSpread$2({}, options), {}, {
|
|
670
693
|
ns: namespaces
|
|
671
694
|
})) : "key '".concat(key, " (").concat(this.language, ")' returned an object instead of string.");
|
|
672
695
|
}
|
|
@@ -679,7 +702,7 @@ var Translator = function (_EventEmitter) {
|
|
|
679
702
|
for (var m in res) {
|
|
680
703
|
if (Object.prototype.hasOwnProperty.call(res, m)) {
|
|
681
704
|
var deepKey = "".concat(newKeyToUse).concat(keySeparator).concat(m);
|
|
682
|
-
copy[m] = this.translate(deepKey, _objectSpread({}, options, {
|
|
705
|
+
copy[m] = this.translate(deepKey, _objectSpread$2(_objectSpread$2({}, options), {
|
|
683
706
|
joinArrays: false,
|
|
684
707
|
ns: namespaces
|
|
685
708
|
}));
|
|
@@ -718,7 +741,7 @@ var Translator = function (_EventEmitter) {
|
|
|
718
741
|
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
|
|
719
742
|
|
|
720
743
|
if (keySeparator) {
|
|
721
|
-
var fk = this.resolve(key, _objectSpread({}, options, {
|
|
744
|
+
var fk = this.resolve(key, _objectSpread$2(_objectSpread$2({}, options), {}, {
|
|
722
745
|
keySeparator: false
|
|
723
746
|
}));
|
|
724
747
|
if (fk && fk.res) 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.');
|
|
@@ -777,8 +800,8 @@ var Translator = function (_EventEmitter) {
|
|
|
777
800
|
resolved: resolved
|
|
778
801
|
});
|
|
779
802
|
} else if (!options.skipInterpolation) {
|
|
780
|
-
if (options.interpolation) this.interpolator.init(_objectSpread({}, options, {
|
|
781
|
-
interpolation: _objectSpread({}, this.options.interpolation, options.interpolation)
|
|
803
|
+
if (options.interpolation) this.interpolator.init(_objectSpread$2(_objectSpread$2({}, options), {
|
|
804
|
+
interpolation: _objectSpread$2(_objectSpread$2({}, this.options.interpolation), options.interpolation)
|
|
782
805
|
}));
|
|
783
806
|
var skipOnVariables = options.interpolation && options.interpolation.skipOnVariables || this.options.interpolation.skipOnVariables;
|
|
784
807
|
var nestBef;
|
|
@@ -789,7 +812,7 @@ var Translator = function (_EventEmitter) {
|
|
|
789
812
|
}
|
|
790
813
|
|
|
791
814
|
var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
|
|
792
|
-
if (this.options.interpolation.defaultVariables) data = _objectSpread({}, this.options.interpolation.defaultVariables, data);
|
|
815
|
+
if (this.options.interpolation.defaultVariables) data = _objectSpread$2(_objectSpread$2({}, this.options.interpolation.defaultVariables), data);
|
|
793
816
|
res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
|
|
794
817
|
|
|
795
818
|
if (skipOnVariables) {
|
|
@@ -818,7 +841,7 @@ var Translator = function (_EventEmitter) {
|
|
|
818
841
|
var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
|
|
819
842
|
|
|
820
843
|
if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
|
|
821
|
-
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread({
|
|
844
|
+
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread$2({
|
|
822
845
|
i18nResolved: resolved
|
|
823
846
|
}, options) : options, this);
|
|
824
847
|
}
|
|
@@ -1400,6 +1423,10 @@ var PluralResolver = function () {
|
|
|
1400
1423
|
return PluralResolver;
|
|
1401
1424
|
}();
|
|
1402
1425
|
|
|
1426
|
+
function ownKeys$3(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; }
|
|
1427
|
+
|
|
1428
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1429
|
+
|
|
1403
1430
|
var Interpolator = function () {
|
|
1404
1431
|
function Interpolator() {
|
|
1405
1432
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -1471,7 +1498,7 @@ var Interpolator = function () {
|
|
|
1471
1498
|
var handleFormat = function handleFormat(key) {
|
|
1472
1499
|
if (key.indexOf(_this.formatSeparator) < 0) {
|
|
1473
1500
|
var path = getPathWithDefaults(data, defaultData, key);
|
|
1474
|
-
return _this.alwaysFormat ? _this.format(path, undefined, lng, _objectSpread({}, options, data, {
|
|
1501
|
+
return _this.alwaysFormat ? _this.format(path, undefined, lng, _objectSpread$3(_objectSpread$3(_objectSpread$3({}, options), data), {}, {
|
|
1475
1502
|
interpolationkey: key
|
|
1476
1503
|
})) : path;
|
|
1477
1504
|
}
|
|
@@ -1479,7 +1506,7 @@ var Interpolator = function () {
|
|
|
1479
1506
|
var p = key.split(_this.formatSeparator);
|
|
1480
1507
|
var k = p.shift().trim();
|
|
1481
1508
|
var f = p.join(_this.formatSeparator).trim();
|
|
1482
|
-
return _this.format(getPathWithDefaults(data, defaultData, k), f, lng, _objectSpread({}, options, data, {
|
|
1509
|
+
return _this.format(getPathWithDefaults(data, defaultData, k), f, lng, _objectSpread$3(_objectSpread$3(_objectSpread$3({}, options), data), {}, {
|
|
1483
1510
|
interpolationkey: k
|
|
1484
1511
|
}));
|
|
1485
1512
|
};
|
|
@@ -1548,7 +1575,7 @@ var Interpolator = function () {
|
|
|
1548
1575
|
var match;
|
|
1549
1576
|
var value;
|
|
1550
1577
|
|
|
1551
|
-
var clonedOptions = _objectSpread({}, options);
|
|
1578
|
+
var clonedOptions = _objectSpread$3({}, options);
|
|
1552
1579
|
|
|
1553
1580
|
clonedOptions.applyPostProcessor = false;
|
|
1554
1581
|
delete clonedOptions.defaultValue;
|
|
@@ -1564,7 +1591,7 @@ var Interpolator = function () {
|
|
|
1564
1591
|
|
|
1565
1592
|
try {
|
|
1566
1593
|
clonedOptions = JSON.parse(optionsString);
|
|
1567
|
-
if (inheritedOptions) clonedOptions = _objectSpread({}, inheritedOptions, clonedOptions);
|
|
1594
|
+
if (inheritedOptions) clonedOptions = _objectSpread$3(_objectSpread$3({}, inheritedOptions), clonedOptions);
|
|
1568
1595
|
} catch (e) {
|
|
1569
1596
|
this.logger.warn("failed parsing options string in nesting for key ".concat(key), e);
|
|
1570
1597
|
return "".concat(key).concat(sep).concat(optionsString);
|
|
@@ -1598,7 +1625,7 @@ var Interpolator = function () {
|
|
|
1598
1625
|
|
|
1599
1626
|
if (doReduce) {
|
|
1600
1627
|
value = formatters.reduce(function (v, f) {
|
|
1601
|
-
return _this2.format(v, f, options.lng, _objectSpread({}, options, {
|
|
1628
|
+
return _this2.format(v, f, options.lng, _objectSpread$3(_objectSpread$3({}, options), {}, {
|
|
1602
1629
|
interpolationkey: match[1].trim()
|
|
1603
1630
|
}));
|
|
1604
1631
|
}, value.trim());
|
|
@@ -1615,6 +1642,10 @@ var Interpolator = function () {
|
|
|
1615
1642
|
return Interpolator;
|
|
1616
1643
|
}();
|
|
1617
1644
|
|
|
1645
|
+
function ownKeys$4(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; }
|
|
1646
|
+
|
|
1647
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1648
|
+
|
|
1618
1649
|
function parseFormatStr(formatStr) {
|
|
1619
1650
|
var formatName = formatStr.toLowerCase().trim();
|
|
1620
1651
|
var formatOptions = {};
|
|
@@ -1665,18 +1696,18 @@ var Formatter = function () {
|
|
|
1665
1696
|
return new Intl.NumberFormat(lng, options).format(val);
|
|
1666
1697
|
},
|
|
1667
1698
|
currency: function currency(val, lng, options) {
|
|
1668
|
-
return new Intl.NumberFormat(lng, _objectSpread({}, options, {
|
|
1699
|
+
return new Intl.NumberFormat(lng, _objectSpread$4(_objectSpread$4({}, options), {}, {
|
|
1669
1700
|
style: 'currency'
|
|
1670
1701
|
})).format(val);
|
|
1671
1702
|
},
|
|
1672
1703
|
datetime: function datetime(val, lng, options) {
|
|
1673
|
-
return new Intl.DateTimeFormat(lng, _objectSpread({}, options)).format(val);
|
|
1704
|
+
return new Intl.DateTimeFormat(lng, _objectSpread$4({}, options)).format(val);
|
|
1674
1705
|
},
|
|
1675
1706
|
relativetime: function relativetime(val, lng, options) {
|
|
1676
|
-
return new Intl.RelativeTimeFormat(lng, _objectSpread({}, options)).format(val, options.range || 'day');
|
|
1707
|
+
return new Intl.RelativeTimeFormat(lng, _objectSpread$4({}, options)).format(val, options.range || 'day');
|
|
1677
1708
|
},
|
|
1678
1709
|
list: function list(val, lng, options) {
|
|
1679
|
-
return new Intl.ListFormat(lng, _objectSpread({}, options)).format(val);
|
|
1710
|
+
return new Intl.ListFormat(lng, _objectSpread$4({}, options)).format(val);
|
|
1680
1711
|
}
|
|
1681
1712
|
};
|
|
1682
1713
|
this.init(options);
|
|
@@ -1714,7 +1745,7 @@ var Formatter = function () {
|
|
|
1714
1745
|
try {
|
|
1715
1746
|
var valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
|
|
1716
1747
|
var l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
|
|
1717
|
-
formatted = _this.formats[formatName](mem, l, _objectSpread({}, formatOptions, options, valOptions));
|
|
1748
|
+
formatted = _this.formats[formatName](mem, l, _objectSpread$4(_objectSpread$4(_objectSpread$4({}, formatOptions), options), valOptions));
|
|
1718
1749
|
} catch (error) {
|
|
1719
1750
|
_this.logger.warn(error);
|
|
1720
1751
|
}
|
|
@@ -1733,6 +1764,14 @@ var Formatter = function () {
|
|
|
1733
1764
|
return Formatter;
|
|
1734
1765
|
}();
|
|
1735
1766
|
|
|
1767
|
+
function ownKeys$5(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; }
|
|
1768
|
+
|
|
1769
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1770
|
+
|
|
1771
|
+
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
1772
|
+
|
|
1773
|
+
function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
1774
|
+
|
|
1736
1775
|
function remove(arr, what) {
|
|
1737
1776
|
var found = arr.indexOf(what);
|
|
1738
1777
|
|
|
@@ -1745,6 +1784,8 @@ function remove(arr, what) {
|
|
|
1745
1784
|
var Connector = function (_EventEmitter) {
|
|
1746
1785
|
_inherits(Connector, _EventEmitter);
|
|
1747
1786
|
|
|
1787
|
+
var _super = _createSuper$2(Connector);
|
|
1788
|
+
|
|
1748
1789
|
function Connector(backend, store, services) {
|
|
1749
1790
|
var _this;
|
|
1750
1791
|
|
|
@@ -1752,7 +1793,7 @@ var Connector = function (_EventEmitter) {
|
|
|
1752
1793
|
|
|
1753
1794
|
_classCallCheck(this, Connector);
|
|
1754
1795
|
|
|
1755
|
-
_this =
|
|
1796
|
+
_this = _super.call(this);
|
|
1756
1797
|
|
|
1757
1798
|
if (isIE10) {
|
|
1758
1799
|
EventEmitter.call(_assertThisInitialized(_this));
|
|
@@ -1949,7 +1990,7 @@ var Connector = function (_EventEmitter) {
|
|
|
1949
1990
|
if (key === undefined || key === null || key === '') return;
|
|
1950
1991
|
|
|
1951
1992
|
if (this.backend && this.backend.create) {
|
|
1952
|
-
this.backend.create(languages, namespace, key, fallbackValue, null, _objectSpread({}, options, {
|
|
1993
|
+
this.backend.create(languages, namespace, key, fallbackValue, null, _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
1953
1994
|
isUpdate: isUpdate
|
|
1954
1995
|
}));
|
|
1955
1996
|
}
|
|
@@ -2040,6 +2081,14 @@ function transformOptions(options) {
|
|
|
2040
2081
|
return options;
|
|
2041
2082
|
}
|
|
2042
2083
|
|
|
2084
|
+
function ownKeys$6(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; }
|
|
2085
|
+
|
|
2086
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2087
|
+
|
|
2088
|
+
function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
2089
|
+
|
|
2090
|
+
function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
2091
|
+
|
|
2043
2092
|
function noop() {}
|
|
2044
2093
|
|
|
2045
2094
|
function bindMemberFunctions(inst) {
|
|
@@ -2054,6 +2103,8 @@ function bindMemberFunctions(inst) {
|
|
|
2054
2103
|
var I18n = function (_EventEmitter) {
|
|
2055
2104
|
_inherits(I18n, _EventEmitter);
|
|
2056
2105
|
|
|
2106
|
+
var _super = _createSuper$3(I18n);
|
|
2107
|
+
|
|
2057
2108
|
function I18n() {
|
|
2058
2109
|
var _this;
|
|
2059
2110
|
|
|
@@ -2062,7 +2113,7 @@ var I18n = function (_EventEmitter) {
|
|
|
2062
2113
|
|
|
2063
2114
|
_classCallCheck(this, I18n);
|
|
2064
2115
|
|
|
2065
|
-
_this =
|
|
2116
|
+
_this = _super.call(this);
|
|
2066
2117
|
|
|
2067
2118
|
if (isIE10) {
|
|
2068
2119
|
EventEmitter.call(_assertThisInitialized(_this));
|
|
@@ -2113,7 +2164,7 @@ var I18n = function (_EventEmitter) {
|
|
|
2113
2164
|
}
|
|
2114
2165
|
|
|
2115
2166
|
var defOpts = get();
|
|
2116
|
-
this.options = _objectSpread({}, defOpts, this.options, transformOptions(options));
|
|
2167
|
+
this.options = _objectSpread$6(_objectSpread$6(_objectSpread$6({}, defOpts), this.options), transformOptions(options));
|
|
2117
2168
|
|
|
2118
2169
|
if (options.keySeparator !== undefined) {
|
|
2119
2170
|
this.options.userDefinedKeySeparator = options.keySeparator;
|
|
@@ -2440,7 +2491,7 @@ var I18n = function (_EventEmitter) {
|
|
|
2440
2491
|
|
|
2441
2492
|
options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
|
2442
2493
|
} else {
|
|
2443
|
-
options = _objectSpread({}, opts);
|
|
2494
|
+
options = _objectSpread$6({}, opts);
|
|
2444
2495
|
}
|
|
2445
2496
|
|
|
2446
2497
|
options.lng = options.lng || fixedT.lng;
|
|
@@ -2570,13 +2621,6 @@ var I18n = function (_EventEmitter) {
|
|
|
2570
2621
|
var 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'];
|
|
2571
2622
|
return rtlLngs.indexOf(this.services.languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
|
|
2572
2623
|
}
|
|
2573
|
-
}, {
|
|
2574
|
-
key: "createInstance",
|
|
2575
|
-
value: function createInstance() {
|
|
2576
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2577
|
-
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
2578
|
-
return new I18n(options, callback);
|
|
2579
|
-
}
|
|
2580
2624
|
}, {
|
|
2581
2625
|
key: "cloneInstance",
|
|
2582
2626
|
value: function cloneInstance() {
|
|
@@ -2585,7 +2629,7 @@ var I18n = function (_EventEmitter) {
|
|
|
2585
2629
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2586
2630
|
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
|
2587
2631
|
|
|
2588
|
-
var mergedOptions = _objectSpread({}, this.options, options, {
|
|
2632
|
+
var mergedOptions = _objectSpread$6(_objectSpread$6(_objectSpread$6({}, this.options), options), {
|
|
2589
2633
|
isClone: true
|
|
2590
2634
|
});
|
|
2591
2635
|
|
|
@@ -2594,7 +2638,7 @@ var I18n = function (_EventEmitter) {
|
|
|
2594
2638
|
membersToCopy.forEach(function (m) {
|
|
2595
2639
|
clone[m] = _this8[m];
|
|
2596
2640
|
});
|
|
2597
|
-
clone.services = _objectSpread({}, this.services);
|
|
2641
|
+
clone.services = _objectSpread$6({}, this.services);
|
|
2598
2642
|
clone.services.utils = {
|
|
2599
2643
|
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
|
2600
2644
|
};
|
|
@@ -2629,6 +2673,28 @@ var I18n = function (_EventEmitter) {
|
|
|
2629
2673
|
return I18n;
|
|
2630
2674
|
}(EventEmitter);
|
|
2631
2675
|
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2676
|
+
_defineProperty(I18n, "createInstance", function () {
|
|
2677
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2678
|
+
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
2679
|
+
return new I18n(options, callback);
|
|
2680
|
+
});
|
|
2681
|
+
|
|
2682
|
+
var instance = I18n.createInstance();
|
|
2683
|
+
instance.createInstance = I18n.createInstance;
|
|
2684
|
+
|
|
2685
|
+
var createInstance = instance.createInstance;
|
|
2686
|
+
var init = instance.init;
|
|
2687
|
+
var loadResources = instance.loadResources;
|
|
2688
|
+
var reloadResources = instance.reloadResources;
|
|
2689
|
+
var use = instance.use;
|
|
2690
|
+
var changeLanguage = instance.changeLanguage;
|
|
2691
|
+
var getFixedT = instance.getFixedT;
|
|
2692
|
+
var t = instance.t;
|
|
2693
|
+
var exists = instance.exists;
|
|
2694
|
+
var setDefaultNamespace = instance.setDefaultNamespace;
|
|
2695
|
+
var hasLoadedNamespace = instance.hasLoadedNamespace;
|
|
2696
|
+
var loadNamespaces = instance.loadNamespaces;
|
|
2697
|
+
var loadLanguages = instance.loadLanguages;
|
|
2698
|
+
|
|
2699
|
+
export default instance;
|
|
2700
|
+
export { changeLanguage, createInstance, exists, getFixedT, hasLoadedNamespace, init, loadLanguages, loadNamespaces, loadResources, reloadResources, setDefaultNamespace, t, use };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|