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
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) {
|
|
2
|
+
var keys = Object.keys(object);
|
|
3
|
+
|
|
4
|
+
if (Object.getOwnPropertySymbols) {
|
|
5
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
6
|
+
|
|
7
|
+
if (enumerableOnly) {
|
|
8
|
+
symbols = symbols.filter(function (sym) {
|
|
9
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
keys.push.apply(keys, symbols);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return keys;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function _objectSpread2(target) {
|
|
20
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
21
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
22
|
+
|
|
23
|
+
if (i % 2) {
|
|
24
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
25
|
+
_defineProperty(target, key, source[key]);
|
|
26
|
+
});
|
|
27
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
28
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
29
|
+
} else {
|
|
30
|
+
ownKeys(Object(source)).forEach(function (key) {
|
|
31
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return target;
|
|
37
|
+
}
|
|
38
|
+
|
|
1
39
|
function _typeof(obj) {
|
|
2
40
|
"@babel/helpers - typeof";
|
|
3
41
|
|
|
@@ -51,25 +89,6 @@ function _defineProperty(obj, key, value) {
|
|
|
51
89
|
return obj;
|
|
52
90
|
}
|
|
53
91
|
|
|
54
|
-
function _objectSpread(target) {
|
|
55
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
56
|
-
var source = arguments[i] != null ? Object(arguments[i]) : {};
|
|
57
|
-
var ownKeys = Object.keys(source);
|
|
58
|
-
|
|
59
|
-
if (typeof Object.getOwnPropertySymbols === 'function') {
|
|
60
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
|
|
61
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
62
|
-
}));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
ownKeys.forEach(function (key) {
|
|
66
|
-
_defineProperty(target, key, source[key]);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return target;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
92
|
function _inherits(subClass, superClass) {
|
|
74
93
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
75
94
|
throw new TypeError("Super expression must either be null or a function");
|
|
@@ -101,6 +120,19 @@ function _setPrototypeOf(o, p) {
|
|
|
101
120
|
return _setPrototypeOf(o, p);
|
|
102
121
|
}
|
|
103
122
|
|
|
123
|
+
function _isNativeReflectConstruct() {
|
|
124
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
125
|
+
if (Reflect.construct.sham) return false;
|
|
126
|
+
if (typeof Proxy === "function") return true;
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
130
|
+
return true;
|
|
131
|
+
} catch (e) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
104
136
|
function _assertThisInitialized(self) {
|
|
105
137
|
if (self === void 0) {
|
|
106
138
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
@@ -112,11 +144,32 @@ function _assertThisInitialized(self) {
|
|
|
112
144
|
function _possibleConstructorReturn(self, call) {
|
|
113
145
|
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
114
146
|
return call;
|
|
147
|
+
} else if (call !== void 0) {
|
|
148
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
115
149
|
}
|
|
116
150
|
|
|
117
151
|
return _assertThisInitialized(self);
|
|
118
152
|
}
|
|
119
153
|
|
|
154
|
+
function _createSuper(Derived) {
|
|
155
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
156
|
+
|
|
157
|
+
return function _createSuperInternal() {
|
|
158
|
+
var Super = _getPrototypeOf(Derived),
|
|
159
|
+
result;
|
|
160
|
+
|
|
161
|
+
if (hasNativeReflectConstruct) {
|
|
162
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
163
|
+
|
|
164
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
165
|
+
} else {
|
|
166
|
+
result = Super.apply(this, arguments);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return _possibleConstructorReturn(this, result);
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
120
173
|
function _slicedToArray(arr, i) {
|
|
121
174
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
122
175
|
}
|
|
@@ -126,14 +179,17 @@ function _arrayWithHoles(arr) {
|
|
|
126
179
|
}
|
|
127
180
|
|
|
128
181
|
function _iterableToArrayLimit(arr, i) {
|
|
129
|
-
|
|
182
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
183
|
+
|
|
184
|
+
if (_i == null) return;
|
|
130
185
|
var _arr = [];
|
|
131
186
|
var _n = true;
|
|
132
187
|
var _d = false;
|
|
133
|
-
|
|
188
|
+
|
|
189
|
+
var _s, _e;
|
|
134
190
|
|
|
135
191
|
try {
|
|
136
|
-
for (
|
|
192
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
137
193
|
_arr.push(_s.value);
|
|
138
194
|
|
|
139
195
|
if (i && _arr.length === i) break;
|
|
@@ -258,9 +314,9 @@ var Logger = function () {
|
|
|
258
314
|
}, {
|
|
259
315
|
key: "create",
|
|
260
316
|
value: function create(moduleName) {
|
|
261
|
-
return new Logger(this.logger,
|
|
317
|
+
return new Logger(this.logger, _objectSpread2(_objectSpread2({}, {
|
|
262
318
|
prefix: "".concat(this.prefix, ":").concat(moduleName, ":")
|
|
263
|
-
}, this.options));
|
|
319
|
+
}), this.options));
|
|
264
320
|
}
|
|
265
321
|
}]);
|
|
266
322
|
|
|
@@ -517,6 +573,8 @@ function deepFind(obj, path) {
|
|
|
517
573
|
var ResourceStore = function (_EventEmitter) {
|
|
518
574
|
_inherits(ResourceStore, _EventEmitter);
|
|
519
575
|
|
|
576
|
+
var _super = _createSuper(ResourceStore);
|
|
577
|
+
|
|
520
578
|
function ResourceStore(data) {
|
|
521
579
|
var _this;
|
|
522
580
|
|
|
@@ -527,7 +585,7 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
527
585
|
|
|
528
586
|
_classCallCheck(this, ResourceStore);
|
|
529
587
|
|
|
530
|
-
_this =
|
|
588
|
+
_this = _super.call(this);
|
|
531
589
|
|
|
532
590
|
if (isIE10) {
|
|
533
591
|
EventEmitter.call(_assertThisInitialized(_this));
|
|
@@ -638,7 +696,7 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
638
696
|
if (deep) {
|
|
639
697
|
deepExtend(pack, resources, overwrite);
|
|
640
698
|
} else {
|
|
641
|
-
pack =
|
|
699
|
+
pack = _objectSpread2(_objectSpread2({}, pack), resources);
|
|
642
700
|
}
|
|
643
701
|
|
|
644
702
|
setPath(this.data, path, pack);
|
|
@@ -663,7 +721,7 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
663
721
|
key: "getResourceBundle",
|
|
664
722
|
value: function getResourceBundle(lng, ns) {
|
|
665
723
|
if (!ns) ns = this.options.defaultNS;
|
|
666
|
-
if (this.options.compatibilityAPI === 'v1') return
|
|
724
|
+
if (this.options.compatibilityAPI === 'v1') return _objectSpread2(_objectSpread2({}, {}), this.getResource(lng, ns));
|
|
667
725
|
return this.getResource(lng, ns);
|
|
668
726
|
}
|
|
669
727
|
}, {
|
|
@@ -710,6 +768,8 @@ var checkedLoadedFor = {};
|
|
|
710
768
|
var Translator = function (_EventEmitter) {
|
|
711
769
|
_inherits(Translator, _EventEmitter);
|
|
712
770
|
|
|
771
|
+
var _super = _createSuper(Translator);
|
|
772
|
+
|
|
713
773
|
function Translator(services) {
|
|
714
774
|
var _this;
|
|
715
775
|
|
|
@@ -717,7 +777,7 @@ var Translator = function (_EventEmitter) {
|
|
|
717
777
|
|
|
718
778
|
_classCallCheck(this, Translator);
|
|
719
779
|
|
|
720
|
-
_this =
|
|
780
|
+
_this = _super.call(this);
|
|
721
781
|
|
|
722
782
|
if (isIE10) {
|
|
723
783
|
EventEmitter.call(_assertThisInitialized(_this));
|
|
@@ -831,7 +891,7 @@ var Translator = function (_EventEmitter) {
|
|
|
831
891
|
this.logger.warn('accessing an object - but returnObjects options is not enabled!');
|
|
832
892
|
}
|
|
833
893
|
|
|
834
|
-
return this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res,
|
|
894
|
+
return this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
835
895
|
ns: namespaces
|
|
836
896
|
})) : "key '".concat(key, " (").concat(this.language, ")' returned an object instead of string.");
|
|
837
897
|
}
|
|
@@ -844,7 +904,7 @@ var Translator = function (_EventEmitter) {
|
|
|
844
904
|
for (var m in res) {
|
|
845
905
|
if (Object.prototype.hasOwnProperty.call(res, m)) {
|
|
846
906
|
var deepKey = "".concat(newKeyToUse).concat(keySeparator).concat(m);
|
|
847
|
-
copy[m] = this.translate(deepKey,
|
|
907
|
+
copy[m] = this.translate(deepKey, _objectSpread2(_objectSpread2({}, options), {
|
|
848
908
|
joinArrays: false,
|
|
849
909
|
ns: namespaces
|
|
850
910
|
}));
|
|
@@ -883,7 +943,7 @@ var Translator = function (_EventEmitter) {
|
|
|
883
943
|
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
|
|
884
944
|
|
|
885
945
|
if (keySeparator) {
|
|
886
|
-
var fk = this.resolve(key,
|
|
946
|
+
var fk = this.resolve(key, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
887
947
|
keySeparator: false
|
|
888
948
|
}));
|
|
889
949
|
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.');
|
|
@@ -942,8 +1002,8 @@ var Translator = function (_EventEmitter) {
|
|
|
942
1002
|
resolved: resolved
|
|
943
1003
|
});
|
|
944
1004
|
} else if (!options.skipInterpolation) {
|
|
945
|
-
if (options.interpolation) this.interpolator.init(
|
|
946
|
-
interpolation:
|
|
1005
|
+
if (options.interpolation) this.interpolator.init(_objectSpread2(_objectSpread2({}, options), {
|
|
1006
|
+
interpolation: _objectSpread2(_objectSpread2({}, this.options.interpolation), options.interpolation)
|
|
947
1007
|
}));
|
|
948
1008
|
var skipOnVariables = options.interpolation && options.interpolation.skipOnVariables || this.options.interpolation.skipOnVariables;
|
|
949
1009
|
var nestBef;
|
|
@@ -954,7 +1014,7 @@ var Translator = function (_EventEmitter) {
|
|
|
954
1014
|
}
|
|
955
1015
|
|
|
956
1016
|
var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
|
|
957
|
-
if (this.options.interpolation.defaultVariables) data =
|
|
1017
|
+
if (this.options.interpolation.defaultVariables) data = _objectSpread2(_objectSpread2({}, this.options.interpolation.defaultVariables), data);
|
|
958
1018
|
res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
|
|
959
1019
|
|
|
960
1020
|
if (skipOnVariables) {
|
|
@@ -983,7 +1043,7 @@ var Translator = function (_EventEmitter) {
|
|
|
983
1043
|
var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
|
|
984
1044
|
|
|
985
1045
|
if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
|
|
986
|
-
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ?
|
|
1046
|
+
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread2({
|
|
987
1047
|
i18nResolved: resolved
|
|
988
1048
|
}, options) : options, this);
|
|
989
1049
|
}
|
|
@@ -1636,7 +1696,7 @@ var Interpolator = function () {
|
|
|
1636
1696
|
var handleFormat = function handleFormat(key) {
|
|
1637
1697
|
if (key.indexOf(_this.formatSeparator) < 0) {
|
|
1638
1698
|
var path = getPathWithDefaults(data, defaultData, key);
|
|
1639
|
-
return _this.alwaysFormat ? _this.format(path, undefined, lng,
|
|
1699
|
+
return _this.alwaysFormat ? _this.format(path, undefined, lng, _objectSpread2(_objectSpread2(_objectSpread2({}, options), data), {}, {
|
|
1640
1700
|
interpolationkey: key
|
|
1641
1701
|
})) : path;
|
|
1642
1702
|
}
|
|
@@ -1644,7 +1704,7 @@ var Interpolator = function () {
|
|
|
1644
1704
|
var p = key.split(_this.formatSeparator);
|
|
1645
1705
|
var k = p.shift().trim();
|
|
1646
1706
|
var f = p.join(_this.formatSeparator).trim();
|
|
1647
|
-
return _this.format(getPathWithDefaults(data, defaultData, k), f, lng,
|
|
1707
|
+
return _this.format(getPathWithDefaults(data, defaultData, k), f, lng, _objectSpread2(_objectSpread2(_objectSpread2({}, options), data), {}, {
|
|
1648
1708
|
interpolationkey: k
|
|
1649
1709
|
}));
|
|
1650
1710
|
};
|
|
@@ -1713,7 +1773,7 @@ var Interpolator = function () {
|
|
|
1713
1773
|
var match;
|
|
1714
1774
|
var value;
|
|
1715
1775
|
|
|
1716
|
-
var clonedOptions =
|
|
1776
|
+
var clonedOptions = _objectSpread2({}, options);
|
|
1717
1777
|
|
|
1718
1778
|
clonedOptions.applyPostProcessor = false;
|
|
1719
1779
|
delete clonedOptions.defaultValue;
|
|
@@ -1729,7 +1789,7 @@ var Interpolator = function () {
|
|
|
1729
1789
|
|
|
1730
1790
|
try {
|
|
1731
1791
|
clonedOptions = JSON.parse(optionsString);
|
|
1732
|
-
if (inheritedOptions) clonedOptions =
|
|
1792
|
+
if (inheritedOptions) clonedOptions = _objectSpread2(_objectSpread2({}, inheritedOptions), clonedOptions);
|
|
1733
1793
|
} catch (e) {
|
|
1734
1794
|
this.logger.warn("failed parsing options string in nesting for key ".concat(key), e);
|
|
1735
1795
|
return "".concat(key).concat(sep).concat(optionsString);
|
|
@@ -1763,7 +1823,7 @@ var Interpolator = function () {
|
|
|
1763
1823
|
|
|
1764
1824
|
if (doReduce) {
|
|
1765
1825
|
value = formatters.reduce(function (v, f) {
|
|
1766
|
-
return _this2.format(v, f, options.lng,
|
|
1826
|
+
return _this2.format(v, f, options.lng, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1767
1827
|
interpolationkey: match[1].trim()
|
|
1768
1828
|
}));
|
|
1769
1829
|
}, value.trim());
|
|
@@ -1830,18 +1890,18 @@ var Formatter = function () {
|
|
|
1830
1890
|
return new Intl.NumberFormat(lng, options).format(val);
|
|
1831
1891
|
},
|
|
1832
1892
|
currency: function currency(val, lng, options) {
|
|
1833
|
-
return new Intl.NumberFormat(lng,
|
|
1893
|
+
return new Intl.NumberFormat(lng, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1834
1894
|
style: 'currency'
|
|
1835
1895
|
})).format(val);
|
|
1836
1896
|
},
|
|
1837
1897
|
datetime: function datetime(val, lng, options) {
|
|
1838
|
-
return new Intl.DateTimeFormat(lng,
|
|
1898
|
+
return new Intl.DateTimeFormat(lng, _objectSpread2({}, options)).format(val);
|
|
1839
1899
|
},
|
|
1840
1900
|
relativetime: function relativetime(val, lng, options) {
|
|
1841
|
-
return new Intl.RelativeTimeFormat(lng,
|
|
1901
|
+
return new Intl.RelativeTimeFormat(lng, _objectSpread2({}, options)).format(val, options.range || 'day');
|
|
1842
1902
|
},
|
|
1843
1903
|
list: function list(val, lng, options) {
|
|
1844
|
-
return new Intl.ListFormat(lng,
|
|
1904
|
+
return new Intl.ListFormat(lng, _objectSpread2({}, options)).format(val);
|
|
1845
1905
|
}
|
|
1846
1906
|
};
|
|
1847
1907
|
this.init(options);
|
|
@@ -1879,7 +1939,7 @@ var Formatter = function () {
|
|
|
1879
1939
|
try {
|
|
1880
1940
|
var valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
|
|
1881
1941
|
var l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
|
|
1882
|
-
formatted = _this.formats[formatName](mem, l,
|
|
1942
|
+
formatted = _this.formats[formatName](mem, l, _objectSpread2(_objectSpread2(_objectSpread2({}, formatOptions), options), valOptions));
|
|
1883
1943
|
} catch (error) {
|
|
1884
1944
|
_this.logger.warn(error);
|
|
1885
1945
|
}
|
|
@@ -1910,6 +1970,8 @@ function remove(arr, what) {
|
|
|
1910
1970
|
var Connector = function (_EventEmitter) {
|
|
1911
1971
|
_inherits(Connector, _EventEmitter);
|
|
1912
1972
|
|
|
1973
|
+
var _super = _createSuper(Connector);
|
|
1974
|
+
|
|
1913
1975
|
function Connector(backend, store, services) {
|
|
1914
1976
|
var _this;
|
|
1915
1977
|
|
|
@@ -1917,7 +1979,7 @@ var Connector = function (_EventEmitter) {
|
|
|
1917
1979
|
|
|
1918
1980
|
_classCallCheck(this, Connector);
|
|
1919
1981
|
|
|
1920
|
-
_this =
|
|
1982
|
+
_this = _super.call(this);
|
|
1921
1983
|
|
|
1922
1984
|
if (isIE10) {
|
|
1923
1985
|
EventEmitter.call(_assertThisInitialized(_this));
|
|
@@ -2114,7 +2176,7 @@ var Connector = function (_EventEmitter) {
|
|
|
2114
2176
|
if (key === undefined || key === null || key === '') return;
|
|
2115
2177
|
|
|
2116
2178
|
if (this.backend && this.backend.create) {
|
|
2117
|
-
this.backend.create(languages, namespace, key, fallbackValue, null,
|
|
2179
|
+
this.backend.create(languages, namespace, key, fallbackValue, null, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
2118
2180
|
isUpdate: isUpdate
|
|
2119
2181
|
}));
|
|
2120
2182
|
}
|
|
@@ -2219,6 +2281,8 @@ function bindMemberFunctions(inst) {
|
|
|
2219
2281
|
var I18n = function (_EventEmitter) {
|
|
2220
2282
|
_inherits(I18n, _EventEmitter);
|
|
2221
2283
|
|
|
2284
|
+
var _super = _createSuper(I18n);
|
|
2285
|
+
|
|
2222
2286
|
function I18n() {
|
|
2223
2287
|
var _this;
|
|
2224
2288
|
|
|
@@ -2227,7 +2291,7 @@ var I18n = function (_EventEmitter) {
|
|
|
2227
2291
|
|
|
2228
2292
|
_classCallCheck(this, I18n);
|
|
2229
2293
|
|
|
2230
|
-
_this =
|
|
2294
|
+
_this = _super.call(this);
|
|
2231
2295
|
|
|
2232
2296
|
if (isIE10) {
|
|
2233
2297
|
EventEmitter.call(_assertThisInitialized(_this));
|
|
@@ -2278,7 +2342,7 @@ var I18n = function (_EventEmitter) {
|
|
|
2278
2342
|
}
|
|
2279
2343
|
|
|
2280
2344
|
var defOpts = get();
|
|
2281
|
-
this.options =
|
|
2345
|
+
this.options = _objectSpread2(_objectSpread2(_objectSpread2({}, defOpts), this.options), transformOptions(options));
|
|
2282
2346
|
|
|
2283
2347
|
if (options.keySeparator !== undefined) {
|
|
2284
2348
|
this.options.userDefinedKeySeparator = options.keySeparator;
|
|
@@ -2605,7 +2669,7 @@ var I18n = function (_EventEmitter) {
|
|
|
2605
2669
|
|
|
2606
2670
|
options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
|
2607
2671
|
} else {
|
|
2608
|
-
options =
|
|
2672
|
+
options = _objectSpread2({}, opts);
|
|
2609
2673
|
}
|
|
2610
2674
|
|
|
2611
2675
|
options.lng = options.lng || fixedT.lng;
|
|
@@ -2735,13 +2799,6 @@ var I18n = function (_EventEmitter) {
|
|
|
2735
2799
|
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'];
|
|
2736
2800
|
return rtlLngs.indexOf(this.services.languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
|
|
2737
2801
|
}
|
|
2738
|
-
}, {
|
|
2739
|
-
key: "createInstance",
|
|
2740
|
-
value: function createInstance() {
|
|
2741
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2742
|
-
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
2743
|
-
return new I18n(options, callback);
|
|
2744
|
-
}
|
|
2745
2802
|
}, {
|
|
2746
2803
|
key: "cloneInstance",
|
|
2747
2804
|
value: function cloneInstance() {
|
|
@@ -2750,7 +2807,7 @@ var I18n = function (_EventEmitter) {
|
|
|
2750
2807
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2751
2808
|
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
|
2752
2809
|
|
|
2753
|
-
var mergedOptions =
|
|
2810
|
+
var mergedOptions = _objectSpread2(_objectSpread2(_objectSpread2({}, this.options), options), {
|
|
2754
2811
|
isClone: true
|
|
2755
2812
|
});
|
|
2756
2813
|
|
|
@@ -2759,7 +2816,7 @@ var I18n = function (_EventEmitter) {
|
|
|
2759
2816
|
membersToCopy.forEach(function (m) {
|
|
2760
2817
|
clone[m] = _this8[m];
|
|
2761
2818
|
});
|
|
2762
|
-
clone.services =
|
|
2819
|
+
clone.services = _objectSpread2({}, this.services);
|
|
2763
2820
|
clone.services.utils = {
|
|
2764
2821
|
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
|
2765
2822
|
};
|
|
@@ -2794,6 +2851,28 @@ var I18n = function (_EventEmitter) {
|
|
|
2794
2851
|
return I18n;
|
|
2795
2852
|
}(EventEmitter);
|
|
2796
2853
|
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2854
|
+
_defineProperty(I18n, "createInstance", function () {
|
|
2855
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2856
|
+
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
2857
|
+
return new I18n(options, callback);
|
|
2858
|
+
});
|
|
2859
|
+
|
|
2860
|
+
var instance = I18n.createInstance();
|
|
2861
|
+
instance.createInstance = I18n.createInstance;
|
|
2862
|
+
|
|
2863
|
+
var createInstance = instance.createInstance;
|
|
2864
|
+
var init = instance.init;
|
|
2865
|
+
var loadResources = instance.loadResources;
|
|
2866
|
+
var reloadResources = instance.reloadResources;
|
|
2867
|
+
var use = instance.use;
|
|
2868
|
+
var changeLanguage = instance.changeLanguage;
|
|
2869
|
+
var getFixedT = instance.getFixedT;
|
|
2870
|
+
var t = instance.t;
|
|
2871
|
+
var exists = instance.exists;
|
|
2872
|
+
var setDefaultNamespace = instance.setDefaultNamespace;
|
|
2873
|
+
var hasLoadedNamespace = instance.hasLoadedNamespace;
|
|
2874
|
+
var loadNamespaces = instance.loadNamespaces;
|
|
2875
|
+
var loadLanguages = instance.loadLanguages;
|
|
2876
|
+
|
|
2877
|
+
export default instance;
|
|
2878
|
+
export { changeLanguage, createInstance, exists, getFixedT, hasLoadedNamespace, init, loadLanguages, loadNamespaces, loadResources, reloadResources, setDefaultNamespace, t, use };
|