@pie-lib/graphing-module 1.11.29 → 1.11.31
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/module/index.js +3220 -222
- package/module/manifest.json +7 -7
- package/package.json +1 -1
package/module/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {_dll_prop_types, _dll_pie_lib__render_ui, _dll_material_ui__core_styles, _dll_react, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug, _dll_material_ui__core, _dll_material_ui__core_styles_color_manipulator, _dll_material_ui__icons} from "../../shared-module@^1.6.
|
|
2
|
-
import {_dll_pie_lib__editable_html} from "../../editable-html-module@^3.7.
|
|
3
|
-
import {_dll_pie_lib__drag} from "../../drag-module@^2.1.
|
|
4
|
-
import {_dll_pie_lib__config_ui} from "../../config-module@^2.8.
|
|
1
|
+
import {_dll_prop_types, _dll_pie_lib__render_ui, _dll_material_ui__core_styles, _dll_react, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug, _dll_material_ui__core, _dll_material_ui__core_styles_color_manipulator, _dll_material_ui__icons} from "../../shared-module@^1.6.29/module/index.js";
|
|
2
|
+
import {_dll_pie_lib__editable_html} from "../../editable-html-module@^3.7.6/module/index.js";
|
|
3
|
+
import {_dll_pie_lib__drag} from "../../drag-module@^2.1.32/module/index.js";
|
|
4
|
+
import {_dll_pie_lib__config_ui} from "../../config-module@^2.8.16/module/index.js";
|
|
5
5
|
const PropTypes$E = _dll_prop_types;
|
|
6
6
|
const BaseDomainRangeType = {
|
|
7
7
|
min: PropTypes$E.number.isRequired,
|
|
@@ -4276,7 +4276,7 @@ function polymap(domain, range, interpolate) {
|
|
|
4276
4276
|
return r[i](d[i](x));
|
|
4277
4277
|
};
|
|
4278
4278
|
}
|
|
4279
|
-
function copy$
|
|
4279
|
+
function copy$2(source, target) {
|
|
4280
4280
|
return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown());
|
|
4281
4281
|
}
|
|
4282
4282
|
function transformer$2() {
|
|
@@ -4617,7 +4617,7 @@ function linearish(scale) {
|
|
|
4617
4617
|
function linear() {
|
|
4618
4618
|
var scale = continuous(identity$3, identity$3);
|
|
4619
4619
|
scale.copy = function () {
|
|
4620
|
-
return copy$
|
|
4620
|
+
return copy$2(scale, linear());
|
|
4621
4621
|
};
|
|
4622
4622
|
initRange.apply(scale, arguments);
|
|
4623
4623
|
return linearish(scale);
|
|
@@ -4752,7 +4752,7 @@ function loggish(transform) {
|
|
|
4752
4752
|
function log$8() {
|
|
4753
4753
|
var scale = loggish(transformer$2()).domain([1, 10]);
|
|
4754
4754
|
scale.copy = function () {
|
|
4755
|
-
return copy$
|
|
4755
|
+
return copy$2(scale, log$8()).base(scale.base());
|
|
4756
4756
|
};
|
|
4757
4757
|
initRange.apply(scale, arguments);
|
|
4758
4758
|
return scale;
|
|
@@ -4777,7 +4777,7 @@ function symlogish(transform) {
|
|
|
4777
4777
|
function symlog() {
|
|
4778
4778
|
var scale = symlogish(transformer$2());
|
|
4779
4779
|
scale.copy = function () {
|
|
4780
|
-
return copy$
|
|
4780
|
+
return copy$2(scale, symlog()).constant(scale.constant());
|
|
4781
4781
|
};
|
|
4782
4782
|
return initRange.apply(scale, arguments);
|
|
4783
4783
|
}
|
|
@@ -4805,7 +4805,7 @@ function powish(transform) {
|
|
|
4805
4805
|
function pow() {
|
|
4806
4806
|
var scale = powish(transformer$2());
|
|
4807
4807
|
scale.copy = function () {
|
|
4808
|
-
return copy$
|
|
4808
|
+
return copy$2(scale, pow()).exponent(scale.exponent());
|
|
4809
4809
|
};
|
|
4810
4810
|
initRange.apply(scale, arguments);
|
|
4811
4811
|
return scale;
|
|
@@ -5772,7 +5772,7 @@ function calendar(year, month, week, day, hour, minute, second, millisecond, for
|
|
|
5772
5772
|
return (interval = tickInterval(interval, d[0], d[d.length - 1], step)) ? domain(nice(d, interval)) : scale;
|
|
5773
5773
|
};
|
|
5774
5774
|
scale.copy = function () {
|
|
5775
|
-
return copy$
|
|
5775
|
+
return copy$2(scale, calendar(year, month, week, day, hour, minute, second, millisecond, format));
|
|
5776
5776
|
};
|
|
5777
5777
|
return scale;
|
|
5778
5778
|
}
|
|
@@ -5804,34 +5804,34 @@ function transformer$1() {
|
|
|
5804
5804
|
return scale;
|
|
5805
5805
|
};
|
|
5806
5806
|
}
|
|
5807
|
-
function copy(source, target) {
|
|
5807
|
+
function copy$1(source, target) {
|
|
5808
5808
|
return target.domain(source.domain()).interpolator(source.interpolator()).clamp(source.clamp()).unknown(source.unknown());
|
|
5809
5809
|
}
|
|
5810
5810
|
function sequential() {
|
|
5811
5811
|
var scale = linearish(transformer$1()(identity$3));
|
|
5812
5812
|
scale.copy = function () {
|
|
5813
|
-
return copy(scale, sequential());
|
|
5813
|
+
return copy$1(scale, sequential());
|
|
5814
5814
|
};
|
|
5815
5815
|
return initInterpolator.apply(scale, arguments);
|
|
5816
5816
|
}
|
|
5817
5817
|
function sequentialLog() {
|
|
5818
5818
|
var scale = loggish(transformer$1()).domain([1, 10]);
|
|
5819
5819
|
scale.copy = function () {
|
|
5820
|
-
return copy(scale, sequentialLog()).base(scale.base());
|
|
5820
|
+
return copy$1(scale, sequentialLog()).base(scale.base());
|
|
5821
5821
|
};
|
|
5822
5822
|
return initInterpolator.apply(scale, arguments);
|
|
5823
5823
|
}
|
|
5824
5824
|
function sequentialSymlog() {
|
|
5825
5825
|
var scale = symlogish(transformer$1());
|
|
5826
5826
|
scale.copy = function () {
|
|
5827
|
-
return copy(scale, sequentialSymlog()).constant(scale.constant());
|
|
5827
|
+
return copy$1(scale, sequentialSymlog()).constant(scale.constant());
|
|
5828
5828
|
};
|
|
5829
5829
|
return initInterpolator.apply(scale, arguments);
|
|
5830
5830
|
}
|
|
5831
5831
|
function sequentialPow() {
|
|
5832
5832
|
var scale = powish(transformer$1());
|
|
5833
5833
|
scale.copy = function () {
|
|
5834
|
-
return copy(scale, sequentialPow()).exponent(scale.exponent());
|
|
5834
|
+
return copy$1(scale, sequentialPow()).exponent(scale.exponent());
|
|
5835
5835
|
};
|
|
5836
5836
|
return initInterpolator.apply(scale, arguments);
|
|
5837
5837
|
}
|
|
@@ -5883,28 +5883,28 @@ function transformer() {
|
|
|
5883
5883
|
function diverging() {
|
|
5884
5884
|
var scale = linearish(transformer()(identity$3));
|
|
5885
5885
|
scale.copy = function () {
|
|
5886
|
-
return copy(scale, diverging());
|
|
5886
|
+
return copy$1(scale, diverging());
|
|
5887
5887
|
};
|
|
5888
5888
|
return initInterpolator.apply(scale, arguments);
|
|
5889
5889
|
}
|
|
5890
5890
|
function divergingLog() {
|
|
5891
5891
|
var scale = loggish(transformer()).domain([0.1, 1, 10]);
|
|
5892
5892
|
scale.copy = function () {
|
|
5893
|
-
return copy(scale, divergingLog()).base(scale.base());
|
|
5893
|
+
return copy$1(scale, divergingLog()).base(scale.base());
|
|
5894
5894
|
};
|
|
5895
5895
|
return initInterpolator.apply(scale, arguments);
|
|
5896
5896
|
}
|
|
5897
5897
|
function divergingSymlog() {
|
|
5898
5898
|
var scale = symlogish(transformer());
|
|
5899
5899
|
scale.copy = function () {
|
|
5900
|
-
return copy(scale, divergingSymlog()).constant(scale.constant());
|
|
5900
|
+
return copy$1(scale, divergingSymlog()).constant(scale.constant());
|
|
5901
5901
|
};
|
|
5902
5902
|
return initInterpolator.apply(scale, arguments);
|
|
5903
5903
|
}
|
|
5904
5904
|
function divergingPow() {
|
|
5905
5905
|
var scale = powish(transformer());
|
|
5906
5906
|
scale.copy = function () {
|
|
5907
|
-
return copy(scale, divergingPow()).exponent(scale.exponent());
|
|
5907
|
+
return copy$1(scale, divergingPow()).exponent(scale.exponent());
|
|
5908
5908
|
};
|
|
5909
5909
|
return initInterpolator.apply(scale, arguments);
|
|
5910
5910
|
}
|
|
@@ -6254,12 +6254,12 @@ Object.create(MonotoneX.prototype).point = function (x, y) {
|
|
|
6254
6254
|
function monotoneX(context) {
|
|
6255
6255
|
return new MonotoneX(context);
|
|
6256
6256
|
}
|
|
6257
|
-
function _classCallCheck$
|
|
6257
|
+
function _classCallCheck$3(instance, Constructor) {
|
|
6258
6258
|
if (!(instance instanceof Constructor)) {
|
|
6259
6259
|
throw new TypeError("Cannot call a class as a function");
|
|
6260
6260
|
}
|
|
6261
6261
|
}
|
|
6262
|
-
function _defineProperties$
|
|
6262
|
+
function _defineProperties$2(target, props) {
|
|
6263
6263
|
for (var i = 0; i < props.length; i++) {
|
|
6264
6264
|
var descriptor = props[i];
|
|
6265
6265
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -6268,19 +6268,19 @@ function _defineProperties$1(target, props) {
|
|
|
6268
6268
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
6269
6269
|
}
|
|
6270
6270
|
}
|
|
6271
|
-
function _createClass$
|
|
6272
|
-
if (protoProps) _defineProperties$
|
|
6273
|
-
if (staticProps) _defineProperties$
|
|
6271
|
+
function _createClass$3(Constructor, protoProps, staticProps) {
|
|
6272
|
+
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
6273
|
+
if (staticProps) _defineProperties$2(Constructor, staticProps);
|
|
6274
6274
|
return Constructor;
|
|
6275
6275
|
}
|
|
6276
6276
|
var Point$1 = (function () {
|
|
6277
6277
|
function Point(_ref) {
|
|
6278
6278
|
var _ref$x = _ref.x, x = _ref$x === void 0 ? 0 : _ref$x, _ref$y = _ref.y, y = _ref$y === void 0 ? 0 : _ref$y;
|
|
6279
|
-
_classCallCheck$
|
|
6279
|
+
_classCallCheck$3(this, Point);
|
|
6280
6280
|
this.x = x;
|
|
6281
6281
|
this.y = y;
|
|
6282
6282
|
}
|
|
6283
|
-
_createClass$
|
|
6283
|
+
_createClass$3(Point, [{
|
|
6284
6284
|
key: "value",
|
|
6285
6285
|
value: function value() {
|
|
6286
6286
|
return {
|
|
@@ -7620,12 +7620,12 @@ function getUnitsInExpression(expression) {
|
|
|
7620
7620
|
const PropTypes$y = _dll_prop_types;
|
|
7621
7621
|
const React$A = _dll_react;
|
|
7622
7622
|
const {Component: Component$a} = _dll_react;
|
|
7623
|
-
function _classCallCheck$
|
|
7623
|
+
function _classCallCheck$2(instance, Constructor) {
|
|
7624
7624
|
if (!(instance instanceof Constructor)) {
|
|
7625
7625
|
throw new TypeError("Cannot call a class as a function");
|
|
7626
7626
|
}
|
|
7627
7627
|
}
|
|
7628
|
-
function _defineProperties(target, props) {
|
|
7628
|
+
function _defineProperties$1(target, props) {
|
|
7629
7629
|
for (var i = 0; i < props.length; i++) {
|
|
7630
7630
|
var descriptor = props[i];
|
|
7631
7631
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -7634,9 +7634,9 @@ function _defineProperties(target, props) {
|
|
|
7634
7634
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
7635
7635
|
}
|
|
7636
7636
|
}
|
|
7637
|
-
function _createClass$
|
|
7638
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
7639
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
7637
|
+
function _createClass$2(Constructor, protoProps, staticProps) {
|
|
7638
|
+
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
7639
|
+
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
7640
7640
|
return Constructor;
|
|
7641
7641
|
}
|
|
7642
7642
|
function _extends$4() {
|
|
@@ -7653,7 +7653,7 @@ function _extends$4() {
|
|
|
7653
7653
|
});
|
|
7654
7654
|
return _extends$4.apply(this, arguments);
|
|
7655
7655
|
}
|
|
7656
|
-
function _inherits$
|
|
7656
|
+
function _inherits$2(subClass, superClass) {
|
|
7657
7657
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
7658
7658
|
throw new TypeError("Super expression must either be null or a function");
|
|
7659
7659
|
}
|
|
@@ -7664,20 +7664,20 @@ function _inherits$1(subClass, superClass) {
|
|
|
7664
7664
|
configurable: true
|
|
7665
7665
|
}
|
|
7666
7666
|
});
|
|
7667
|
-
if (superClass) _setPrototypeOf$
|
|
7667
|
+
if (superClass) _setPrototypeOf$2(subClass, superClass);
|
|
7668
7668
|
}
|
|
7669
|
-
function _getPrototypeOf(o) {
|
|
7670
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
7669
|
+
function _getPrototypeOf$1(o) {
|
|
7670
|
+
_getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
7671
7671
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
7672
7672
|
};
|
|
7673
|
-
return _getPrototypeOf(o);
|
|
7673
|
+
return _getPrototypeOf$1(o);
|
|
7674
7674
|
}
|
|
7675
|
-
function _setPrototypeOf$
|
|
7676
|
-
_setPrototypeOf$
|
|
7675
|
+
function _setPrototypeOf$2(o, p) {
|
|
7676
|
+
_setPrototypeOf$2 = Object.setPrototypeOf || (function _setPrototypeOf(o, p) {
|
|
7677
7677
|
o.__proto__ = p;
|
|
7678
7678
|
return o;
|
|
7679
7679
|
});
|
|
7680
|
-
return _setPrototypeOf$
|
|
7680
|
+
return _setPrototypeOf$2(o, p);
|
|
7681
7681
|
}
|
|
7682
7682
|
function _objectWithoutPropertiesLoose$2(source, excluded) {
|
|
7683
7683
|
if (source == null) return {};
|
|
@@ -7706,17 +7706,17 @@ function _objectWithoutProperties$2(source, excluded) {
|
|
|
7706
7706
|
}
|
|
7707
7707
|
return target;
|
|
7708
7708
|
}
|
|
7709
|
-
function _assertThisInitialized$
|
|
7709
|
+
function _assertThisInitialized$2(self) {
|
|
7710
7710
|
if (self === void 0) {
|
|
7711
7711
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
7712
7712
|
}
|
|
7713
7713
|
return self;
|
|
7714
7714
|
}
|
|
7715
|
-
function _possibleConstructorReturn$
|
|
7715
|
+
function _possibleConstructorReturn$2(self, call) {
|
|
7716
7716
|
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
7717
7717
|
return call;
|
|
7718
7718
|
}
|
|
7719
|
-
return _assertThisInitialized$
|
|
7719
|
+
return _assertThisInitialized$2(self);
|
|
7720
7720
|
}
|
|
7721
7721
|
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
7722
7722
|
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
@@ -8048,17 +8048,17 @@ var getStringWidth$1 = memoize_1(getStringWidth, function (str, style) {
|
|
|
8048
8048
|
return ("").concat(str, "_").concat(JSON.stringify(style));
|
|
8049
8049
|
});
|
|
8050
8050
|
var Text = (function (_Component) {
|
|
8051
|
-
_inherits$
|
|
8051
|
+
_inherits$2(Text, _Component);
|
|
8052
8052
|
function Text(props) {
|
|
8053
8053
|
var _this;
|
|
8054
|
-
_classCallCheck$
|
|
8055
|
-
_this = _possibleConstructorReturn$
|
|
8054
|
+
_classCallCheck$2(this, Text);
|
|
8055
|
+
_this = _possibleConstructorReturn$2(this, _getPrototypeOf$1(Text).call(this, props));
|
|
8056
8056
|
_this.state = {
|
|
8057
8057
|
wordsByLines: []
|
|
8058
8058
|
};
|
|
8059
8059
|
return _this;
|
|
8060
8060
|
}
|
|
8061
|
-
_createClass$
|
|
8061
|
+
_createClass$2(Text, [{
|
|
8062
8062
|
key: "componentWillMount",
|
|
8063
8063
|
value: function componentWillMount() {
|
|
8064
8064
|
this.updateWordsByLines(this.props, true);
|
|
@@ -8203,7 +8203,7 @@ Text.propTypes = {
|
|
|
8203
8203
|
const React$z = _dll_react;
|
|
8204
8204
|
const PropTypes$x = _dll_prop_types;
|
|
8205
8205
|
const cx$1 = _dll_classnames;
|
|
8206
|
-
function _defineProperty$
|
|
8206
|
+
function _defineProperty$2(obj, key, value) {
|
|
8207
8207
|
if ((key in obj)) {
|
|
8208
8208
|
Object.defineProperty(obj, key, {
|
|
8209
8209
|
value: value,
|
|
@@ -8230,7 +8230,7 @@ function _extends$3() {
|
|
|
8230
8230
|
});
|
|
8231
8231
|
return _extends$3.apply(this, arguments);
|
|
8232
8232
|
}
|
|
8233
|
-
function _objectSpread(target) {
|
|
8233
|
+
function _objectSpread$7(target) {
|
|
8234
8234
|
for (var i = 1; i < arguments.length; i++) {
|
|
8235
8235
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
8236
8236
|
var ownKeys = Object.keys(source);
|
|
@@ -8240,7 +8240,7 @@ function _objectSpread(target) {
|
|
|
8240
8240
|
}));
|
|
8241
8241
|
}
|
|
8242
8242
|
ownKeys.forEach(function (key) {
|
|
8243
|
-
_defineProperty$
|
|
8243
|
+
_defineProperty$2(target, key, source[key]);
|
|
8244
8244
|
});
|
|
8245
8245
|
}
|
|
8246
8246
|
return target;
|
|
@@ -8404,7 +8404,7 @@ function Axis(_ref) {
|
|
|
8404
8404
|
from: tickFromPoint,
|
|
8405
8405
|
to: tickToPoint,
|
|
8406
8406
|
stroke: tickStroke
|
|
8407
|
-
}), tickComponent ? tickComponent(_objectSpread({
|
|
8407
|
+
}), tickComponent ? tickComponent(_objectSpread$7({
|
|
8408
8408
|
x: tickToPoint.x,
|
|
8409
8409
|
y: tickToPoint.y + (horizontal && !isTop ? tickLabelFontSize : 0),
|
|
8410
8410
|
formattedValue: format(val, index)
|
|
@@ -9988,17 +9988,17 @@ class Graph extends React$s.Component {
|
|
|
9988
9988
|
}
|
|
9989
9989
|
Graph.__initStatic();
|
|
9990
9990
|
Graph.__initStatic2();
|
|
9991
|
-
function _setPrototypeOf(o, p) {
|
|
9992
|
-
_setPrototypeOf = Object.setPrototypeOf || (function _setPrototypeOf(o, p) {
|
|
9991
|
+
function _setPrototypeOf$1(o, p) {
|
|
9992
|
+
_setPrototypeOf$1 = Object.setPrototypeOf || (function _setPrototypeOf(o, p) {
|
|
9993
9993
|
o.__proto__ = p;
|
|
9994
9994
|
return o;
|
|
9995
9995
|
});
|
|
9996
|
-
return _setPrototypeOf(o, p);
|
|
9996
|
+
return _setPrototypeOf$1(o, p);
|
|
9997
9997
|
}
|
|
9998
9998
|
function _inheritsLoose(subClass, superClass) {
|
|
9999
9999
|
subClass.prototype = Object.create(superClass.prototype);
|
|
10000
10000
|
subClass.prototype.constructor = subClass;
|
|
10001
|
-
_setPrototypeOf(subClass, superClass);
|
|
10001
|
+
_setPrototypeOf$1(subClass, superClass);
|
|
10002
10002
|
}
|
|
10003
10003
|
const React$r = _dll_react;
|
|
10004
10004
|
var ReactReduxContext = React$r.createContext(null);
|
|
@@ -10073,7 +10073,7 @@ Provider.propTypes = {
|
|
|
10073
10073
|
context: PropTypes$p.object,
|
|
10074
10074
|
children: PropTypes$p.any
|
|
10075
10075
|
};
|
|
10076
|
-
function _assertThisInitialized(self) {
|
|
10076
|
+
function _assertThisInitialized$1(self) {
|
|
10077
10077
|
if (self === void 0) {
|
|
10078
10078
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
10079
10079
|
}
|
|
@@ -10426,7 +10426,7 @@ function connectAdvanced(selectorFactory, _ref) {
|
|
|
10426
10426
|
browser(forwardRef ? !props.wrapperProps[storeKey] : !props[storeKey], 'Passing redux store in props has been removed and does not do anything. ' + customStoreWarningMessage);
|
|
10427
10427
|
_this.selectDerivedProps = makeDerivedPropsSelector();
|
|
10428
10428
|
_this.selectChildElement = makeChildElementSelector();
|
|
10429
|
-
_this.indirectRenderWrappedComponent = _this.indirectRenderWrappedComponent.bind(_assertThisInitialized(_this));
|
|
10429
|
+
_this.indirectRenderWrappedComponent = _this.indirectRenderWrappedComponent.bind(_assertThisInitialized$1(_this));
|
|
10430
10430
|
return _this;
|
|
10431
10431
|
}
|
|
10432
10432
|
var _proto = Connect.prototype;
|
|
@@ -10490,7 +10490,7 @@ function shallowEqual(objA, objB) {
|
|
|
10490
10490
|
}
|
|
10491
10491
|
return true;
|
|
10492
10492
|
}
|
|
10493
|
-
function _defineProperty(obj, key, value) {
|
|
10493
|
+
function _defineProperty$1(obj, key, value) {
|
|
10494
10494
|
if ((key in obj)) {
|
|
10495
10495
|
Object.defineProperty(obj, key, {
|
|
10496
10496
|
value: value,
|
|
@@ -10503,7 +10503,7 @@ function _defineProperty(obj, key, value) {
|
|
|
10503
10503
|
}
|
|
10504
10504
|
return obj;
|
|
10505
10505
|
}
|
|
10506
|
-
function ownKeys(object, enumerableOnly) {
|
|
10506
|
+
function ownKeys$7(object, enumerableOnly) {
|
|
10507
10507
|
var keys = Object.keys(object);
|
|
10508
10508
|
if (Object.getOwnPropertySymbols) {
|
|
10509
10509
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
@@ -10516,9 +10516,9 @@ function ownKeys(object, enumerableOnly) {
|
|
|
10516
10516
|
function _objectSpread2(target) {
|
|
10517
10517
|
for (var i = 1; i < arguments.length; i++) {
|
|
10518
10518
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
10519
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
10520
|
-
_defineProperty(target, key, source[key]);
|
|
10521
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
10519
|
+
i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) {
|
|
10520
|
+
_defineProperty$1(target, key, source[key]);
|
|
10521
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) {
|
|
10522
10522
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
10523
10523
|
});
|
|
10524
10524
|
}
|
|
@@ -12066,7 +12066,7 @@ var _extends = Object.assign || (function (target) {
|
|
|
12066
12066
|
}
|
|
12067
12067
|
return target;
|
|
12068
12068
|
});
|
|
12069
|
-
var _createClass = (function () {
|
|
12069
|
+
var _createClass$1 = (function () {
|
|
12070
12070
|
function defineProperties(target, props) {
|
|
12071
12071
|
for (var i = 0; i < props.length; i++) {
|
|
12072
12072
|
var descriptor = props[i];
|
|
@@ -12100,18 +12100,18 @@ function _objectWithoutProperties(obj, keys) {
|
|
|
12100
12100
|
}
|
|
12101
12101
|
return target;
|
|
12102
12102
|
}
|
|
12103
|
-
function _classCallCheck(instance, Constructor) {
|
|
12103
|
+
function _classCallCheck$1(instance, Constructor) {
|
|
12104
12104
|
if (!(instance instanceof Constructor)) {
|
|
12105
12105
|
throw new TypeError("Cannot call a class as a function");
|
|
12106
12106
|
}
|
|
12107
12107
|
}
|
|
12108
|
-
function _possibleConstructorReturn(self, call) {
|
|
12108
|
+
function _possibleConstructorReturn$1(self, call) {
|
|
12109
12109
|
if (!self) {
|
|
12110
12110
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
12111
12111
|
}
|
|
12112
12112
|
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
|
12113
12113
|
}
|
|
12114
|
-
function _inherits(subClass, superClass) {
|
|
12114
|
+
function _inherits$1(subClass, superClass) {
|
|
12115
12115
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
12116
12116
|
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
|
12117
12117
|
}
|
|
@@ -12154,10 +12154,10 @@ var generateId = function generateId() {
|
|
|
12154
12154
|
return isIE ? '_' + Math.random().toString(36).substr(2, 12) : undefined;
|
|
12155
12155
|
};
|
|
12156
12156
|
var AutosizeInput = (function (_Component) {
|
|
12157
|
-
_inherits(AutosizeInput, _Component);
|
|
12157
|
+
_inherits$1(AutosizeInput, _Component);
|
|
12158
12158
|
function AutosizeInput(props) {
|
|
12159
|
-
_classCallCheck(this, AutosizeInput);
|
|
12160
|
-
var _this = _possibleConstructorReturn(this, (AutosizeInput.__proto__ || Object.getPrototypeOf(AutosizeInput)).call(this, props));
|
|
12159
|
+
_classCallCheck$1(this, AutosizeInput);
|
|
12160
|
+
var _this = _possibleConstructorReturn$1(this, (AutosizeInput.__proto__ || Object.getPrototypeOf(AutosizeInput)).call(this, props));
|
|
12161
12161
|
_this.inputRef = function (el) {
|
|
12162
12162
|
_this.input = el;
|
|
12163
12163
|
if (typeof _this.props.inputRef === 'function') {
|
|
@@ -12176,7 +12176,7 @@ var AutosizeInput = (function (_Component) {
|
|
|
12176
12176
|
};
|
|
12177
12177
|
return _this;
|
|
12178
12178
|
}
|
|
12179
|
-
_createClass(AutosizeInput, [{
|
|
12179
|
+
_createClass$1(AutosizeInput, [{
|
|
12180
12180
|
key: 'componentDidMount',
|
|
12181
12181
|
value: function componentDidMount() {
|
|
12182
12182
|
this.mounted = true;
|
|
@@ -14836,138 +14836,3122 @@ var index$1 = Object.freeze({
|
|
|
14836
14836
|
sine: tool$5,
|
|
14837
14837
|
vector: tool
|
|
14838
14838
|
});
|
|
14839
|
-
|
|
14840
|
-
|
|
14841
|
-
|
|
14842
|
-
|
|
14843
|
-
|
|
14844
|
-
|
|
14845
|
-
|
|
14846
|
-
|
|
14847
|
-
|
|
14848
|
-
|
|
14849
|
-
|
|
14850
|
-
let lastAccessLHS = undefined;
|
|
14851
|
-
let value = ops[0];
|
|
14852
|
-
let i = 1;
|
|
14853
|
-
while (i < ops.length) {
|
|
14854
|
-
const op = ops[i];
|
|
14855
|
-
const fn = ops[i + 1];
|
|
14856
|
-
i += 2;
|
|
14857
|
-
if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
|
|
14858
|
-
return undefined;
|
|
14859
|
-
}
|
|
14860
|
-
if (op === 'access' || op === 'optionalAccess') {
|
|
14861
|
-
lastAccessLHS = value;
|
|
14862
|
-
value = fn(value);
|
|
14863
|
-
} else if (op === 'call' || op === 'optionalCall') {
|
|
14864
|
-
value = fn((...args) => value.call(lastAccessLHS, ...args));
|
|
14865
|
-
lastAccessLHS = undefined;
|
|
14866
|
-
}
|
|
14839
|
+
function _typeof(obj) {
|
|
14840
|
+
"@babel/helpers - typeof";
|
|
14841
|
+
return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
14842
|
+
return typeof obj;
|
|
14843
|
+
} : function (obj) {
|
|
14844
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
14845
|
+
}, _typeof(obj));
|
|
14846
|
+
}
|
|
14847
|
+
function _classCallCheck(instance, Constructor) {
|
|
14848
|
+
if (!(instance instanceof Constructor)) {
|
|
14849
|
+
throw new TypeError("Cannot call a class as a function");
|
|
14867
14850
|
}
|
|
14868
|
-
return value;
|
|
14869
14851
|
}
|
|
14870
|
-
|
|
14871
|
-
|
|
14872
|
-
|
|
14873
|
-
|
|
14874
|
-
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
selected: {
|
|
14878
|
-
backgroundColor: color$3.background(),
|
|
14879
|
-
border: `1px solid ${color$3.secondary()}`
|
|
14880
|
-
},
|
|
14881
|
-
notSelected: {
|
|
14882
|
-
'& span': {
|
|
14883
|
-
color: color$3.primary()
|
|
14884
|
-
},
|
|
14885
|
-
backgroundColor: color$3.background()
|
|
14886
|
-
},
|
|
14887
|
-
disabled: {
|
|
14888
|
-
'& span': {
|
|
14889
|
-
color: color$3.primary()
|
|
14890
|
-
},
|
|
14891
|
-
backgroundColor: color$3.disabled()
|
|
14852
|
+
function _toPrimitive(input, hint) {
|
|
14853
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
14854
|
+
var prim = input[Symbol.toPrimitive];
|
|
14855
|
+
if (prim !== undefined) {
|
|
14856
|
+
var res = prim.call(input, hint || "default");
|
|
14857
|
+
if (_typeof(res) !== "object") return res;
|
|
14858
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
14892
14859
|
}
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
|
|
14897
|
-
|
|
14898
|
-
|
|
14899
|
-
|
|
14900
|
-
|
|
14901
|
-
|
|
14902
|
-
|
|
14903
|
-
|
|
14904
|
-
|
|
14905
|
-
|
|
14906
|
-
|
|
14907
|
-
|
|
14908
|
-
|
|
14909
|
-
|
|
14910
|
-
|
|
14860
|
+
return (hint === "string" ? String : Number)(input);
|
|
14861
|
+
}
|
|
14862
|
+
function _toPropertyKey(arg) {
|
|
14863
|
+
var key = _toPrimitive(arg, "string");
|
|
14864
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
14865
|
+
}
|
|
14866
|
+
function _defineProperties(target, props) {
|
|
14867
|
+
for (var i = 0; i < props.length; i++) {
|
|
14868
|
+
var descriptor = props[i];
|
|
14869
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
14870
|
+
descriptor.configurable = true;
|
|
14871
|
+
if (("value" in descriptor)) descriptor.writable = true;
|
|
14872
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
14873
|
+
}
|
|
14874
|
+
}
|
|
14875
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
14876
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
14877
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
14878
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
14879
|
+
writable: false
|
|
14880
|
+
});
|
|
14881
|
+
return Constructor;
|
|
14882
|
+
}
|
|
14883
|
+
function _assertThisInitialized(self) {
|
|
14884
|
+
if (self === void 0) {
|
|
14885
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
14886
|
+
}
|
|
14887
|
+
return self;
|
|
14888
|
+
}
|
|
14889
|
+
function _setPrototypeOf(o, p) {
|
|
14890
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
14891
|
+
o.__proto__ = p;
|
|
14892
|
+
return o;
|
|
14893
|
+
};
|
|
14894
|
+
return _setPrototypeOf(o, p);
|
|
14895
|
+
}
|
|
14896
|
+
function _inherits(subClass, superClass) {
|
|
14897
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
14898
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
14899
|
+
}
|
|
14900
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
14901
|
+
constructor: {
|
|
14902
|
+
value: subClass,
|
|
14903
|
+
writable: true,
|
|
14904
|
+
configurable: true
|
|
14911
14905
|
}
|
|
14912
|
-
}
|
|
14913
|
-
|
|
14914
|
-
|
|
14915
|
-
|
|
14916
|
-
|
|
14917
|
-
|
|
14918
|
-
|
|
14919
|
-
|
|
14920
|
-
|
|
14921
|
-
|
|
14922
|
-
|
|
14923
|
-
class ToggleBar extends React$5.Component {
|
|
14924
|
-
constructor(...args) {
|
|
14925
|
-
super(...args);
|
|
14926
|
-
ToggleBar.prototype.__init.call(this);
|
|
14927
|
-
ToggleBar.prototype.__init2.call(this);
|
|
14906
|
+
});
|
|
14907
|
+
Object.defineProperty(subClass, "prototype", {
|
|
14908
|
+
writable: false
|
|
14909
|
+
});
|
|
14910
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
14911
|
+
}
|
|
14912
|
+
function _possibleConstructorReturn(self, call) {
|
|
14913
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
14914
|
+
return call;
|
|
14915
|
+
} else if (call !== void 0) {
|
|
14916
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
14928
14917
|
}
|
|
14929
|
-
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
|
|
14933
|
-
|
|
14934
|
-
|
|
14935
|
-
|
|
14936
|
-
|
|
14937
|
-
|
|
14938
|
-
|
|
14939
|
-
|
|
14918
|
+
return _assertThisInitialized(self);
|
|
14919
|
+
}
|
|
14920
|
+
function _getPrototypeOf(o) {
|
|
14921
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
14922
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
14923
|
+
};
|
|
14924
|
+
return _getPrototypeOf(o);
|
|
14925
|
+
}
|
|
14926
|
+
function _defineProperty(obj, key, value) {
|
|
14927
|
+
key = _toPropertyKey(key);
|
|
14928
|
+
if ((key in obj)) {
|
|
14929
|
+
Object.defineProperty(obj, key, {
|
|
14930
|
+
value: value,
|
|
14931
|
+
enumerable: true,
|
|
14932
|
+
configurable: true,
|
|
14933
|
+
writable: true
|
|
14934
|
+
});
|
|
14935
|
+
} else {
|
|
14936
|
+
obj[key] = value;
|
|
14940
14937
|
}
|
|
14941
|
-
|
|
14942
|
-
|
|
14938
|
+
return obj;
|
|
14939
|
+
}
|
|
14940
|
+
function _arrayWithHoles(arr) {
|
|
14941
|
+
if (Array.isArray(arr)) return arr;
|
|
14942
|
+
}
|
|
14943
|
+
function _iterableToArray(iter) {
|
|
14944
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
14945
|
+
}
|
|
14946
|
+
function _arrayLikeToArray(arr, len) {
|
|
14947
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
14948
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
14949
|
+
return arr2;
|
|
14950
|
+
}
|
|
14951
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
14952
|
+
if (!o) return;
|
|
14953
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
14954
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
14955
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
14956
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
14957
|
+
if (n === "Arguments" || (/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/).test(n)) return _arrayLikeToArray(o, minLen);
|
|
14958
|
+
}
|
|
14959
|
+
function _nonIterableRest() {
|
|
14960
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
14961
|
+
}
|
|
14962
|
+
function _toArray(arr) {
|
|
14963
|
+
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
|
|
14964
|
+
}
|
|
14965
|
+
function ownKeys$6(object, enumerableOnly) {
|
|
14966
|
+
var keys = Object.keys(object);
|
|
14967
|
+
if (Object.getOwnPropertySymbols) {
|
|
14968
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
14969
|
+
(enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
14970
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
14971
|
+
})), keys.push.apply(keys, symbols));
|
|
14943
14972
|
}
|
|
14944
|
-
|
|
14945
|
-
|
|
14973
|
+
return keys;
|
|
14974
|
+
}
|
|
14975
|
+
function _objectSpread$6(target) {
|
|
14976
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
14977
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
14978
|
+
i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) {
|
|
14979
|
+
_defineProperty(target, key, source[key]);
|
|
14980
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) {
|
|
14981
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
14982
|
+
});
|
|
14946
14983
|
}
|
|
14947
|
-
|
|
14948
|
-
|
|
14949
|
-
|
|
14950
|
-
|
|
14951
|
-
|
|
14952
|
-
|
|
14953
|
-
|
|
14954
|
-
|
|
14984
|
+
return target;
|
|
14985
|
+
}
|
|
14986
|
+
var consoleLogger = {
|
|
14987
|
+
type: 'logger',
|
|
14988
|
+
log: function log(args) {
|
|
14989
|
+
this.output('log', args);
|
|
14990
|
+
},
|
|
14991
|
+
warn: function warn(args) {
|
|
14992
|
+
this.output('warn', args);
|
|
14993
|
+
},
|
|
14994
|
+
error: function error(args) {
|
|
14995
|
+
this.output('error', args);
|
|
14996
|
+
},
|
|
14997
|
+
output: function output(type, args) {
|
|
14998
|
+
if (console && console[type]) console[type].apply(console, args);
|
|
14955
14999
|
}
|
|
14956
|
-
|
|
14957
|
-
|
|
14958
|
-
|
|
14959
|
-
|
|
14960
|
-
|
|
14961
|
-
|
|
14962
|
-
|
|
14963
|
-
|
|
15000
|
+
};
|
|
15001
|
+
var Logger = (function () {
|
|
15002
|
+
function Logger(concreteLogger) {
|
|
15003
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
15004
|
+
_classCallCheck(this, Logger);
|
|
15005
|
+
this.init(concreteLogger, options);
|
|
15006
|
+
}
|
|
15007
|
+
_createClass(Logger, [{
|
|
15008
|
+
key: "init",
|
|
15009
|
+
value: function init(concreteLogger) {
|
|
15010
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
15011
|
+
this.prefix = options.prefix || 'i18next:';
|
|
15012
|
+
this.logger = concreteLogger || consoleLogger;
|
|
15013
|
+
this.options = options;
|
|
15014
|
+
this.debug = options.debug;
|
|
15015
|
+
}
|
|
15016
|
+
}, {
|
|
15017
|
+
key: "setDebug",
|
|
15018
|
+
value: function setDebug(bool) {
|
|
15019
|
+
this.debug = bool;
|
|
15020
|
+
}
|
|
15021
|
+
}, {
|
|
15022
|
+
key: "log",
|
|
15023
|
+
value: function log() {
|
|
15024
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15025
|
+
args[_key] = arguments[_key];
|
|
14964
15026
|
}
|
|
14965
|
-
|
|
14966
|
-
|
|
14967
|
-
|
|
14968
|
-
|
|
14969
|
-
|
|
14970
|
-
|
|
15027
|
+
return this.forward(args, 'log', '', true);
|
|
15028
|
+
}
|
|
15029
|
+
}, {
|
|
15030
|
+
key: "warn",
|
|
15031
|
+
value: function warn() {
|
|
15032
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
15033
|
+
args[_key2] = arguments[_key2];
|
|
15034
|
+
}
|
|
15035
|
+
return this.forward(args, 'warn', '', true);
|
|
15036
|
+
}
|
|
15037
|
+
}, {
|
|
15038
|
+
key: "error",
|
|
15039
|
+
value: function error() {
|
|
15040
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
15041
|
+
args[_key3] = arguments[_key3];
|
|
15042
|
+
}
|
|
15043
|
+
return this.forward(args, 'error', '');
|
|
15044
|
+
}
|
|
15045
|
+
}, {
|
|
15046
|
+
key: "deprecate",
|
|
15047
|
+
value: function deprecate() {
|
|
15048
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
15049
|
+
args[_key4] = arguments[_key4];
|
|
15050
|
+
}
|
|
15051
|
+
return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
|
|
15052
|
+
}
|
|
15053
|
+
}, {
|
|
15054
|
+
key: "forward",
|
|
15055
|
+
value: function forward(args, lvl, prefix, debugOnly) {
|
|
15056
|
+
if (debugOnly && !this.debug) return null;
|
|
15057
|
+
if (typeof args[0] === 'string') args[0] = ("").concat(prefix).concat(this.prefix, " ").concat(args[0]);
|
|
15058
|
+
return this.logger[lvl](args);
|
|
15059
|
+
}
|
|
15060
|
+
}, {
|
|
15061
|
+
key: "create",
|
|
15062
|
+
value: function create(moduleName) {
|
|
15063
|
+
return new Logger(this.logger, _objectSpread$6(_objectSpread$6({}, {
|
|
15064
|
+
prefix: ("").concat(this.prefix, ":").concat(moduleName, ":")
|
|
15065
|
+
}), this.options));
|
|
15066
|
+
}
|
|
15067
|
+
}, {
|
|
15068
|
+
key: "clone",
|
|
15069
|
+
value: function clone(options) {
|
|
15070
|
+
options = options || this.options;
|
|
15071
|
+
options.prefix = options.prefix || this.prefix;
|
|
15072
|
+
return new Logger(this.logger, options);
|
|
15073
|
+
}
|
|
15074
|
+
}]);
|
|
15075
|
+
return Logger;
|
|
15076
|
+
})();
|
|
15077
|
+
var baseLogger = new Logger();
|
|
15078
|
+
var EventEmitter = (function () {
|
|
15079
|
+
function EventEmitter() {
|
|
15080
|
+
_classCallCheck(this, EventEmitter);
|
|
15081
|
+
this.observers = {};
|
|
15082
|
+
}
|
|
15083
|
+
_createClass(EventEmitter, [{
|
|
15084
|
+
key: "on",
|
|
15085
|
+
value: function on(events, listener) {
|
|
15086
|
+
var _this = this;
|
|
15087
|
+
events.split(' ').forEach(function (event) {
|
|
15088
|
+
_this.observers[event] = _this.observers[event] || [];
|
|
15089
|
+
_this.observers[event].push(listener);
|
|
15090
|
+
});
|
|
15091
|
+
return this;
|
|
15092
|
+
}
|
|
15093
|
+
}, {
|
|
15094
|
+
key: "off",
|
|
15095
|
+
value: function off(event, listener) {
|
|
15096
|
+
if (!this.observers[event]) return;
|
|
15097
|
+
if (!listener) {
|
|
15098
|
+
delete this.observers[event];
|
|
15099
|
+
return;
|
|
15100
|
+
}
|
|
15101
|
+
this.observers[event] = this.observers[event].filter(function (l) {
|
|
15102
|
+
return l !== listener;
|
|
15103
|
+
});
|
|
15104
|
+
}
|
|
15105
|
+
}, {
|
|
15106
|
+
key: "emit",
|
|
15107
|
+
value: function emit(event) {
|
|
15108
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
15109
|
+
args[_key - 1] = arguments[_key];
|
|
15110
|
+
}
|
|
15111
|
+
if (this.observers[event]) {
|
|
15112
|
+
var cloned = [].concat(this.observers[event]);
|
|
15113
|
+
cloned.forEach(function (observer) {
|
|
15114
|
+
observer.apply(void 0, args);
|
|
15115
|
+
});
|
|
15116
|
+
}
|
|
15117
|
+
if (this.observers['*']) {
|
|
15118
|
+
var _cloned = [].concat(this.observers['*']);
|
|
15119
|
+
_cloned.forEach(function (observer) {
|
|
15120
|
+
observer.apply(observer, [event].concat(args));
|
|
15121
|
+
});
|
|
15122
|
+
}
|
|
15123
|
+
}
|
|
15124
|
+
}]);
|
|
15125
|
+
return EventEmitter;
|
|
15126
|
+
})();
|
|
15127
|
+
function defer() {
|
|
15128
|
+
var res;
|
|
15129
|
+
var rej;
|
|
15130
|
+
var promise = new Promise(function (resolve, reject) {
|
|
15131
|
+
res = resolve;
|
|
15132
|
+
rej = reject;
|
|
15133
|
+
});
|
|
15134
|
+
promise.resolve = res;
|
|
15135
|
+
promise.reject = rej;
|
|
15136
|
+
return promise;
|
|
15137
|
+
}
|
|
15138
|
+
function makeString(object) {
|
|
15139
|
+
if (object == null) return '';
|
|
15140
|
+
return '' + object;
|
|
15141
|
+
}
|
|
15142
|
+
function copy(a, s, t) {
|
|
15143
|
+
a.forEach(function (m) {
|
|
15144
|
+
if (s[m]) t[m] = s[m];
|
|
15145
|
+
});
|
|
15146
|
+
}
|
|
15147
|
+
function getLastOfPath(object, path, Empty) {
|
|
15148
|
+
function cleanKey(key) {
|
|
15149
|
+
return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
|
|
15150
|
+
}
|
|
15151
|
+
function canNotTraverseDeeper() {
|
|
15152
|
+
return !object || typeof object === 'string';
|
|
15153
|
+
}
|
|
15154
|
+
var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
|
|
15155
|
+
while (stack.length > 1) {
|
|
15156
|
+
if (canNotTraverseDeeper()) return {};
|
|
15157
|
+
var key = cleanKey(stack.shift());
|
|
15158
|
+
if (!object[key] && Empty) object[key] = new Empty();
|
|
15159
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
15160
|
+
object = object[key];
|
|
15161
|
+
} else {
|
|
15162
|
+
object = {};
|
|
15163
|
+
}
|
|
15164
|
+
}
|
|
15165
|
+
if (canNotTraverseDeeper()) return {};
|
|
15166
|
+
return {
|
|
15167
|
+
obj: object,
|
|
15168
|
+
k: cleanKey(stack.shift())
|
|
15169
|
+
};
|
|
15170
|
+
}
|
|
15171
|
+
function setPath(object, path, newValue) {
|
|
15172
|
+
var _getLastOfPath = getLastOfPath(object, path, Object), obj = _getLastOfPath.obj, k = _getLastOfPath.k;
|
|
15173
|
+
obj[k] = newValue;
|
|
15174
|
+
}
|
|
15175
|
+
function pushPath(object, path, newValue, concat) {
|
|
15176
|
+
var _getLastOfPath2 = getLastOfPath(object, path, Object), obj = _getLastOfPath2.obj, k = _getLastOfPath2.k;
|
|
15177
|
+
obj[k] = obj[k] || [];
|
|
15178
|
+
if (concat) obj[k] = obj[k].concat(newValue);
|
|
15179
|
+
if (!concat) obj[k].push(newValue);
|
|
15180
|
+
}
|
|
15181
|
+
function getPath(object, path) {
|
|
15182
|
+
var _getLastOfPath3 = getLastOfPath(object, path), obj = _getLastOfPath3.obj, k = _getLastOfPath3.k;
|
|
15183
|
+
if (!obj) return undefined;
|
|
15184
|
+
return obj[k];
|
|
15185
|
+
}
|
|
15186
|
+
function getPathWithDefaults(data, defaultData, key) {
|
|
15187
|
+
var value = getPath(data, key);
|
|
15188
|
+
if (value !== undefined) {
|
|
15189
|
+
return value;
|
|
15190
|
+
}
|
|
15191
|
+
return getPath(defaultData, key);
|
|
15192
|
+
}
|
|
15193
|
+
function deepExtend(target, source, overwrite) {
|
|
15194
|
+
for (var prop in source) {
|
|
15195
|
+
if (prop !== '__proto__' && prop !== 'constructor') {
|
|
15196
|
+
if ((prop in target)) {
|
|
15197
|
+
if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
|
|
15198
|
+
if (overwrite) target[prop] = source[prop];
|
|
15199
|
+
} else {
|
|
15200
|
+
deepExtend(target[prop], source[prop], overwrite);
|
|
15201
|
+
}
|
|
15202
|
+
} else {
|
|
15203
|
+
target[prop] = source[prop];
|
|
15204
|
+
}
|
|
15205
|
+
}
|
|
15206
|
+
}
|
|
15207
|
+
return target;
|
|
15208
|
+
}
|
|
15209
|
+
function regexEscape(str) {
|
|
15210
|
+
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
|
15211
|
+
}
|
|
15212
|
+
var _entityMap = {
|
|
15213
|
+
'&': '&',
|
|
15214
|
+
'<': '<',
|
|
15215
|
+
'>': '>',
|
|
15216
|
+
'"': '"',
|
|
15217
|
+
"'": ''',
|
|
15218
|
+
'/': '/'
|
|
15219
|
+
};
|
|
15220
|
+
function escape(data) {
|
|
15221
|
+
if (typeof data === 'string') {
|
|
15222
|
+
return data.replace(/[&<>"'\/]/g, function (s) {
|
|
15223
|
+
return _entityMap[s];
|
|
15224
|
+
});
|
|
15225
|
+
}
|
|
15226
|
+
return data;
|
|
15227
|
+
}
|
|
15228
|
+
var isIE10 = typeof window !== 'undefined' && window.navigator && typeof window.navigator.userAgentData === 'undefined' && window.navigator.userAgent && window.navigator.userAgent.indexOf('MSIE') > -1;
|
|
15229
|
+
var chars = [' ', ',', '?', '!', ';'];
|
|
15230
|
+
function looksLikeObjectPath(key, nsSeparator, keySeparator) {
|
|
15231
|
+
nsSeparator = nsSeparator || '';
|
|
15232
|
+
keySeparator = keySeparator || '';
|
|
15233
|
+
var possibleChars = chars.filter(function (c) {
|
|
15234
|
+
return nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0;
|
|
15235
|
+
});
|
|
15236
|
+
if (possibleChars.length === 0) return true;
|
|
15237
|
+
var r = new RegExp(("(").concat(possibleChars.map(function (c) {
|
|
15238
|
+
return c === '?' ? '\\?' : c;
|
|
15239
|
+
}).join('|'), ")"));
|
|
15240
|
+
var matched = !r.test(key);
|
|
15241
|
+
if (!matched) {
|
|
15242
|
+
var ki = key.indexOf(keySeparator);
|
|
15243
|
+
if (ki > 0 && !r.test(key.substring(0, ki))) {
|
|
15244
|
+
matched = true;
|
|
15245
|
+
}
|
|
15246
|
+
}
|
|
15247
|
+
return matched;
|
|
15248
|
+
}
|
|
15249
|
+
function deepFind(obj, path) {
|
|
15250
|
+
var keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
|
|
15251
|
+
if (!obj) return undefined;
|
|
15252
|
+
if (obj[path]) return obj[path];
|
|
15253
|
+
var paths = path.split(keySeparator);
|
|
15254
|
+
var current = obj;
|
|
15255
|
+
for (var i = 0; i < paths.length; ++i) {
|
|
15256
|
+
if (!current) return undefined;
|
|
15257
|
+
if (typeof current[paths[i]] === 'string' && i + 1 < paths.length) {
|
|
15258
|
+
return undefined;
|
|
15259
|
+
}
|
|
15260
|
+
if (current[paths[i]] === undefined) {
|
|
15261
|
+
var j = 2;
|
|
15262
|
+
var p = paths.slice(i, i + j).join(keySeparator);
|
|
15263
|
+
var mix = current[p];
|
|
15264
|
+
while (mix === undefined && paths.length > i + j) {
|
|
15265
|
+
j++;
|
|
15266
|
+
p = paths.slice(i, i + j).join(keySeparator);
|
|
15267
|
+
mix = current[p];
|
|
15268
|
+
}
|
|
15269
|
+
if (mix === undefined) return undefined;
|
|
15270
|
+
if (mix === null) return null;
|
|
15271
|
+
if (path.endsWith(p)) {
|
|
15272
|
+
if (typeof mix === 'string') return mix;
|
|
15273
|
+
if (p && typeof mix[p] === 'string') return mix[p];
|
|
15274
|
+
}
|
|
15275
|
+
var joinedPath = paths.slice(i + j).join(keySeparator);
|
|
15276
|
+
if (joinedPath) return deepFind(mix, joinedPath, keySeparator);
|
|
15277
|
+
return undefined;
|
|
15278
|
+
}
|
|
15279
|
+
current = current[paths[i]];
|
|
15280
|
+
}
|
|
15281
|
+
return current;
|
|
15282
|
+
}
|
|
15283
|
+
function ownKeys$5(object, enumerableOnly) {
|
|
15284
|
+
var keys = Object.keys(object);
|
|
15285
|
+
if (Object.getOwnPropertySymbols) {
|
|
15286
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
15287
|
+
(enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
15288
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
15289
|
+
})), keys.push.apply(keys, symbols));
|
|
15290
|
+
}
|
|
15291
|
+
return keys;
|
|
15292
|
+
}
|
|
15293
|
+
function _objectSpread$5(target) {
|
|
15294
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
15295
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
15296
|
+
i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) {
|
|
15297
|
+
_defineProperty(target, key, source[key]);
|
|
15298
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) {
|
|
15299
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
15300
|
+
});
|
|
15301
|
+
}
|
|
15302
|
+
return target;
|
|
15303
|
+
}
|
|
15304
|
+
function _createSuper$3(Derived) {
|
|
15305
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$3();
|
|
15306
|
+
return function _createSuperInternal() {
|
|
15307
|
+
var Super = _getPrototypeOf(Derived), result;
|
|
15308
|
+
if (hasNativeReflectConstruct) {
|
|
15309
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
15310
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
15311
|
+
} else {
|
|
15312
|
+
result = Super.apply(this, arguments);
|
|
15313
|
+
}
|
|
15314
|
+
return _possibleConstructorReturn(this, result);
|
|
15315
|
+
};
|
|
15316
|
+
}
|
|
15317
|
+
function _isNativeReflectConstruct$3() {
|
|
15318
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
15319
|
+
if (Reflect.construct.sham) return false;
|
|
15320
|
+
if (typeof Proxy === "function") return true;
|
|
15321
|
+
try {
|
|
15322
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
15323
|
+
return true;
|
|
15324
|
+
} catch (e) {
|
|
15325
|
+
return false;
|
|
15326
|
+
}
|
|
15327
|
+
}
|
|
15328
|
+
var ResourceStore = (function (_EventEmitter) {
|
|
15329
|
+
_inherits(ResourceStore, _EventEmitter);
|
|
15330
|
+
var _super = _createSuper$3(ResourceStore);
|
|
15331
|
+
function ResourceStore(data) {
|
|
15332
|
+
var _this;
|
|
15333
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
15334
|
+
ns: ['translation'],
|
|
15335
|
+
defaultNS: 'translation'
|
|
15336
|
+
};
|
|
15337
|
+
_classCallCheck(this, ResourceStore);
|
|
15338
|
+
_this = _super.call(this);
|
|
15339
|
+
if (isIE10) {
|
|
15340
|
+
EventEmitter.call(_assertThisInitialized(_this));
|
|
15341
|
+
}
|
|
15342
|
+
_this.data = data || ({});
|
|
15343
|
+
_this.options = options;
|
|
15344
|
+
if (_this.options.keySeparator === undefined) {
|
|
15345
|
+
_this.options.keySeparator = '.';
|
|
15346
|
+
}
|
|
15347
|
+
if (_this.options.ignoreJSONStructure === undefined) {
|
|
15348
|
+
_this.options.ignoreJSONStructure = true;
|
|
15349
|
+
}
|
|
15350
|
+
return _this;
|
|
15351
|
+
}
|
|
15352
|
+
_createClass(ResourceStore, [{
|
|
15353
|
+
key: "addNamespaces",
|
|
15354
|
+
value: function addNamespaces(ns) {
|
|
15355
|
+
if (this.options.ns.indexOf(ns) < 0) {
|
|
15356
|
+
this.options.ns.push(ns);
|
|
15357
|
+
}
|
|
15358
|
+
}
|
|
15359
|
+
}, {
|
|
15360
|
+
key: "removeNamespaces",
|
|
15361
|
+
value: function removeNamespaces(ns) {
|
|
15362
|
+
var index = this.options.ns.indexOf(ns);
|
|
15363
|
+
if (index > -1) {
|
|
15364
|
+
this.options.ns.splice(index, 1);
|
|
15365
|
+
}
|
|
15366
|
+
}
|
|
15367
|
+
}, {
|
|
15368
|
+
key: "getResource",
|
|
15369
|
+
value: function getResource(lng, ns, key) {
|
|
15370
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
15371
|
+
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
15372
|
+
var ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
15373
|
+
var path = [lng, ns];
|
|
15374
|
+
if (key && typeof key !== 'string') path = path.concat(key);
|
|
15375
|
+
if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
15376
|
+
if (lng.indexOf('.') > -1) {
|
|
15377
|
+
path = lng.split('.');
|
|
15378
|
+
}
|
|
15379
|
+
var result = getPath(this.data, path);
|
|
15380
|
+
if (result || !ignoreJSONStructure || typeof key !== 'string') return result;
|
|
15381
|
+
return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
|
|
15382
|
+
}
|
|
15383
|
+
}, {
|
|
15384
|
+
key: "addResource",
|
|
15385
|
+
value: function addResource(lng, ns, key, value) {
|
|
15386
|
+
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
15387
|
+
silent: false
|
|
15388
|
+
};
|
|
15389
|
+
var keySeparator = this.options.keySeparator;
|
|
15390
|
+
if (keySeparator === undefined) keySeparator = '.';
|
|
15391
|
+
var path = [lng, ns];
|
|
15392
|
+
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
15393
|
+
if (lng.indexOf('.') > -1) {
|
|
15394
|
+
path = lng.split('.');
|
|
15395
|
+
value = ns;
|
|
15396
|
+
ns = path[1];
|
|
15397
|
+
}
|
|
15398
|
+
this.addNamespaces(ns);
|
|
15399
|
+
setPath(this.data, path, value);
|
|
15400
|
+
if (!options.silent) this.emit('added', lng, ns, key, value);
|
|
15401
|
+
}
|
|
15402
|
+
}, {
|
|
15403
|
+
key: "addResources",
|
|
15404
|
+
value: function addResources(lng, ns, resources) {
|
|
15405
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
|
|
15406
|
+
silent: false
|
|
15407
|
+
};
|
|
15408
|
+
for (var m in resources) {
|
|
15409
|
+
if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
|
|
15410
|
+
silent: true
|
|
15411
|
+
});
|
|
15412
|
+
}
|
|
15413
|
+
if (!options.silent) this.emit('added', lng, ns, resources);
|
|
15414
|
+
}
|
|
15415
|
+
}, {
|
|
15416
|
+
key: "addResourceBundle",
|
|
15417
|
+
value: function addResourceBundle(lng, ns, resources, deep, overwrite) {
|
|
15418
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
|
|
15419
|
+
silent: false
|
|
15420
|
+
};
|
|
15421
|
+
var path = [lng, ns];
|
|
15422
|
+
if (lng.indexOf('.') > -1) {
|
|
15423
|
+
path = lng.split('.');
|
|
15424
|
+
deep = resources;
|
|
15425
|
+
resources = ns;
|
|
15426
|
+
ns = path[1];
|
|
15427
|
+
}
|
|
15428
|
+
this.addNamespaces(ns);
|
|
15429
|
+
var pack = getPath(this.data, path) || ({});
|
|
15430
|
+
if (deep) {
|
|
15431
|
+
deepExtend(pack, resources, overwrite);
|
|
15432
|
+
} else {
|
|
15433
|
+
pack = _objectSpread$5(_objectSpread$5({}, pack), resources);
|
|
15434
|
+
}
|
|
15435
|
+
setPath(this.data, path, pack);
|
|
15436
|
+
if (!options.silent) this.emit('added', lng, ns, resources);
|
|
15437
|
+
}
|
|
15438
|
+
}, {
|
|
15439
|
+
key: "removeResourceBundle",
|
|
15440
|
+
value: function removeResourceBundle(lng, ns) {
|
|
15441
|
+
if (this.hasResourceBundle(lng, ns)) {
|
|
15442
|
+
delete this.data[lng][ns];
|
|
15443
|
+
}
|
|
15444
|
+
this.removeNamespaces(ns);
|
|
15445
|
+
this.emit('removed', lng, ns);
|
|
15446
|
+
}
|
|
15447
|
+
}, {
|
|
15448
|
+
key: "hasResourceBundle",
|
|
15449
|
+
value: function hasResourceBundle(lng, ns) {
|
|
15450
|
+
return this.getResource(lng, ns) !== undefined;
|
|
15451
|
+
}
|
|
15452
|
+
}, {
|
|
15453
|
+
key: "getResourceBundle",
|
|
15454
|
+
value: function getResourceBundle(lng, ns) {
|
|
15455
|
+
if (!ns) ns = this.options.defaultNS;
|
|
15456
|
+
if (this.options.compatibilityAPI === 'v1') return _objectSpread$5(_objectSpread$5({}, {}), this.getResource(lng, ns));
|
|
15457
|
+
return this.getResource(lng, ns);
|
|
15458
|
+
}
|
|
15459
|
+
}, {
|
|
15460
|
+
key: "getDataByLanguage",
|
|
15461
|
+
value: function getDataByLanguage(lng) {
|
|
15462
|
+
return this.data[lng];
|
|
15463
|
+
}
|
|
15464
|
+
}, {
|
|
15465
|
+
key: "hasLanguageSomeTranslations",
|
|
15466
|
+
value: function hasLanguageSomeTranslations(lng) {
|
|
15467
|
+
var data = this.getDataByLanguage(lng);
|
|
15468
|
+
var n = data && Object.keys(data) || [];
|
|
15469
|
+
return !!n.find(function (v) {
|
|
15470
|
+
return data[v] && Object.keys(data[v]).length > 0;
|
|
15471
|
+
});
|
|
15472
|
+
}
|
|
15473
|
+
}, {
|
|
15474
|
+
key: "toJSON",
|
|
15475
|
+
value: function toJSON() {
|
|
15476
|
+
return this.data;
|
|
15477
|
+
}
|
|
15478
|
+
}]);
|
|
15479
|
+
return ResourceStore;
|
|
15480
|
+
})(EventEmitter);
|
|
15481
|
+
var postProcessor = {
|
|
15482
|
+
processors: {},
|
|
15483
|
+
addPostProcessor: function addPostProcessor(module) {
|
|
15484
|
+
this.processors[module.name] = module;
|
|
15485
|
+
},
|
|
15486
|
+
handle: function handle(processors, value, key, options, translator) {
|
|
15487
|
+
var _this = this;
|
|
15488
|
+
processors.forEach(function (processor) {
|
|
15489
|
+
if (_this.processors[processor]) value = _this.processors[processor].process(value, key, options, translator);
|
|
15490
|
+
});
|
|
15491
|
+
return value;
|
|
15492
|
+
}
|
|
15493
|
+
};
|
|
15494
|
+
function ownKeys$4(object, enumerableOnly) {
|
|
15495
|
+
var keys = Object.keys(object);
|
|
15496
|
+
if (Object.getOwnPropertySymbols) {
|
|
15497
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
15498
|
+
(enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
15499
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
15500
|
+
})), keys.push.apply(keys, symbols));
|
|
15501
|
+
}
|
|
15502
|
+
return keys;
|
|
15503
|
+
}
|
|
15504
|
+
function _objectSpread$4(target) {
|
|
15505
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
15506
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
15507
|
+
i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) {
|
|
15508
|
+
_defineProperty(target, key, source[key]);
|
|
15509
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) {
|
|
15510
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
15511
|
+
});
|
|
15512
|
+
}
|
|
15513
|
+
return target;
|
|
15514
|
+
}
|
|
15515
|
+
function _createSuper$2(Derived) {
|
|
15516
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$2();
|
|
15517
|
+
return function _createSuperInternal() {
|
|
15518
|
+
var Super = _getPrototypeOf(Derived), result;
|
|
15519
|
+
if (hasNativeReflectConstruct) {
|
|
15520
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
15521
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
15522
|
+
} else {
|
|
15523
|
+
result = Super.apply(this, arguments);
|
|
15524
|
+
}
|
|
15525
|
+
return _possibleConstructorReturn(this, result);
|
|
15526
|
+
};
|
|
15527
|
+
}
|
|
15528
|
+
function _isNativeReflectConstruct$2() {
|
|
15529
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
15530
|
+
if (Reflect.construct.sham) return false;
|
|
15531
|
+
if (typeof Proxy === "function") return true;
|
|
15532
|
+
try {
|
|
15533
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
15534
|
+
return true;
|
|
15535
|
+
} catch (e) {
|
|
15536
|
+
return false;
|
|
15537
|
+
}
|
|
15538
|
+
}
|
|
15539
|
+
var checkedLoadedFor = {};
|
|
15540
|
+
var Translator = (function (_EventEmitter) {
|
|
15541
|
+
_inherits(Translator, _EventEmitter);
|
|
15542
|
+
var _super = _createSuper$2(Translator);
|
|
15543
|
+
function Translator(services) {
|
|
15544
|
+
var _this;
|
|
15545
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
15546
|
+
_classCallCheck(this, Translator);
|
|
15547
|
+
_this = _super.call(this);
|
|
15548
|
+
if (isIE10) {
|
|
15549
|
+
EventEmitter.call(_assertThisInitialized(_this));
|
|
15550
|
+
}
|
|
15551
|
+
copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, _assertThisInitialized(_this));
|
|
15552
|
+
_this.options = options;
|
|
15553
|
+
if (_this.options.keySeparator === undefined) {
|
|
15554
|
+
_this.options.keySeparator = '.';
|
|
15555
|
+
}
|
|
15556
|
+
_this.logger = baseLogger.create('translator');
|
|
15557
|
+
return _this;
|
|
15558
|
+
}
|
|
15559
|
+
_createClass(Translator, [{
|
|
15560
|
+
key: "changeLanguage",
|
|
15561
|
+
value: function changeLanguage(lng) {
|
|
15562
|
+
if (lng) this.language = lng;
|
|
15563
|
+
}
|
|
15564
|
+
}, {
|
|
15565
|
+
key: "exists",
|
|
15566
|
+
value: function exists(key) {
|
|
15567
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
15568
|
+
interpolation: {}
|
|
15569
|
+
};
|
|
15570
|
+
if (key === undefined || key === null) {
|
|
15571
|
+
return false;
|
|
15572
|
+
}
|
|
15573
|
+
var resolved = this.resolve(key, options);
|
|
15574
|
+
return resolved && resolved.res !== undefined;
|
|
15575
|
+
}
|
|
15576
|
+
}, {
|
|
15577
|
+
key: "extractFromKey",
|
|
15578
|
+
value: function extractFromKey(key, options) {
|
|
15579
|
+
var nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
|
|
15580
|
+
if (nsSeparator === undefined) nsSeparator = ':';
|
|
15581
|
+
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
15582
|
+
var namespaces = options.ns || this.options.defaultNS || [];
|
|
15583
|
+
var wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
|
|
15584
|
+
var seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
|
|
15585
|
+
if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
|
|
15586
|
+
var m = key.match(this.interpolator.nestingRegexp);
|
|
15587
|
+
if (m && m.length > 0) {
|
|
15588
|
+
return {
|
|
15589
|
+
key: key,
|
|
15590
|
+
namespaces: namespaces
|
|
15591
|
+
};
|
|
15592
|
+
}
|
|
15593
|
+
var parts = key.split(nsSeparator);
|
|
15594
|
+
if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
|
|
15595
|
+
key = parts.join(keySeparator);
|
|
15596
|
+
}
|
|
15597
|
+
if (typeof namespaces === 'string') namespaces = [namespaces];
|
|
15598
|
+
return {
|
|
15599
|
+
key: key,
|
|
15600
|
+
namespaces: namespaces
|
|
15601
|
+
};
|
|
15602
|
+
}
|
|
15603
|
+
}, {
|
|
15604
|
+
key: "translate",
|
|
15605
|
+
value: function translate(keys, options, lastKey) {
|
|
15606
|
+
var _this2 = this;
|
|
15607
|
+
if (_typeof(options) !== 'object' && this.options.overloadTranslationOptionHandler) {
|
|
15608
|
+
options = this.options.overloadTranslationOptionHandler(arguments);
|
|
15609
|
+
}
|
|
15610
|
+
if (_typeof(options) === 'object') options = _objectSpread$4({}, options);
|
|
15611
|
+
if (!options) options = {};
|
|
15612
|
+
if (keys === undefined || keys === null) return '';
|
|
15613
|
+
if (!Array.isArray(keys)) keys = [String(keys)];
|
|
15614
|
+
var returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
|
|
15615
|
+
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
15616
|
+
var _this$extractFromKey = this.extractFromKey(keys[keys.length - 1], options), key = _this$extractFromKey.key, namespaces = _this$extractFromKey.namespaces;
|
|
15617
|
+
var namespace = namespaces[namespaces.length - 1];
|
|
15618
|
+
var lng = options.lng || this.language;
|
|
15619
|
+
var appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
15620
|
+
if (lng && lng.toLowerCase() === 'cimode') {
|
|
15621
|
+
if (appendNamespaceToCIMode) {
|
|
15622
|
+
var nsSeparator = options.nsSeparator || this.options.nsSeparator;
|
|
15623
|
+
if (returnDetails) {
|
|
15624
|
+
return {
|
|
15625
|
+
res: ("").concat(namespace).concat(nsSeparator).concat(key),
|
|
15626
|
+
usedKey: key,
|
|
15627
|
+
exactUsedKey: key,
|
|
15628
|
+
usedLng: lng,
|
|
15629
|
+
usedNS: namespace
|
|
15630
|
+
};
|
|
15631
|
+
}
|
|
15632
|
+
return ("").concat(namespace).concat(nsSeparator).concat(key);
|
|
15633
|
+
}
|
|
15634
|
+
if (returnDetails) {
|
|
15635
|
+
return {
|
|
15636
|
+
res: key,
|
|
15637
|
+
usedKey: key,
|
|
15638
|
+
exactUsedKey: key,
|
|
15639
|
+
usedLng: lng,
|
|
15640
|
+
usedNS: namespace
|
|
15641
|
+
};
|
|
15642
|
+
}
|
|
15643
|
+
return key;
|
|
15644
|
+
}
|
|
15645
|
+
var resolved = this.resolve(keys, options);
|
|
15646
|
+
var res = resolved && resolved.res;
|
|
15647
|
+
var resUsedKey = resolved && resolved.usedKey || key;
|
|
15648
|
+
var resExactUsedKey = resolved && resolved.exactUsedKey || key;
|
|
15649
|
+
var resType = Object.prototype.toString.apply(res);
|
|
15650
|
+
var noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
|
|
15651
|
+
var joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
|
|
15652
|
+
var handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
|
15653
|
+
var handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
|
|
15654
|
+
if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
|
|
15655
|
+
if (!options.returnObjects && !this.options.returnObjects) {
|
|
15656
|
+
if (!this.options.returnedObjectHandler) {
|
|
15657
|
+
this.logger.warn('accessing an object - but returnObjects options is not enabled!');
|
|
15658
|
+
}
|
|
15659
|
+
var r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread$4(_objectSpread$4({}, options), {}, {
|
|
15660
|
+
ns: namespaces
|
|
15661
|
+
})) : ("key '").concat(key, " (").concat(this.language, ")' returned an object instead of string.");
|
|
15662
|
+
if (returnDetails) {
|
|
15663
|
+
resolved.res = r;
|
|
15664
|
+
return resolved;
|
|
15665
|
+
}
|
|
15666
|
+
return r;
|
|
15667
|
+
}
|
|
15668
|
+
if (keySeparator) {
|
|
15669
|
+
var resTypeIsArray = resType === '[object Array]';
|
|
15670
|
+
var copy = resTypeIsArray ? [] : {};
|
|
15671
|
+
var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
|
|
15672
|
+
for (var m in res) {
|
|
15673
|
+
if (Object.prototype.hasOwnProperty.call(res, m)) {
|
|
15674
|
+
var deepKey = ("").concat(newKeyToUse).concat(keySeparator).concat(m);
|
|
15675
|
+
copy[m] = this.translate(deepKey, _objectSpread$4(_objectSpread$4({}, options), {
|
|
15676
|
+
joinArrays: false,
|
|
15677
|
+
ns: namespaces
|
|
15678
|
+
}));
|
|
15679
|
+
if (copy[m] === deepKey) copy[m] = res[m];
|
|
15680
|
+
}
|
|
15681
|
+
}
|
|
15682
|
+
res = copy;
|
|
15683
|
+
}
|
|
15684
|
+
} else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
|
|
15685
|
+
res = res.join(joinArrays);
|
|
15686
|
+
if (res) res = this.extendTranslation(res, keys, options, lastKey);
|
|
15687
|
+
} else {
|
|
15688
|
+
var usedDefault = false;
|
|
15689
|
+
var usedKey = false;
|
|
15690
|
+
var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
|
|
15691
|
+
var hasDefaultValue = Translator.hasDefaultValue(options);
|
|
15692
|
+
var defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
|
|
15693
|
+
var defaultValue = options[("defaultValue").concat(defaultValueSuffix)] || options.defaultValue;
|
|
15694
|
+
if (!this.isValidLookup(res) && hasDefaultValue) {
|
|
15695
|
+
usedDefault = true;
|
|
15696
|
+
res = defaultValue;
|
|
15697
|
+
}
|
|
15698
|
+
if (!this.isValidLookup(res)) {
|
|
15699
|
+
usedKey = true;
|
|
15700
|
+
res = key;
|
|
15701
|
+
}
|
|
15702
|
+
var missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
|
|
15703
|
+
var resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
|
|
15704
|
+
var updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
|
|
15705
|
+
if (usedKey || usedDefault || updateMissing) {
|
|
15706
|
+
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
|
|
15707
|
+
if (keySeparator) {
|
|
15708
|
+
var fk = this.resolve(key, _objectSpread$4(_objectSpread$4({}, options), {}, {
|
|
15709
|
+
keySeparator: false
|
|
15710
|
+
}));
|
|
15711
|
+
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.');
|
|
15712
|
+
}
|
|
15713
|
+
var lngs = [];
|
|
15714
|
+
var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
|
|
15715
|
+
if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
|
|
15716
|
+
for (var i = 0; i < fallbackLngs.length; i++) {
|
|
15717
|
+
lngs.push(fallbackLngs[i]);
|
|
15718
|
+
}
|
|
15719
|
+
} else if (this.options.saveMissingTo === 'all') {
|
|
15720
|
+
lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
|
|
15721
|
+
} else {
|
|
15722
|
+
lngs.push(options.lng || this.language);
|
|
15723
|
+
}
|
|
15724
|
+
var send = function send(l, k, specificDefaultValue) {
|
|
15725
|
+
var defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
|
|
15726
|
+
if (_this2.options.missingKeyHandler) {
|
|
15727
|
+
_this2.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
|
|
15728
|
+
} else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {
|
|
15729
|
+
_this2.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
|
|
15730
|
+
}
|
|
15731
|
+
_this2.emit('missingKey', l, namespace, k, res);
|
|
15732
|
+
};
|
|
15733
|
+
if (this.options.saveMissing) {
|
|
15734
|
+
if (this.options.saveMissingPlurals && needsPluralHandling) {
|
|
15735
|
+
lngs.forEach(function (language) {
|
|
15736
|
+
_this2.pluralResolver.getSuffixes(language, options).forEach(function (suffix) {
|
|
15737
|
+
send([language], key + suffix, options[("defaultValue").concat(suffix)] || defaultValue);
|
|
15738
|
+
});
|
|
15739
|
+
});
|
|
15740
|
+
} else {
|
|
15741
|
+
send(lngs, key, defaultValue);
|
|
15742
|
+
}
|
|
15743
|
+
}
|
|
15744
|
+
}
|
|
15745
|
+
res = this.extendTranslation(res, keys, options, resolved, lastKey);
|
|
15746
|
+
if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = ("").concat(namespace, ":").concat(key);
|
|
15747
|
+
if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
|
|
15748
|
+
if (this.options.compatibilityAPI !== 'v1') {
|
|
15749
|
+
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? ("").concat(namespace, ":").concat(key) : key, usedDefault ? res : undefined);
|
|
15750
|
+
} else {
|
|
15751
|
+
res = this.options.parseMissingKeyHandler(res);
|
|
15752
|
+
}
|
|
15753
|
+
}
|
|
15754
|
+
}
|
|
15755
|
+
if (returnDetails) {
|
|
15756
|
+
resolved.res = res;
|
|
15757
|
+
return resolved;
|
|
15758
|
+
}
|
|
15759
|
+
return res;
|
|
15760
|
+
}
|
|
15761
|
+
}, {
|
|
15762
|
+
key: "extendTranslation",
|
|
15763
|
+
value: function extendTranslation(res, key, options, resolved, lastKey) {
|
|
15764
|
+
var _this3 = this;
|
|
15765
|
+
if (this.i18nFormat && this.i18nFormat.parse) {
|
|
15766
|
+
res = this.i18nFormat.parse(res, _objectSpread$4(_objectSpread$4({}, this.options.interpolation.defaultVariables), options), resolved.usedLng, resolved.usedNS, resolved.usedKey, {
|
|
15767
|
+
resolved: resolved
|
|
15768
|
+
});
|
|
15769
|
+
} else if (!options.skipInterpolation) {
|
|
15770
|
+
if (options.interpolation) this.interpolator.init(_objectSpread$4(_objectSpread$4({}, options), {
|
|
15771
|
+
interpolation: _objectSpread$4(_objectSpread$4({}, this.options.interpolation), options.interpolation)
|
|
15772
|
+
}));
|
|
15773
|
+
var skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
15774
|
+
var nestBef;
|
|
15775
|
+
if (skipOnVariables) {
|
|
15776
|
+
var nb = res.match(this.interpolator.nestingRegexp);
|
|
15777
|
+
nestBef = nb && nb.length;
|
|
15778
|
+
}
|
|
15779
|
+
var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
|
|
15780
|
+
if (this.options.interpolation.defaultVariables) data = _objectSpread$4(_objectSpread$4({}, this.options.interpolation.defaultVariables), data);
|
|
15781
|
+
res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
|
|
15782
|
+
if (skipOnVariables) {
|
|
15783
|
+
var na = res.match(this.interpolator.nestingRegexp);
|
|
15784
|
+
var nestAft = na && na.length;
|
|
15785
|
+
if (nestBef < nestAft) options.nest = false;
|
|
15786
|
+
}
|
|
15787
|
+
if (!options.lng && this.options.compatibilityAPI !== 'v1' && resolved && resolved.res) options.lng = resolved.usedLng;
|
|
15788
|
+
if (options.nest !== false) res = this.interpolator.nest(res, function () {
|
|
15789
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15790
|
+
args[_key] = arguments[_key];
|
|
15791
|
+
}
|
|
15792
|
+
if (lastKey && lastKey[0] === args[0] && !options.context) {
|
|
15793
|
+
_this3.logger.warn(("It seems you are nesting recursively key: ").concat(args[0], " in key: ").concat(key[0]));
|
|
15794
|
+
return null;
|
|
15795
|
+
}
|
|
15796
|
+
return _this3.translate.apply(_this3, args.concat([key]));
|
|
15797
|
+
}, options);
|
|
15798
|
+
if (options.interpolation) this.interpolator.reset();
|
|
15799
|
+
}
|
|
15800
|
+
var postProcess = options.postProcess || this.options.postProcess;
|
|
15801
|
+
var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
|
|
15802
|
+
if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
|
|
15803
|
+
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread$4({
|
|
15804
|
+
i18nResolved: resolved
|
|
15805
|
+
}, options) : options, this);
|
|
15806
|
+
}
|
|
15807
|
+
return res;
|
|
15808
|
+
}
|
|
15809
|
+
}, {
|
|
15810
|
+
key: "resolve",
|
|
15811
|
+
value: function resolve(keys) {
|
|
15812
|
+
var _this4 = this;
|
|
15813
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
15814
|
+
var found;
|
|
15815
|
+
var usedKey;
|
|
15816
|
+
var exactUsedKey;
|
|
15817
|
+
var usedLng;
|
|
15818
|
+
var usedNS;
|
|
15819
|
+
if (typeof keys === 'string') keys = [keys];
|
|
15820
|
+
keys.forEach(function (k) {
|
|
15821
|
+
if (_this4.isValidLookup(found)) return;
|
|
15822
|
+
var extracted = _this4.extractFromKey(k, options);
|
|
15823
|
+
var key = extracted.key;
|
|
15824
|
+
usedKey = key;
|
|
15825
|
+
var namespaces = extracted.namespaces;
|
|
15826
|
+
if (_this4.options.fallbackNS) namespaces = namespaces.concat(_this4.options.fallbackNS);
|
|
15827
|
+
var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
|
|
15828
|
+
var needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && _this4.pluralResolver.shouldUseIntlApi();
|
|
15829
|
+
var needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';
|
|
15830
|
+
var codes = options.lngs ? options.lngs : _this4.languageUtils.toResolveHierarchy(options.lng || _this4.language, options.fallbackLng);
|
|
15831
|
+
namespaces.forEach(function (ns) {
|
|
15832
|
+
if (_this4.isValidLookup(found)) return;
|
|
15833
|
+
usedNS = ns;
|
|
15834
|
+
if (!checkedLoadedFor[("").concat(codes[0], "-").concat(ns)] && _this4.utils && _this4.utils.hasLoadedNamespace && !_this4.utils.hasLoadedNamespace(usedNS)) {
|
|
15835
|
+
checkedLoadedFor[("").concat(codes[0], "-").concat(ns)] = true;
|
|
15836
|
+
_this4.logger.warn(("key \"").concat(usedKey, "\" for languages \"").concat(codes.join(', '), "\" won't get resolved as namespace \"").concat(usedNS, "\" was not yet loaded"), 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
|
|
15837
|
+
}
|
|
15838
|
+
codes.forEach(function (code) {
|
|
15839
|
+
if (_this4.isValidLookup(found)) return;
|
|
15840
|
+
usedLng = code;
|
|
15841
|
+
var finalKeys = [key];
|
|
15842
|
+
if (_this4.i18nFormat && _this4.i18nFormat.addLookupKeys) {
|
|
15843
|
+
_this4.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
|
|
15844
|
+
} else {
|
|
15845
|
+
var pluralSuffix;
|
|
15846
|
+
if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count, options);
|
|
15847
|
+
var zeroSuffix = ("").concat(_this4.options.pluralSeparator, "zero");
|
|
15848
|
+
if (needsPluralHandling) {
|
|
15849
|
+
finalKeys.push(key + pluralSuffix);
|
|
15850
|
+
if (needsZeroSuffixLookup) {
|
|
15851
|
+
finalKeys.push(key + zeroSuffix);
|
|
15852
|
+
}
|
|
15853
|
+
}
|
|
15854
|
+
if (needsContextHandling) {
|
|
15855
|
+
var contextKey = ("").concat(key).concat(_this4.options.contextSeparator).concat(options.context);
|
|
15856
|
+
finalKeys.push(contextKey);
|
|
15857
|
+
if (needsPluralHandling) {
|
|
15858
|
+
finalKeys.push(contextKey + pluralSuffix);
|
|
15859
|
+
if (needsZeroSuffixLookup) {
|
|
15860
|
+
finalKeys.push(contextKey + zeroSuffix);
|
|
15861
|
+
}
|
|
15862
|
+
}
|
|
15863
|
+
}
|
|
15864
|
+
}
|
|
15865
|
+
var possibleKey;
|
|
15866
|
+
while (possibleKey = finalKeys.pop()) {
|
|
15867
|
+
if (!_this4.isValidLookup(found)) {
|
|
15868
|
+
exactUsedKey = possibleKey;
|
|
15869
|
+
found = _this4.getResource(code, ns, possibleKey, options);
|
|
15870
|
+
}
|
|
15871
|
+
}
|
|
15872
|
+
});
|
|
15873
|
+
});
|
|
15874
|
+
});
|
|
15875
|
+
return {
|
|
15876
|
+
res: found,
|
|
15877
|
+
usedKey: usedKey,
|
|
15878
|
+
exactUsedKey: exactUsedKey,
|
|
15879
|
+
usedLng: usedLng,
|
|
15880
|
+
usedNS: usedNS
|
|
15881
|
+
};
|
|
15882
|
+
}
|
|
15883
|
+
}, {
|
|
15884
|
+
key: "isValidLookup",
|
|
15885
|
+
value: function isValidLookup(res) {
|
|
15886
|
+
return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
|
|
15887
|
+
}
|
|
15888
|
+
}, {
|
|
15889
|
+
key: "getResource",
|
|
15890
|
+
value: function getResource(code, ns, key) {
|
|
15891
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
15892
|
+
if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
|
|
15893
|
+
return this.resourceStore.getResource(code, ns, key, options);
|
|
15894
|
+
}
|
|
15895
|
+
}], [{
|
|
15896
|
+
key: "hasDefaultValue",
|
|
15897
|
+
value: function hasDefaultValue(options) {
|
|
15898
|
+
var prefix = 'defaultValue';
|
|
15899
|
+
for (var option in options) {
|
|
15900
|
+
if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
|
|
15901
|
+
return true;
|
|
15902
|
+
}
|
|
15903
|
+
}
|
|
15904
|
+
return false;
|
|
15905
|
+
}
|
|
15906
|
+
}]);
|
|
15907
|
+
return Translator;
|
|
15908
|
+
})(EventEmitter);
|
|
15909
|
+
function capitalize(string) {
|
|
15910
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
15911
|
+
}
|
|
15912
|
+
var LanguageUtil = (function () {
|
|
15913
|
+
function LanguageUtil(options) {
|
|
15914
|
+
_classCallCheck(this, LanguageUtil);
|
|
15915
|
+
this.options = options;
|
|
15916
|
+
this.supportedLngs = this.options.supportedLngs || false;
|
|
15917
|
+
this.logger = baseLogger.create('languageUtils');
|
|
15918
|
+
}
|
|
15919
|
+
_createClass(LanguageUtil, [{
|
|
15920
|
+
key: "getScriptPartFromCode",
|
|
15921
|
+
value: function getScriptPartFromCode(code) {
|
|
15922
|
+
if (!code || code.indexOf('-') < 0) return null;
|
|
15923
|
+
var p = code.split('-');
|
|
15924
|
+
if (p.length === 2) return null;
|
|
15925
|
+
p.pop();
|
|
15926
|
+
if (p[p.length - 1].toLowerCase() === 'x') return null;
|
|
15927
|
+
return this.formatLanguageCode(p.join('-'));
|
|
15928
|
+
}
|
|
15929
|
+
}, {
|
|
15930
|
+
key: "getLanguagePartFromCode",
|
|
15931
|
+
value: function getLanguagePartFromCode(code) {
|
|
15932
|
+
if (!code || code.indexOf('-') < 0) return code;
|
|
15933
|
+
var p = code.split('-');
|
|
15934
|
+
return this.formatLanguageCode(p[0]);
|
|
15935
|
+
}
|
|
15936
|
+
}, {
|
|
15937
|
+
key: "formatLanguageCode",
|
|
15938
|
+
value: function formatLanguageCode(code) {
|
|
15939
|
+
if (typeof code === 'string' && code.indexOf('-') > -1) {
|
|
15940
|
+
var specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
|
|
15941
|
+
var p = code.split('-');
|
|
15942
|
+
if (this.options.lowerCaseLng) {
|
|
15943
|
+
p = p.map(function (part) {
|
|
15944
|
+
return part.toLowerCase();
|
|
15945
|
+
});
|
|
15946
|
+
} else if (p.length === 2) {
|
|
15947
|
+
p[0] = p[0].toLowerCase();
|
|
15948
|
+
p[1] = p[1].toUpperCase();
|
|
15949
|
+
if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
|
|
15950
|
+
} else if (p.length === 3) {
|
|
15951
|
+
p[0] = p[0].toLowerCase();
|
|
15952
|
+
if (p[1].length === 2) p[1] = p[1].toUpperCase();
|
|
15953
|
+
if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
|
|
15954
|
+
if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
|
|
15955
|
+
if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
|
|
15956
|
+
}
|
|
15957
|
+
return p.join('-');
|
|
15958
|
+
}
|
|
15959
|
+
return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
|
|
15960
|
+
}
|
|
15961
|
+
}, {
|
|
15962
|
+
key: "isSupportedCode",
|
|
15963
|
+
value: function isSupportedCode(code) {
|
|
15964
|
+
if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
|
|
15965
|
+
code = this.getLanguagePartFromCode(code);
|
|
15966
|
+
}
|
|
15967
|
+
return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
|
|
15968
|
+
}
|
|
15969
|
+
}, {
|
|
15970
|
+
key: "getBestMatchFromCodes",
|
|
15971
|
+
value: function getBestMatchFromCodes(codes) {
|
|
15972
|
+
var _this = this;
|
|
15973
|
+
if (!codes) return null;
|
|
15974
|
+
var found;
|
|
15975
|
+
codes.forEach(function (code) {
|
|
15976
|
+
if (found) return;
|
|
15977
|
+
var cleanedLng = _this.formatLanguageCode(code);
|
|
15978
|
+
if (!_this.options.supportedLngs || _this.isSupportedCode(cleanedLng)) found = cleanedLng;
|
|
15979
|
+
});
|
|
15980
|
+
if (!found && this.options.supportedLngs) {
|
|
15981
|
+
codes.forEach(function (code) {
|
|
15982
|
+
if (found) return;
|
|
15983
|
+
var lngOnly = _this.getLanguagePartFromCode(code);
|
|
15984
|
+
if (_this.isSupportedCode(lngOnly)) return found = lngOnly;
|
|
15985
|
+
found = _this.options.supportedLngs.find(function (supportedLng) {
|
|
15986
|
+
if (supportedLng === lngOnly) return supportedLng;
|
|
15987
|
+
if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
|
|
15988
|
+
if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;
|
|
15989
|
+
});
|
|
15990
|
+
});
|
|
15991
|
+
}
|
|
15992
|
+
if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
|
|
15993
|
+
return found;
|
|
15994
|
+
}
|
|
15995
|
+
}, {
|
|
15996
|
+
key: "getFallbackCodes",
|
|
15997
|
+
value: function getFallbackCodes(fallbacks, code) {
|
|
15998
|
+
if (!fallbacks) return [];
|
|
15999
|
+
if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
|
|
16000
|
+
if (typeof fallbacks === 'string') fallbacks = [fallbacks];
|
|
16001
|
+
if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;
|
|
16002
|
+
if (!code) return fallbacks["default"] || [];
|
|
16003
|
+
var found = fallbacks[code];
|
|
16004
|
+
if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
|
|
16005
|
+
if (!found) found = fallbacks[this.formatLanguageCode(code)];
|
|
16006
|
+
if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
|
|
16007
|
+
if (!found) found = fallbacks["default"];
|
|
16008
|
+
return found || [];
|
|
16009
|
+
}
|
|
16010
|
+
}, {
|
|
16011
|
+
key: "toResolveHierarchy",
|
|
16012
|
+
value: function toResolveHierarchy(code, fallbackCode) {
|
|
16013
|
+
var _this2 = this;
|
|
16014
|
+
var fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
|
|
16015
|
+
var codes = [];
|
|
16016
|
+
var addCode = function addCode(c) {
|
|
16017
|
+
if (!c) return;
|
|
16018
|
+
if (_this2.isSupportedCode(c)) {
|
|
16019
|
+
codes.push(c);
|
|
16020
|
+
} else {
|
|
16021
|
+
_this2.logger.warn(("rejecting language code not found in supportedLngs: ").concat(c));
|
|
16022
|
+
}
|
|
16023
|
+
};
|
|
16024
|
+
if (typeof code === 'string' && code.indexOf('-') > -1) {
|
|
16025
|
+
if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
|
|
16026
|
+
if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
|
|
16027
|
+
if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
|
|
16028
|
+
} else if (typeof code === 'string') {
|
|
16029
|
+
addCode(this.formatLanguageCode(code));
|
|
16030
|
+
}
|
|
16031
|
+
fallbackCodes.forEach(function (fc) {
|
|
16032
|
+
if (codes.indexOf(fc) < 0) addCode(_this2.formatLanguageCode(fc));
|
|
16033
|
+
});
|
|
16034
|
+
return codes;
|
|
16035
|
+
}
|
|
16036
|
+
}]);
|
|
16037
|
+
return LanguageUtil;
|
|
16038
|
+
})();
|
|
16039
|
+
var sets = [{
|
|
16040
|
+
lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
|
|
16041
|
+
nr: [1, 2],
|
|
16042
|
+
fc: 1
|
|
16043
|
+
}, {
|
|
16044
|
+
lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'hi', 'hu', 'hy', 'ia', 'it', 'kk', 'kn', 'ku', 'lb', 'mai', 'ml', 'mn', 'mr', 'nah', 'nap', 'nb', 'ne', 'nl', 'nn', 'no', 'nso', 'pa', 'pap', 'pms', 'ps', 'pt-PT', 'rm', 'sco', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw', 'ta', 'te', 'tk', 'ur', 'yo'],
|
|
16045
|
+
nr: [1, 2],
|
|
16046
|
+
fc: 2
|
|
16047
|
+
}, {
|
|
16048
|
+
lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
|
|
16049
|
+
nr: [1],
|
|
16050
|
+
fc: 3
|
|
16051
|
+
}, {
|
|
16052
|
+
lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
|
|
16053
|
+
nr: [1, 2, 5],
|
|
16054
|
+
fc: 4
|
|
16055
|
+
}, {
|
|
16056
|
+
lngs: ['ar'],
|
|
16057
|
+
nr: [0, 1, 2, 3, 11, 100],
|
|
16058
|
+
fc: 5
|
|
16059
|
+
}, {
|
|
16060
|
+
lngs: ['cs', 'sk'],
|
|
16061
|
+
nr: [1, 2, 5],
|
|
16062
|
+
fc: 6
|
|
16063
|
+
}, {
|
|
16064
|
+
lngs: ['csb', 'pl'],
|
|
16065
|
+
nr: [1, 2, 5],
|
|
16066
|
+
fc: 7
|
|
16067
|
+
}, {
|
|
16068
|
+
lngs: ['cy'],
|
|
16069
|
+
nr: [1, 2, 3, 8],
|
|
16070
|
+
fc: 8
|
|
16071
|
+
}, {
|
|
16072
|
+
lngs: ['fr'],
|
|
16073
|
+
nr: [1, 2],
|
|
16074
|
+
fc: 9
|
|
16075
|
+
}, {
|
|
16076
|
+
lngs: ['ga'],
|
|
16077
|
+
nr: [1, 2, 3, 7, 11],
|
|
16078
|
+
fc: 10
|
|
16079
|
+
}, {
|
|
16080
|
+
lngs: ['gd'],
|
|
16081
|
+
nr: [1, 2, 3, 20],
|
|
16082
|
+
fc: 11
|
|
16083
|
+
}, {
|
|
16084
|
+
lngs: ['is'],
|
|
16085
|
+
nr: [1, 2],
|
|
16086
|
+
fc: 12
|
|
16087
|
+
}, {
|
|
16088
|
+
lngs: ['jv'],
|
|
16089
|
+
nr: [0, 1],
|
|
16090
|
+
fc: 13
|
|
16091
|
+
}, {
|
|
16092
|
+
lngs: ['kw'],
|
|
16093
|
+
nr: [1, 2, 3, 4],
|
|
16094
|
+
fc: 14
|
|
16095
|
+
}, {
|
|
16096
|
+
lngs: ['lt'],
|
|
16097
|
+
nr: [1, 2, 10],
|
|
16098
|
+
fc: 15
|
|
16099
|
+
}, {
|
|
16100
|
+
lngs: ['lv'],
|
|
16101
|
+
nr: [1, 2, 0],
|
|
16102
|
+
fc: 16
|
|
16103
|
+
}, {
|
|
16104
|
+
lngs: ['mk'],
|
|
16105
|
+
nr: [1, 2],
|
|
16106
|
+
fc: 17
|
|
16107
|
+
}, {
|
|
16108
|
+
lngs: ['mnk'],
|
|
16109
|
+
nr: [0, 1, 2],
|
|
16110
|
+
fc: 18
|
|
16111
|
+
}, {
|
|
16112
|
+
lngs: ['mt'],
|
|
16113
|
+
nr: [1, 2, 11, 20],
|
|
16114
|
+
fc: 19
|
|
16115
|
+
}, {
|
|
16116
|
+
lngs: ['or'],
|
|
16117
|
+
nr: [2, 1],
|
|
16118
|
+
fc: 2
|
|
16119
|
+
}, {
|
|
16120
|
+
lngs: ['ro'],
|
|
16121
|
+
nr: [1, 2, 20],
|
|
16122
|
+
fc: 20
|
|
16123
|
+
}, {
|
|
16124
|
+
lngs: ['sl'],
|
|
16125
|
+
nr: [5, 1, 2, 3],
|
|
16126
|
+
fc: 21
|
|
16127
|
+
}, {
|
|
16128
|
+
lngs: ['he', 'iw'],
|
|
16129
|
+
nr: [1, 2, 20, 21],
|
|
16130
|
+
fc: 22
|
|
16131
|
+
}];
|
|
16132
|
+
var _rulesPluralsTypes = {
|
|
16133
|
+
1: function _(n) {
|
|
16134
|
+
return Number(n > 1);
|
|
16135
|
+
},
|
|
16136
|
+
2: function _(n) {
|
|
16137
|
+
return Number(n != 1);
|
|
16138
|
+
},
|
|
16139
|
+
3: function _(n) {
|
|
16140
|
+
return 0;
|
|
16141
|
+
},
|
|
16142
|
+
4: function _(n) {
|
|
16143
|
+
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
|
16144
|
+
},
|
|
16145
|
+
5: function _(n) {
|
|
16146
|
+
return Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
|
|
16147
|
+
},
|
|
16148
|
+
6: function _(n) {
|
|
16149
|
+
return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
|
|
16150
|
+
},
|
|
16151
|
+
7: function _(n) {
|
|
16152
|
+
return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
|
16153
|
+
},
|
|
16154
|
+
8: function _(n) {
|
|
16155
|
+
return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
|
|
16156
|
+
},
|
|
16157
|
+
9: function _(n) {
|
|
16158
|
+
return Number(n >= 2);
|
|
16159
|
+
},
|
|
16160
|
+
10: function _(n) {
|
|
16161
|
+
return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
|
|
16162
|
+
},
|
|
16163
|
+
11: function _(n) {
|
|
16164
|
+
return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
|
|
16165
|
+
},
|
|
16166
|
+
12: function _(n) {
|
|
16167
|
+
return Number(n % 10 != 1 || n % 100 == 11);
|
|
16168
|
+
},
|
|
16169
|
+
13: function _(n) {
|
|
16170
|
+
return Number(n !== 0);
|
|
16171
|
+
},
|
|
16172
|
+
14: function _(n) {
|
|
16173
|
+
return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
|
|
16174
|
+
},
|
|
16175
|
+
15: function _(n) {
|
|
16176
|
+
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
|
16177
|
+
},
|
|
16178
|
+
16: function _(n) {
|
|
16179
|
+
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
|
|
16180
|
+
},
|
|
16181
|
+
17: function _(n) {
|
|
16182
|
+
return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);
|
|
16183
|
+
},
|
|
16184
|
+
18: function _(n) {
|
|
16185
|
+
return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
|
|
16186
|
+
},
|
|
16187
|
+
19: function _(n) {
|
|
16188
|
+
return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
|
|
16189
|
+
},
|
|
16190
|
+
20: function _(n) {
|
|
16191
|
+
return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
|
|
16192
|
+
},
|
|
16193
|
+
21: function _(n) {
|
|
16194
|
+
return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
|
|
16195
|
+
},
|
|
16196
|
+
22: function _(n) {
|
|
16197
|
+
return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
|
|
16198
|
+
}
|
|
16199
|
+
};
|
|
16200
|
+
var deprecatedJsonVersions = ['v1', 'v2', 'v3'];
|
|
16201
|
+
var suffixesOrder = {
|
|
16202
|
+
zero: 0,
|
|
16203
|
+
one: 1,
|
|
16204
|
+
two: 2,
|
|
16205
|
+
few: 3,
|
|
16206
|
+
many: 4,
|
|
16207
|
+
other: 5
|
|
16208
|
+
};
|
|
16209
|
+
function createRules() {
|
|
16210
|
+
var rules = {};
|
|
16211
|
+
sets.forEach(function (set) {
|
|
16212
|
+
set.lngs.forEach(function (l) {
|
|
16213
|
+
rules[l] = {
|
|
16214
|
+
numbers: set.nr,
|
|
16215
|
+
plurals: _rulesPluralsTypes[set.fc]
|
|
16216
|
+
};
|
|
16217
|
+
});
|
|
16218
|
+
});
|
|
16219
|
+
return rules;
|
|
16220
|
+
}
|
|
16221
|
+
var PluralResolver = (function () {
|
|
16222
|
+
function PluralResolver(languageUtils) {
|
|
16223
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
16224
|
+
_classCallCheck(this, PluralResolver);
|
|
16225
|
+
this.languageUtils = languageUtils;
|
|
16226
|
+
this.options = options;
|
|
16227
|
+
this.logger = baseLogger.create('pluralResolver');
|
|
16228
|
+
if ((!this.options.compatibilityJSON || this.options.compatibilityJSON === 'v4') && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
|
|
16229
|
+
this.options.compatibilityJSON = 'v3';
|
|
16230
|
+
this.logger.error('Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.');
|
|
16231
|
+
}
|
|
16232
|
+
this.rules = createRules();
|
|
16233
|
+
}
|
|
16234
|
+
_createClass(PluralResolver, [{
|
|
16235
|
+
key: "addRule",
|
|
16236
|
+
value: function addRule(lng, obj) {
|
|
16237
|
+
this.rules[lng] = obj;
|
|
16238
|
+
}
|
|
16239
|
+
}, {
|
|
16240
|
+
key: "getRule",
|
|
16241
|
+
value: function getRule(code) {
|
|
16242
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
16243
|
+
if (this.shouldUseIntlApi()) {
|
|
16244
|
+
try {
|
|
16245
|
+
return new Intl.PluralRules(code, {
|
|
16246
|
+
type: options.ordinal ? 'ordinal' : 'cardinal'
|
|
16247
|
+
});
|
|
16248
|
+
} catch (_unused) {
|
|
16249
|
+
return;
|
|
16250
|
+
}
|
|
16251
|
+
}
|
|
16252
|
+
return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
|
|
16253
|
+
}
|
|
16254
|
+
}, {
|
|
16255
|
+
key: "needsPlural",
|
|
16256
|
+
value: function needsPlural(code) {
|
|
16257
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
16258
|
+
var rule = this.getRule(code, options);
|
|
16259
|
+
if (this.shouldUseIntlApi()) {
|
|
16260
|
+
return rule && rule.resolvedOptions().pluralCategories.length > 1;
|
|
16261
|
+
}
|
|
16262
|
+
return rule && rule.numbers.length > 1;
|
|
16263
|
+
}
|
|
16264
|
+
}, {
|
|
16265
|
+
key: "getPluralFormsOfKey",
|
|
16266
|
+
value: function getPluralFormsOfKey(code, key) {
|
|
16267
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
16268
|
+
return this.getSuffixes(code, options).map(function (suffix) {
|
|
16269
|
+
return ("").concat(key).concat(suffix);
|
|
16270
|
+
});
|
|
16271
|
+
}
|
|
16272
|
+
}, {
|
|
16273
|
+
key: "getSuffixes",
|
|
16274
|
+
value: function getSuffixes(code) {
|
|
16275
|
+
var _this = this;
|
|
16276
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
16277
|
+
var rule = this.getRule(code, options);
|
|
16278
|
+
if (!rule) {
|
|
16279
|
+
return [];
|
|
16280
|
+
}
|
|
16281
|
+
if (this.shouldUseIntlApi()) {
|
|
16282
|
+
return rule.resolvedOptions().pluralCategories.sort(function (pluralCategory1, pluralCategory2) {
|
|
16283
|
+
return suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2];
|
|
16284
|
+
}).map(function (pluralCategory) {
|
|
16285
|
+
return ("").concat(_this.options.prepend).concat(pluralCategory);
|
|
16286
|
+
});
|
|
16287
|
+
}
|
|
16288
|
+
return rule.numbers.map(function (number) {
|
|
16289
|
+
return _this.getSuffix(code, number, options);
|
|
16290
|
+
});
|
|
16291
|
+
}
|
|
16292
|
+
}, {
|
|
16293
|
+
key: "getSuffix",
|
|
16294
|
+
value: function getSuffix(code, count) {
|
|
16295
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
16296
|
+
var rule = this.getRule(code, options);
|
|
16297
|
+
if (rule) {
|
|
16298
|
+
if (this.shouldUseIntlApi()) {
|
|
16299
|
+
return ("").concat(this.options.prepend).concat(rule.select(count));
|
|
16300
|
+
}
|
|
16301
|
+
return this.getSuffixRetroCompatible(rule, count);
|
|
16302
|
+
}
|
|
16303
|
+
this.logger.warn(("no plural rule found for: ").concat(code));
|
|
16304
|
+
return '';
|
|
16305
|
+
}
|
|
16306
|
+
}, {
|
|
16307
|
+
key: "getSuffixRetroCompatible",
|
|
16308
|
+
value: function getSuffixRetroCompatible(rule, count) {
|
|
16309
|
+
var _this2 = this;
|
|
16310
|
+
var idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
|
|
16311
|
+
var suffix = rule.numbers[idx];
|
|
16312
|
+
if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
|
16313
|
+
if (suffix === 2) {
|
|
16314
|
+
suffix = 'plural';
|
|
16315
|
+
} else if (suffix === 1) {
|
|
16316
|
+
suffix = '';
|
|
16317
|
+
}
|
|
16318
|
+
}
|
|
16319
|
+
var returnSuffix = function returnSuffix() {
|
|
16320
|
+
return _this2.options.prepend && suffix.toString() ? _this2.options.prepend + suffix.toString() : suffix.toString();
|
|
16321
|
+
};
|
|
16322
|
+
if (this.options.compatibilityJSON === 'v1') {
|
|
16323
|
+
if (suffix === 1) return '';
|
|
16324
|
+
if (typeof suffix === 'number') return ("_plural_").concat(suffix.toString());
|
|
16325
|
+
return returnSuffix();
|
|
16326
|
+
} else if (this.options.compatibilityJSON === 'v2') {
|
|
16327
|
+
return returnSuffix();
|
|
16328
|
+
} else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
|
16329
|
+
return returnSuffix();
|
|
16330
|
+
}
|
|
16331
|
+
return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
|
|
16332
|
+
}
|
|
16333
|
+
}, {
|
|
16334
|
+
key: "shouldUseIntlApi",
|
|
16335
|
+
value: function shouldUseIntlApi() {
|
|
16336
|
+
return !deprecatedJsonVersions.includes(this.options.compatibilityJSON);
|
|
16337
|
+
}
|
|
16338
|
+
}]);
|
|
16339
|
+
return PluralResolver;
|
|
16340
|
+
})();
|
|
16341
|
+
function ownKeys$3(object, enumerableOnly) {
|
|
16342
|
+
var keys = Object.keys(object);
|
|
16343
|
+
if (Object.getOwnPropertySymbols) {
|
|
16344
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
16345
|
+
(enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
16346
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
16347
|
+
})), keys.push.apply(keys, symbols));
|
|
16348
|
+
}
|
|
16349
|
+
return keys;
|
|
16350
|
+
}
|
|
16351
|
+
function _objectSpread$3(target) {
|
|
16352
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
16353
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
16354
|
+
i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) {
|
|
16355
|
+
_defineProperty(target, key, source[key]);
|
|
16356
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) {
|
|
16357
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
16358
|
+
});
|
|
16359
|
+
}
|
|
16360
|
+
return target;
|
|
16361
|
+
}
|
|
16362
|
+
function deepFindWithDefaults(data, defaultData, key) {
|
|
16363
|
+
var keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
|
|
16364
|
+
var ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
16365
|
+
var path = getPathWithDefaults(data, defaultData, key);
|
|
16366
|
+
if (!path && ignoreJSONStructure && typeof key === 'string') {
|
|
16367
|
+
path = deepFind(data, key, keySeparator);
|
|
16368
|
+
if (path === undefined) path = deepFind(defaultData, key, keySeparator);
|
|
16369
|
+
}
|
|
16370
|
+
return path;
|
|
16371
|
+
}
|
|
16372
|
+
var Interpolator = (function () {
|
|
16373
|
+
function Interpolator() {
|
|
16374
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
16375
|
+
_classCallCheck(this, Interpolator);
|
|
16376
|
+
this.logger = baseLogger.create('interpolator');
|
|
16377
|
+
this.options = options;
|
|
16378
|
+
this.format = options.interpolation && options.interpolation.format || (function (value) {
|
|
16379
|
+
return value;
|
|
16380
|
+
});
|
|
16381
|
+
this.init(options);
|
|
16382
|
+
}
|
|
16383
|
+
_createClass(Interpolator, [{
|
|
16384
|
+
key: "init",
|
|
16385
|
+
value: function init() {
|
|
16386
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
16387
|
+
if (!options.interpolation) options.interpolation = {
|
|
16388
|
+
escapeValue: true
|
|
16389
|
+
};
|
|
16390
|
+
var iOpts = options.interpolation;
|
|
16391
|
+
this.escape = iOpts.escape !== undefined ? iOpts.escape : escape;
|
|
16392
|
+
this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;
|
|
16393
|
+
this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;
|
|
16394
|
+
this.prefix = iOpts.prefix ? regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';
|
|
16395
|
+
this.suffix = iOpts.suffix ? regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';
|
|
16396
|
+
this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
|
|
16397
|
+
this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';
|
|
16398
|
+
this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';
|
|
16399
|
+
this.nestingPrefix = iOpts.nestingPrefix ? regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || regexEscape('$t(');
|
|
16400
|
+
this.nestingSuffix = iOpts.nestingSuffix ? regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || regexEscape(')');
|
|
16401
|
+
this.nestingOptionsSeparator = iOpts.nestingOptionsSeparator ? iOpts.nestingOptionsSeparator : iOpts.nestingOptionsSeparator || ',';
|
|
16402
|
+
this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000;
|
|
16403
|
+
this.alwaysFormat = iOpts.alwaysFormat !== undefined ? iOpts.alwaysFormat : false;
|
|
16404
|
+
this.resetRegExp();
|
|
16405
|
+
}
|
|
16406
|
+
}, {
|
|
16407
|
+
key: "reset",
|
|
16408
|
+
value: function reset() {
|
|
16409
|
+
if (this.options) this.init(this.options);
|
|
16410
|
+
}
|
|
16411
|
+
}, {
|
|
16412
|
+
key: "resetRegExp",
|
|
16413
|
+
value: function resetRegExp() {
|
|
16414
|
+
var regexpStr = ("").concat(this.prefix, "(.+?)").concat(this.suffix);
|
|
16415
|
+
this.regexp = new RegExp(regexpStr, 'g');
|
|
16416
|
+
var regexpUnescapeStr = ("").concat(this.prefix).concat(this.unescapePrefix, "(.+?)").concat(this.unescapeSuffix).concat(this.suffix);
|
|
16417
|
+
this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');
|
|
16418
|
+
var nestingRegexpStr = ("").concat(this.nestingPrefix, "(.+?)").concat(this.nestingSuffix);
|
|
16419
|
+
this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
|
|
16420
|
+
}
|
|
16421
|
+
}, {
|
|
16422
|
+
key: "interpolate",
|
|
16423
|
+
value: function interpolate(str, data, lng, options) {
|
|
16424
|
+
var _this = this;
|
|
16425
|
+
var match;
|
|
16426
|
+
var value;
|
|
16427
|
+
var replaces;
|
|
16428
|
+
var defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || ({});
|
|
16429
|
+
function regexSafe(val) {
|
|
16430
|
+
return val.replace(/\$/g, '$$$$');
|
|
16431
|
+
}
|
|
16432
|
+
var handleFormat = function handleFormat(key) {
|
|
16433
|
+
if (key.indexOf(_this.formatSeparator) < 0) {
|
|
16434
|
+
var path = deepFindWithDefaults(data, defaultData, key, _this.options.keySeparator, _this.options.ignoreJSONStructure);
|
|
16435
|
+
return _this.alwaysFormat ? _this.format(path, undefined, lng, _objectSpread$3(_objectSpread$3(_objectSpread$3({}, options), data), {}, {
|
|
16436
|
+
interpolationkey: key
|
|
16437
|
+
})) : path;
|
|
16438
|
+
}
|
|
16439
|
+
var p = key.split(_this.formatSeparator);
|
|
16440
|
+
var k = p.shift().trim();
|
|
16441
|
+
var f = p.join(_this.formatSeparator).trim();
|
|
16442
|
+
return _this.format(deepFindWithDefaults(data, defaultData, k, _this.options.keySeparator, _this.options.ignoreJSONStructure), f, lng, _objectSpread$3(_objectSpread$3(_objectSpread$3({}, options), data), {}, {
|
|
16443
|
+
interpolationkey: k
|
|
16444
|
+
}));
|
|
16445
|
+
};
|
|
16446
|
+
this.resetRegExp();
|
|
16447
|
+
var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
|
|
16448
|
+
var skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
16449
|
+
var todos = [{
|
|
16450
|
+
regex: this.regexpUnescape,
|
|
16451
|
+
safeValue: function safeValue(val) {
|
|
16452
|
+
return regexSafe(val);
|
|
16453
|
+
}
|
|
16454
|
+
}, {
|
|
16455
|
+
regex: this.regexp,
|
|
16456
|
+
safeValue: function safeValue(val) {
|
|
16457
|
+
return _this.escapeValue ? regexSafe(_this.escape(val)) : regexSafe(val);
|
|
16458
|
+
}
|
|
16459
|
+
}];
|
|
16460
|
+
todos.forEach(function (todo) {
|
|
16461
|
+
replaces = 0;
|
|
16462
|
+
while (match = todo.regex.exec(str)) {
|
|
16463
|
+
var matchedVar = match[1].trim();
|
|
16464
|
+
value = handleFormat(matchedVar);
|
|
16465
|
+
if (value === undefined) {
|
|
16466
|
+
if (typeof missingInterpolationHandler === 'function') {
|
|
16467
|
+
var temp = missingInterpolationHandler(str, match, options);
|
|
16468
|
+
value = typeof temp === 'string' ? temp : '';
|
|
16469
|
+
} else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
|
|
16470
|
+
value = '';
|
|
16471
|
+
} else if (skipOnVariables) {
|
|
16472
|
+
value = match[0];
|
|
16473
|
+
continue;
|
|
16474
|
+
} else {
|
|
16475
|
+
_this.logger.warn(("missed to pass in variable ").concat(matchedVar, " for interpolating ").concat(str));
|
|
16476
|
+
value = '';
|
|
16477
|
+
}
|
|
16478
|
+
} else if (typeof value !== 'string' && !_this.useRawValueToEscape) {
|
|
16479
|
+
value = makeString(value);
|
|
16480
|
+
}
|
|
16481
|
+
var safeValue = todo.safeValue(value);
|
|
16482
|
+
str = str.replace(match[0], safeValue);
|
|
16483
|
+
if (skipOnVariables) {
|
|
16484
|
+
todo.regex.lastIndex += value.length;
|
|
16485
|
+
todo.regex.lastIndex -= match[0].length;
|
|
16486
|
+
} else {
|
|
16487
|
+
todo.regex.lastIndex = 0;
|
|
16488
|
+
}
|
|
16489
|
+
replaces++;
|
|
16490
|
+
if (replaces >= _this.maxReplaces) {
|
|
16491
|
+
break;
|
|
16492
|
+
}
|
|
16493
|
+
}
|
|
16494
|
+
});
|
|
16495
|
+
return str;
|
|
16496
|
+
}
|
|
16497
|
+
}, {
|
|
16498
|
+
key: "nest",
|
|
16499
|
+
value: function nest(str, fc) {
|
|
16500
|
+
var _this2 = this;
|
|
16501
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
16502
|
+
var match;
|
|
16503
|
+
var value;
|
|
16504
|
+
var clonedOptions;
|
|
16505
|
+
function handleHasOptions(key, inheritedOptions) {
|
|
16506
|
+
var sep = this.nestingOptionsSeparator;
|
|
16507
|
+
if (key.indexOf(sep) < 0) return key;
|
|
16508
|
+
var c = key.split(new RegExp(("").concat(sep, "[ ]*{")));
|
|
16509
|
+
var optionsString = ("{").concat(c[1]);
|
|
16510
|
+
key = c[0];
|
|
16511
|
+
optionsString = this.interpolate(optionsString, clonedOptions);
|
|
16512
|
+
var matchedSingleQuotes = optionsString.match(/'/g);
|
|
16513
|
+
var matchedDoubleQuotes = optionsString.match(/"/g);
|
|
16514
|
+
if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
|
|
16515
|
+
optionsString = optionsString.replace(/'/g, '"');
|
|
16516
|
+
}
|
|
16517
|
+
try {
|
|
16518
|
+
clonedOptions = JSON.parse(optionsString);
|
|
16519
|
+
if (inheritedOptions) clonedOptions = _objectSpread$3(_objectSpread$3({}, inheritedOptions), clonedOptions);
|
|
16520
|
+
} catch (e) {
|
|
16521
|
+
this.logger.warn(("failed parsing options string in nesting for key ").concat(key), e);
|
|
16522
|
+
return ("").concat(key).concat(sep).concat(optionsString);
|
|
16523
|
+
}
|
|
16524
|
+
delete clonedOptions.defaultValue;
|
|
16525
|
+
return key;
|
|
16526
|
+
}
|
|
16527
|
+
while (match = this.nestingRegexp.exec(str)) {
|
|
16528
|
+
var formatters = [];
|
|
16529
|
+
clonedOptions = _objectSpread$3({}, options);
|
|
16530
|
+
clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;
|
|
16531
|
+
clonedOptions.applyPostProcessor = false;
|
|
16532
|
+
delete clonedOptions.defaultValue;
|
|
16533
|
+
var doReduce = false;
|
|
16534
|
+
if (match[0].indexOf(this.formatSeparator) !== -1 && !(/{.*}/).test(match[1])) {
|
|
16535
|
+
var r = match[1].split(this.formatSeparator).map(function (elem) {
|
|
16536
|
+
return elem.trim();
|
|
16537
|
+
});
|
|
16538
|
+
match[1] = r.shift();
|
|
16539
|
+
formatters = r;
|
|
16540
|
+
doReduce = true;
|
|
16541
|
+
}
|
|
16542
|
+
value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
|
|
16543
|
+
if (value && match[0] === str && typeof value !== 'string') return value;
|
|
16544
|
+
if (typeof value !== 'string') value = makeString(value);
|
|
16545
|
+
if (!value) {
|
|
16546
|
+
this.logger.warn(("missed to resolve ").concat(match[1], " for nesting ").concat(str));
|
|
16547
|
+
value = '';
|
|
16548
|
+
}
|
|
16549
|
+
if (doReduce) {
|
|
16550
|
+
value = formatters.reduce(function (v, f) {
|
|
16551
|
+
return _this2.format(v, f, options.lng, _objectSpread$3(_objectSpread$3({}, options), {}, {
|
|
16552
|
+
interpolationkey: match[1].trim()
|
|
16553
|
+
}));
|
|
16554
|
+
}, value.trim());
|
|
16555
|
+
}
|
|
16556
|
+
str = str.replace(match[0], value);
|
|
16557
|
+
this.regexp.lastIndex = 0;
|
|
16558
|
+
}
|
|
16559
|
+
return str;
|
|
16560
|
+
}
|
|
16561
|
+
}]);
|
|
16562
|
+
return Interpolator;
|
|
16563
|
+
})();
|
|
16564
|
+
function ownKeys$2(object, enumerableOnly) {
|
|
16565
|
+
var keys = Object.keys(object);
|
|
16566
|
+
if (Object.getOwnPropertySymbols) {
|
|
16567
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
16568
|
+
(enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
16569
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
16570
|
+
})), keys.push.apply(keys, symbols));
|
|
16571
|
+
}
|
|
16572
|
+
return keys;
|
|
16573
|
+
}
|
|
16574
|
+
function _objectSpread$2(target) {
|
|
16575
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
16576
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
16577
|
+
i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) {
|
|
16578
|
+
_defineProperty(target, key, source[key]);
|
|
16579
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) {
|
|
16580
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
16581
|
+
});
|
|
16582
|
+
}
|
|
16583
|
+
return target;
|
|
16584
|
+
}
|
|
16585
|
+
function parseFormatStr(formatStr) {
|
|
16586
|
+
var formatName = formatStr.toLowerCase().trim();
|
|
16587
|
+
var formatOptions = {};
|
|
16588
|
+
if (formatStr.indexOf('(') > -1) {
|
|
16589
|
+
var p = formatStr.split('(');
|
|
16590
|
+
formatName = p[0].toLowerCase().trim();
|
|
16591
|
+
var optStr = p[1].substring(0, p[1].length - 1);
|
|
16592
|
+
if (formatName === 'currency' && optStr.indexOf(':') < 0) {
|
|
16593
|
+
if (!formatOptions.currency) formatOptions.currency = optStr.trim();
|
|
16594
|
+
} else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
|
|
16595
|
+
if (!formatOptions.range) formatOptions.range = optStr.trim();
|
|
16596
|
+
} else {
|
|
16597
|
+
var opts = optStr.split(';');
|
|
16598
|
+
opts.forEach(function (opt) {
|
|
16599
|
+
if (!opt) return;
|
|
16600
|
+
var _opt$split = opt.split(':'), _opt$split2 = _toArray(_opt$split), key = _opt$split2[0], rest = _opt$split2.slice(1);
|
|
16601
|
+
var val = rest.join(':').trim().replace(/^'+|'+$/g, '');
|
|
16602
|
+
if (!formatOptions[key.trim()]) formatOptions[key.trim()] = val;
|
|
16603
|
+
if (val === 'false') formatOptions[key.trim()] = false;
|
|
16604
|
+
if (val === 'true') formatOptions[key.trim()] = true;
|
|
16605
|
+
if (!isNaN(val)) formatOptions[key.trim()] = parseInt(val, 10);
|
|
16606
|
+
});
|
|
16607
|
+
}
|
|
16608
|
+
}
|
|
16609
|
+
return {
|
|
16610
|
+
formatName: formatName,
|
|
16611
|
+
formatOptions: formatOptions
|
|
16612
|
+
};
|
|
16613
|
+
}
|
|
16614
|
+
function createCachedFormatter(fn) {
|
|
16615
|
+
var cache = {};
|
|
16616
|
+
return function invokeFormatter(val, lng, options) {
|
|
16617
|
+
var key = lng + JSON.stringify(options);
|
|
16618
|
+
var formatter = cache[key];
|
|
16619
|
+
if (!formatter) {
|
|
16620
|
+
formatter = fn(lng, options);
|
|
16621
|
+
cache[key] = formatter;
|
|
16622
|
+
}
|
|
16623
|
+
return formatter(val);
|
|
16624
|
+
};
|
|
16625
|
+
}
|
|
16626
|
+
var Formatter = (function () {
|
|
16627
|
+
function Formatter() {
|
|
16628
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
16629
|
+
_classCallCheck(this, Formatter);
|
|
16630
|
+
this.logger = baseLogger.create('formatter');
|
|
16631
|
+
this.options = options;
|
|
16632
|
+
this.formats = {
|
|
16633
|
+
number: createCachedFormatter(function (lng, opt) {
|
|
16634
|
+
var formatter = new Intl.NumberFormat(lng, _objectSpread$2({}, opt));
|
|
16635
|
+
return function (val) {
|
|
16636
|
+
return formatter.format(val);
|
|
16637
|
+
};
|
|
16638
|
+
}),
|
|
16639
|
+
currency: createCachedFormatter(function (lng, opt) {
|
|
16640
|
+
var formatter = new Intl.NumberFormat(lng, _objectSpread$2(_objectSpread$2({}, opt), {}, {
|
|
16641
|
+
style: 'currency'
|
|
16642
|
+
}));
|
|
16643
|
+
return function (val) {
|
|
16644
|
+
return formatter.format(val);
|
|
16645
|
+
};
|
|
16646
|
+
}),
|
|
16647
|
+
datetime: createCachedFormatter(function (lng, opt) {
|
|
16648
|
+
var formatter = new Intl.DateTimeFormat(lng, _objectSpread$2({}, opt));
|
|
16649
|
+
return function (val) {
|
|
16650
|
+
return formatter.format(val);
|
|
16651
|
+
};
|
|
16652
|
+
}),
|
|
16653
|
+
relativetime: createCachedFormatter(function (lng, opt) {
|
|
16654
|
+
var formatter = new Intl.RelativeTimeFormat(lng, _objectSpread$2({}, opt));
|
|
16655
|
+
return function (val) {
|
|
16656
|
+
return formatter.format(val, opt.range || 'day');
|
|
16657
|
+
};
|
|
16658
|
+
}),
|
|
16659
|
+
list: createCachedFormatter(function (lng, opt) {
|
|
16660
|
+
var formatter = new Intl.ListFormat(lng, _objectSpread$2({}, opt));
|
|
16661
|
+
return function (val) {
|
|
16662
|
+
return formatter.format(val);
|
|
16663
|
+
};
|
|
16664
|
+
})
|
|
16665
|
+
};
|
|
16666
|
+
this.init(options);
|
|
16667
|
+
}
|
|
16668
|
+
_createClass(Formatter, [{
|
|
16669
|
+
key: "init",
|
|
16670
|
+
value: function init(services) {
|
|
16671
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
16672
|
+
interpolation: {}
|
|
16673
|
+
};
|
|
16674
|
+
var iOpts = options.interpolation;
|
|
16675
|
+
this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
|
|
16676
|
+
}
|
|
16677
|
+
}, {
|
|
16678
|
+
key: "add",
|
|
16679
|
+
value: function add(name, fc) {
|
|
16680
|
+
this.formats[name.toLowerCase().trim()] = fc;
|
|
16681
|
+
}
|
|
16682
|
+
}, {
|
|
16683
|
+
key: "addCached",
|
|
16684
|
+
value: function addCached(name, fc) {
|
|
16685
|
+
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
16686
|
+
}
|
|
16687
|
+
}, {
|
|
16688
|
+
key: "format",
|
|
16689
|
+
value: function format(value, _format, lng) {
|
|
16690
|
+
var _this = this;
|
|
16691
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
16692
|
+
var formats = _format.split(this.formatSeparator);
|
|
16693
|
+
var result = formats.reduce(function (mem, f) {
|
|
16694
|
+
var _parseFormatStr = parseFormatStr(f), formatName = _parseFormatStr.formatName, formatOptions = _parseFormatStr.formatOptions;
|
|
16695
|
+
if (_this.formats[formatName]) {
|
|
16696
|
+
var formatted = mem;
|
|
16697
|
+
try {
|
|
16698
|
+
var valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || ({});
|
|
16699
|
+
var l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
|
|
16700
|
+
formatted = _this.formats[formatName](mem, l, _objectSpread$2(_objectSpread$2(_objectSpread$2({}, formatOptions), options), valOptions));
|
|
16701
|
+
} catch (error) {
|
|
16702
|
+
_this.logger.warn(error);
|
|
16703
|
+
}
|
|
16704
|
+
return formatted;
|
|
16705
|
+
} else {
|
|
16706
|
+
_this.logger.warn(("there was no format function for ").concat(formatName));
|
|
16707
|
+
}
|
|
16708
|
+
return mem;
|
|
16709
|
+
}, value);
|
|
16710
|
+
return result;
|
|
16711
|
+
}
|
|
16712
|
+
}]);
|
|
16713
|
+
return Formatter;
|
|
16714
|
+
})();
|
|
16715
|
+
function ownKeys$1(object, enumerableOnly) {
|
|
16716
|
+
var keys = Object.keys(object);
|
|
16717
|
+
if (Object.getOwnPropertySymbols) {
|
|
16718
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
16719
|
+
(enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
16720
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
16721
|
+
})), keys.push.apply(keys, symbols));
|
|
16722
|
+
}
|
|
16723
|
+
return keys;
|
|
16724
|
+
}
|
|
16725
|
+
function _objectSpread$1(target) {
|
|
16726
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
16727
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
16728
|
+
i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) {
|
|
16729
|
+
_defineProperty(target, key, source[key]);
|
|
16730
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) {
|
|
16731
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
16732
|
+
});
|
|
16733
|
+
}
|
|
16734
|
+
return target;
|
|
16735
|
+
}
|
|
16736
|
+
function _createSuper$1(Derived) {
|
|
16737
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
|
|
16738
|
+
return function _createSuperInternal() {
|
|
16739
|
+
var Super = _getPrototypeOf(Derived), result;
|
|
16740
|
+
if (hasNativeReflectConstruct) {
|
|
16741
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
16742
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
16743
|
+
} else {
|
|
16744
|
+
result = Super.apply(this, arguments);
|
|
16745
|
+
}
|
|
16746
|
+
return _possibleConstructorReturn(this, result);
|
|
16747
|
+
};
|
|
16748
|
+
}
|
|
16749
|
+
function _isNativeReflectConstruct$1() {
|
|
16750
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
16751
|
+
if (Reflect.construct.sham) return false;
|
|
16752
|
+
if (typeof Proxy === "function") return true;
|
|
16753
|
+
try {
|
|
16754
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
16755
|
+
return true;
|
|
16756
|
+
} catch (e) {
|
|
16757
|
+
return false;
|
|
16758
|
+
}
|
|
16759
|
+
}
|
|
16760
|
+
function removePending(q, name) {
|
|
16761
|
+
if (q.pending[name] !== undefined) {
|
|
16762
|
+
delete q.pending[name];
|
|
16763
|
+
q.pendingCount--;
|
|
16764
|
+
}
|
|
16765
|
+
}
|
|
16766
|
+
var Connector = (function (_EventEmitter) {
|
|
16767
|
+
_inherits(Connector, _EventEmitter);
|
|
16768
|
+
var _super = _createSuper$1(Connector);
|
|
16769
|
+
function Connector(backend, store, services) {
|
|
16770
|
+
var _this;
|
|
16771
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
16772
|
+
_classCallCheck(this, Connector);
|
|
16773
|
+
_this = _super.call(this);
|
|
16774
|
+
if (isIE10) {
|
|
16775
|
+
EventEmitter.call(_assertThisInitialized(_this));
|
|
16776
|
+
}
|
|
16777
|
+
_this.backend = backend;
|
|
16778
|
+
_this.store = store;
|
|
16779
|
+
_this.services = services;
|
|
16780
|
+
_this.languageUtils = services.languageUtils;
|
|
16781
|
+
_this.options = options;
|
|
16782
|
+
_this.logger = baseLogger.create('backendConnector');
|
|
16783
|
+
_this.waitingReads = [];
|
|
16784
|
+
_this.maxParallelReads = options.maxParallelReads || 10;
|
|
16785
|
+
_this.readingCalls = 0;
|
|
16786
|
+
_this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
|
|
16787
|
+
_this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
|
|
16788
|
+
_this.state = {};
|
|
16789
|
+
_this.queue = [];
|
|
16790
|
+
if (_this.backend && _this.backend.init) {
|
|
16791
|
+
_this.backend.init(services, options.backend, options);
|
|
16792
|
+
}
|
|
16793
|
+
return _this;
|
|
16794
|
+
}
|
|
16795
|
+
_createClass(Connector, [{
|
|
16796
|
+
key: "queueLoad",
|
|
16797
|
+
value: function queueLoad(languages, namespaces, options, callback) {
|
|
16798
|
+
var _this2 = this;
|
|
16799
|
+
var toLoad = {};
|
|
16800
|
+
var pending = {};
|
|
16801
|
+
var toLoadLanguages = {};
|
|
16802
|
+
var toLoadNamespaces = {};
|
|
16803
|
+
languages.forEach(function (lng) {
|
|
16804
|
+
var hasAllNamespaces = true;
|
|
16805
|
+
namespaces.forEach(function (ns) {
|
|
16806
|
+
var name = ("").concat(lng, "|").concat(ns);
|
|
16807
|
+
if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
|
|
16808
|
+
_this2.state[name] = 2;
|
|
16809
|
+
} else if (_this2.state[name] < 0) ; else if (_this2.state[name] === 1) {
|
|
16810
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
16811
|
+
} else {
|
|
16812
|
+
_this2.state[name] = 1;
|
|
16813
|
+
hasAllNamespaces = false;
|
|
16814
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
16815
|
+
if (toLoad[name] === undefined) toLoad[name] = true;
|
|
16816
|
+
if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
|
|
16817
|
+
}
|
|
16818
|
+
});
|
|
16819
|
+
if (!hasAllNamespaces) toLoadLanguages[lng] = true;
|
|
16820
|
+
});
|
|
16821
|
+
if (Object.keys(toLoad).length || Object.keys(pending).length) {
|
|
16822
|
+
this.queue.push({
|
|
16823
|
+
pending: pending,
|
|
16824
|
+
pendingCount: Object.keys(pending).length,
|
|
16825
|
+
loaded: {},
|
|
16826
|
+
errors: [],
|
|
16827
|
+
callback: callback
|
|
16828
|
+
});
|
|
16829
|
+
}
|
|
16830
|
+
return {
|
|
16831
|
+
toLoad: Object.keys(toLoad),
|
|
16832
|
+
pending: Object.keys(pending),
|
|
16833
|
+
toLoadLanguages: Object.keys(toLoadLanguages),
|
|
16834
|
+
toLoadNamespaces: Object.keys(toLoadNamespaces)
|
|
16835
|
+
};
|
|
16836
|
+
}
|
|
16837
|
+
}, {
|
|
16838
|
+
key: "loaded",
|
|
16839
|
+
value: function loaded(name, err, data) {
|
|
16840
|
+
var s = name.split('|');
|
|
16841
|
+
var lng = s[0];
|
|
16842
|
+
var ns = s[1];
|
|
16843
|
+
if (err) this.emit('failedLoading', lng, ns, err);
|
|
16844
|
+
if (data) {
|
|
16845
|
+
this.store.addResourceBundle(lng, ns, data);
|
|
16846
|
+
}
|
|
16847
|
+
this.state[name] = err ? -1 : 2;
|
|
16848
|
+
var loaded = {};
|
|
16849
|
+
this.queue.forEach(function (q) {
|
|
16850
|
+
pushPath(q.loaded, [lng], ns);
|
|
16851
|
+
removePending(q, name);
|
|
16852
|
+
if (err) q.errors.push(err);
|
|
16853
|
+
if (q.pendingCount === 0 && !q.done) {
|
|
16854
|
+
Object.keys(q.loaded).forEach(function (l) {
|
|
16855
|
+
if (!loaded[l]) loaded[l] = {};
|
|
16856
|
+
var loadedKeys = q.loaded[l];
|
|
16857
|
+
if (loadedKeys.length) {
|
|
16858
|
+
loadedKeys.forEach(function (n) {
|
|
16859
|
+
if (loaded[l][n] === undefined) loaded[l][n] = true;
|
|
16860
|
+
});
|
|
16861
|
+
}
|
|
16862
|
+
});
|
|
16863
|
+
q.done = true;
|
|
16864
|
+
if (q.errors.length) {
|
|
16865
|
+
q.callback(q.errors);
|
|
16866
|
+
} else {
|
|
16867
|
+
q.callback();
|
|
16868
|
+
}
|
|
16869
|
+
}
|
|
16870
|
+
});
|
|
16871
|
+
this.emit('loaded', loaded);
|
|
16872
|
+
this.queue = this.queue.filter(function (q) {
|
|
16873
|
+
return !q.done;
|
|
16874
|
+
});
|
|
16875
|
+
}
|
|
16876
|
+
}, {
|
|
16877
|
+
key: "read",
|
|
16878
|
+
value: function read(lng, ns, fcName) {
|
|
16879
|
+
var _this3 = this;
|
|
16880
|
+
var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
16881
|
+
var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
|
|
16882
|
+
var callback = arguments.length > 5 ? arguments[5] : undefined;
|
|
16883
|
+
if (!lng.length) return callback(null, {});
|
|
16884
|
+
if (this.readingCalls >= this.maxParallelReads) {
|
|
16885
|
+
this.waitingReads.push({
|
|
16886
|
+
lng: lng,
|
|
16887
|
+
ns: ns,
|
|
16888
|
+
fcName: fcName,
|
|
16889
|
+
tried: tried,
|
|
16890
|
+
wait: wait,
|
|
16891
|
+
callback: callback
|
|
16892
|
+
});
|
|
16893
|
+
return;
|
|
16894
|
+
}
|
|
16895
|
+
this.readingCalls++;
|
|
16896
|
+
var resolver = function resolver(err, data) {
|
|
16897
|
+
_this3.readingCalls--;
|
|
16898
|
+
if (_this3.waitingReads.length > 0) {
|
|
16899
|
+
var next = _this3.waitingReads.shift();
|
|
16900
|
+
_this3.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
|
|
16901
|
+
}
|
|
16902
|
+
if (err && data && tried < _this3.maxRetries) {
|
|
16903
|
+
setTimeout(function () {
|
|
16904
|
+
_this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
|
|
16905
|
+
}, wait);
|
|
16906
|
+
return;
|
|
16907
|
+
}
|
|
16908
|
+
callback(err, data);
|
|
16909
|
+
};
|
|
16910
|
+
var fc = this.backend[fcName].bind(this.backend);
|
|
16911
|
+
if (fc.length === 2) {
|
|
16912
|
+
try {
|
|
16913
|
+
var r = fc(lng, ns);
|
|
16914
|
+
if (r && typeof r.then === 'function') {
|
|
16915
|
+
r.then(function (data) {
|
|
16916
|
+
return resolver(null, data);
|
|
16917
|
+
})["catch"](resolver);
|
|
16918
|
+
} else {
|
|
16919
|
+
resolver(null, r);
|
|
16920
|
+
}
|
|
16921
|
+
} catch (err) {
|
|
16922
|
+
resolver(err);
|
|
16923
|
+
}
|
|
16924
|
+
return;
|
|
16925
|
+
}
|
|
16926
|
+
return fc(lng, ns, resolver);
|
|
16927
|
+
}
|
|
16928
|
+
}, {
|
|
16929
|
+
key: "prepareLoading",
|
|
16930
|
+
value: function prepareLoading(languages, namespaces) {
|
|
16931
|
+
var _this4 = this;
|
|
16932
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
16933
|
+
var callback = arguments.length > 3 ? arguments[3] : undefined;
|
|
16934
|
+
if (!this.backend) {
|
|
16935
|
+
this.logger.warn('No backend was added via i18next.use. Will not load resources.');
|
|
16936
|
+
return callback && callback();
|
|
16937
|
+
}
|
|
16938
|
+
if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
|
|
16939
|
+
if (typeof namespaces === 'string') namespaces = [namespaces];
|
|
16940
|
+
var toLoad = this.queueLoad(languages, namespaces, options, callback);
|
|
16941
|
+
if (!toLoad.toLoad.length) {
|
|
16942
|
+
if (!toLoad.pending.length) callback();
|
|
16943
|
+
return null;
|
|
16944
|
+
}
|
|
16945
|
+
toLoad.toLoad.forEach(function (name) {
|
|
16946
|
+
_this4.loadOne(name);
|
|
16947
|
+
});
|
|
16948
|
+
}
|
|
16949
|
+
}, {
|
|
16950
|
+
key: "load",
|
|
16951
|
+
value: function load(languages, namespaces, callback) {
|
|
16952
|
+
this.prepareLoading(languages, namespaces, {}, callback);
|
|
16953
|
+
}
|
|
16954
|
+
}, {
|
|
16955
|
+
key: "reload",
|
|
16956
|
+
value: function reload(languages, namespaces, callback) {
|
|
16957
|
+
this.prepareLoading(languages, namespaces, {
|
|
16958
|
+
reload: true
|
|
16959
|
+
}, callback);
|
|
16960
|
+
}
|
|
16961
|
+
}, {
|
|
16962
|
+
key: "loadOne",
|
|
16963
|
+
value: function loadOne(name) {
|
|
16964
|
+
var _this5 = this;
|
|
16965
|
+
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
16966
|
+
var s = name.split('|');
|
|
16967
|
+
var lng = s[0];
|
|
16968
|
+
var ns = s[1];
|
|
16969
|
+
this.read(lng, ns, 'read', undefined, undefined, function (err, data) {
|
|
16970
|
+
if (err) _this5.logger.warn(("").concat(prefix, "loading namespace ").concat(ns, " for language ").concat(lng, " failed"), err);
|
|
16971
|
+
if (!err && data) _this5.logger.log(("").concat(prefix, "loaded namespace ").concat(ns, " for language ").concat(lng), data);
|
|
16972
|
+
_this5.loaded(name, err, data);
|
|
16973
|
+
});
|
|
16974
|
+
}
|
|
16975
|
+
}, {
|
|
16976
|
+
key: "saveMissing",
|
|
16977
|
+
value: function saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
|
|
16978
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
16979
|
+
var clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : function () {};
|
|
16980
|
+
if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
|
|
16981
|
+
this.logger.warn(("did not save key \"").concat(key, "\" as the namespace \"").concat(namespace, "\" was not yet loaded"), 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
|
|
16982
|
+
return;
|
|
16983
|
+
}
|
|
16984
|
+
if (key === undefined || key === null || key === '') return;
|
|
16985
|
+
if (this.backend && this.backend.create) {
|
|
16986
|
+
var opts = _objectSpread$1(_objectSpread$1({}, options), {}, {
|
|
16987
|
+
isUpdate: isUpdate
|
|
16988
|
+
});
|
|
16989
|
+
var fc = this.backend.create.bind(this.backend);
|
|
16990
|
+
if (fc.length < 6) {
|
|
16991
|
+
try {
|
|
16992
|
+
var r;
|
|
16993
|
+
if (fc.length === 5) {
|
|
16994
|
+
r = fc(languages, namespace, key, fallbackValue, opts);
|
|
16995
|
+
} else {
|
|
16996
|
+
r = fc(languages, namespace, key, fallbackValue);
|
|
16997
|
+
}
|
|
16998
|
+
if (r && typeof r.then === 'function') {
|
|
16999
|
+
r.then(function (data) {
|
|
17000
|
+
return clb(null, data);
|
|
17001
|
+
})["catch"](clb);
|
|
17002
|
+
} else {
|
|
17003
|
+
clb(null, r);
|
|
17004
|
+
}
|
|
17005
|
+
} catch (err) {
|
|
17006
|
+
clb(err);
|
|
17007
|
+
}
|
|
17008
|
+
} else {
|
|
17009
|
+
fc(languages, namespace, key, fallbackValue, clb, opts);
|
|
17010
|
+
}
|
|
17011
|
+
}
|
|
17012
|
+
if (!languages || !languages[0]) return;
|
|
17013
|
+
this.store.addResource(languages[0], namespace, key, fallbackValue);
|
|
17014
|
+
}
|
|
17015
|
+
}]);
|
|
17016
|
+
return Connector;
|
|
17017
|
+
})(EventEmitter);
|
|
17018
|
+
function get() {
|
|
17019
|
+
return {
|
|
17020
|
+
debug: false,
|
|
17021
|
+
initImmediate: true,
|
|
17022
|
+
ns: ['translation'],
|
|
17023
|
+
defaultNS: ['translation'],
|
|
17024
|
+
fallbackLng: ['dev'],
|
|
17025
|
+
fallbackNS: false,
|
|
17026
|
+
supportedLngs: false,
|
|
17027
|
+
nonExplicitSupportedLngs: false,
|
|
17028
|
+
load: 'all',
|
|
17029
|
+
preload: false,
|
|
17030
|
+
simplifyPluralSuffix: true,
|
|
17031
|
+
keySeparator: '.',
|
|
17032
|
+
nsSeparator: ':',
|
|
17033
|
+
pluralSeparator: '_',
|
|
17034
|
+
contextSeparator: '_',
|
|
17035
|
+
partialBundledLanguages: false,
|
|
17036
|
+
saveMissing: false,
|
|
17037
|
+
updateMissing: false,
|
|
17038
|
+
saveMissingTo: 'fallback',
|
|
17039
|
+
saveMissingPlurals: true,
|
|
17040
|
+
missingKeyHandler: false,
|
|
17041
|
+
missingInterpolationHandler: false,
|
|
17042
|
+
postProcess: false,
|
|
17043
|
+
postProcessPassResolved: false,
|
|
17044
|
+
returnNull: true,
|
|
17045
|
+
returnEmptyString: true,
|
|
17046
|
+
returnObjects: false,
|
|
17047
|
+
joinArrays: false,
|
|
17048
|
+
returnedObjectHandler: false,
|
|
17049
|
+
parseMissingKeyHandler: false,
|
|
17050
|
+
appendNamespaceToMissingKey: false,
|
|
17051
|
+
appendNamespaceToCIMode: false,
|
|
17052
|
+
overloadTranslationOptionHandler: function handle(args) {
|
|
17053
|
+
var ret = {};
|
|
17054
|
+
if (_typeof(args[1]) === 'object') ret = args[1];
|
|
17055
|
+
if (typeof args[1] === 'string') ret.defaultValue = args[1];
|
|
17056
|
+
if (typeof args[2] === 'string') ret.tDescription = args[2];
|
|
17057
|
+
if (_typeof(args[2]) === 'object' || _typeof(args[3]) === 'object') {
|
|
17058
|
+
var options = args[3] || args[2];
|
|
17059
|
+
Object.keys(options).forEach(function (key) {
|
|
17060
|
+
ret[key] = options[key];
|
|
17061
|
+
});
|
|
17062
|
+
}
|
|
17063
|
+
return ret;
|
|
17064
|
+
},
|
|
17065
|
+
interpolation: {
|
|
17066
|
+
escapeValue: true,
|
|
17067
|
+
format: function format(value, _format, lng, options) {
|
|
17068
|
+
return value;
|
|
17069
|
+
},
|
|
17070
|
+
prefix: '{{',
|
|
17071
|
+
suffix: '}}',
|
|
17072
|
+
formatSeparator: ',',
|
|
17073
|
+
unescapePrefix: '-',
|
|
17074
|
+
nestingPrefix: '$t(',
|
|
17075
|
+
nestingSuffix: ')',
|
|
17076
|
+
nestingOptionsSeparator: ',',
|
|
17077
|
+
maxReplaces: 1000,
|
|
17078
|
+
skipOnVariables: true
|
|
17079
|
+
}
|
|
17080
|
+
};
|
|
17081
|
+
}
|
|
17082
|
+
function transformOptions(options) {
|
|
17083
|
+
if (typeof options.ns === 'string') options.ns = [options.ns];
|
|
17084
|
+
if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
|
|
17085
|
+
if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
|
|
17086
|
+
if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
|
|
17087
|
+
options.supportedLngs = options.supportedLngs.concat(['cimode']);
|
|
17088
|
+
}
|
|
17089
|
+
return options;
|
|
17090
|
+
}
|
|
17091
|
+
function ownKeys(object, enumerableOnly) {
|
|
17092
|
+
var keys = Object.keys(object);
|
|
17093
|
+
if (Object.getOwnPropertySymbols) {
|
|
17094
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
17095
|
+
(enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
17096
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
17097
|
+
})), keys.push.apply(keys, symbols));
|
|
17098
|
+
}
|
|
17099
|
+
return keys;
|
|
17100
|
+
}
|
|
17101
|
+
function _objectSpread(target) {
|
|
17102
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
17103
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
17104
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
17105
|
+
_defineProperty(target, key, source[key]);
|
|
17106
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
17107
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
17108
|
+
});
|
|
17109
|
+
}
|
|
17110
|
+
return target;
|
|
17111
|
+
}
|
|
17112
|
+
function _createSuper(Derived) {
|
|
17113
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
17114
|
+
return function _createSuperInternal() {
|
|
17115
|
+
var Super = _getPrototypeOf(Derived), result;
|
|
17116
|
+
if (hasNativeReflectConstruct) {
|
|
17117
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
17118
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
17119
|
+
} else {
|
|
17120
|
+
result = Super.apply(this, arguments);
|
|
17121
|
+
}
|
|
17122
|
+
return _possibleConstructorReturn(this, result);
|
|
17123
|
+
};
|
|
17124
|
+
}
|
|
17125
|
+
function _isNativeReflectConstruct() {
|
|
17126
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
17127
|
+
if (Reflect.construct.sham) return false;
|
|
17128
|
+
if (typeof Proxy === "function") return true;
|
|
17129
|
+
try {
|
|
17130
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
17131
|
+
return true;
|
|
17132
|
+
} catch (e) {
|
|
17133
|
+
return false;
|
|
17134
|
+
}
|
|
17135
|
+
}
|
|
17136
|
+
function noop() {}
|
|
17137
|
+
function bindMemberFunctions(inst) {
|
|
17138
|
+
var mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
|
|
17139
|
+
mems.forEach(function (mem) {
|
|
17140
|
+
if (typeof inst[mem] === 'function') {
|
|
17141
|
+
inst[mem] = inst[mem].bind(inst);
|
|
17142
|
+
}
|
|
17143
|
+
});
|
|
17144
|
+
}
|
|
17145
|
+
var I18n = (function (_EventEmitter) {
|
|
17146
|
+
_inherits(I18n, _EventEmitter);
|
|
17147
|
+
var _super = _createSuper(I18n);
|
|
17148
|
+
function I18n() {
|
|
17149
|
+
var _this;
|
|
17150
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
17151
|
+
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
17152
|
+
_classCallCheck(this, I18n);
|
|
17153
|
+
_this = _super.call(this);
|
|
17154
|
+
if (isIE10) {
|
|
17155
|
+
EventEmitter.call(_assertThisInitialized(_this));
|
|
17156
|
+
}
|
|
17157
|
+
_this.options = transformOptions(options);
|
|
17158
|
+
_this.services = {};
|
|
17159
|
+
_this.logger = baseLogger;
|
|
17160
|
+
_this.modules = {
|
|
17161
|
+
external: []
|
|
17162
|
+
};
|
|
17163
|
+
bindMemberFunctions(_assertThisInitialized(_this));
|
|
17164
|
+
if (callback && !_this.isInitialized && !options.isClone) {
|
|
17165
|
+
if (!_this.options.initImmediate) {
|
|
17166
|
+
_this.init(options, callback);
|
|
17167
|
+
return _possibleConstructorReturn(_this, _assertThisInitialized(_this));
|
|
17168
|
+
}
|
|
17169
|
+
setTimeout(function () {
|
|
17170
|
+
_this.init(options, callback);
|
|
17171
|
+
}, 0);
|
|
17172
|
+
}
|
|
17173
|
+
return _this;
|
|
17174
|
+
}
|
|
17175
|
+
_createClass(I18n, [{
|
|
17176
|
+
key: "init",
|
|
17177
|
+
value: function init() {
|
|
17178
|
+
var _this2 = this;
|
|
17179
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
17180
|
+
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
17181
|
+
if (typeof options === 'function') {
|
|
17182
|
+
callback = options;
|
|
17183
|
+
options = {};
|
|
17184
|
+
}
|
|
17185
|
+
if (!options.defaultNS && options.defaultNS !== false && options.ns) {
|
|
17186
|
+
if (typeof options.ns === 'string') {
|
|
17187
|
+
options.defaultNS = options.ns;
|
|
17188
|
+
} else if (options.ns.indexOf('translation') < 0) {
|
|
17189
|
+
options.defaultNS = options.ns[0];
|
|
17190
|
+
}
|
|
17191
|
+
}
|
|
17192
|
+
var defOpts = get();
|
|
17193
|
+
this.options = _objectSpread(_objectSpread(_objectSpread({}, defOpts), this.options), transformOptions(options));
|
|
17194
|
+
if (this.options.compatibilityAPI !== 'v1') {
|
|
17195
|
+
this.options.interpolation = _objectSpread(_objectSpread({}, defOpts.interpolation), this.options.interpolation);
|
|
17196
|
+
}
|
|
17197
|
+
if (options.keySeparator !== undefined) {
|
|
17198
|
+
this.options.userDefinedKeySeparator = options.keySeparator;
|
|
17199
|
+
}
|
|
17200
|
+
if (options.nsSeparator !== undefined) {
|
|
17201
|
+
this.options.userDefinedNsSeparator = options.nsSeparator;
|
|
17202
|
+
}
|
|
17203
|
+
function createClassOnDemand(ClassOrObject) {
|
|
17204
|
+
if (!ClassOrObject) return null;
|
|
17205
|
+
if (typeof ClassOrObject === 'function') return new ClassOrObject();
|
|
17206
|
+
return ClassOrObject;
|
|
17207
|
+
}
|
|
17208
|
+
if (!this.options.isClone) {
|
|
17209
|
+
if (this.modules.logger) {
|
|
17210
|
+
baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
|
|
17211
|
+
} else {
|
|
17212
|
+
baseLogger.init(null, this.options);
|
|
17213
|
+
}
|
|
17214
|
+
var formatter;
|
|
17215
|
+
if (this.modules.formatter) {
|
|
17216
|
+
formatter = this.modules.formatter;
|
|
17217
|
+
} else if (typeof Intl !== 'undefined') {
|
|
17218
|
+
formatter = Formatter;
|
|
17219
|
+
}
|
|
17220
|
+
var lu = new LanguageUtil(this.options);
|
|
17221
|
+
this.store = new ResourceStore(this.options.resources, this.options);
|
|
17222
|
+
var s = this.services;
|
|
17223
|
+
s.logger = baseLogger;
|
|
17224
|
+
s.resourceStore = this.store;
|
|
17225
|
+
s.languageUtils = lu;
|
|
17226
|
+
s.pluralResolver = new PluralResolver(lu, {
|
|
17227
|
+
prepend: this.options.pluralSeparator,
|
|
17228
|
+
compatibilityJSON: this.options.compatibilityJSON,
|
|
17229
|
+
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
17230
|
+
});
|
|
17231
|
+
if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
|
|
17232
|
+
s.formatter = createClassOnDemand(formatter);
|
|
17233
|
+
s.formatter.init(s, this.options);
|
|
17234
|
+
this.options.interpolation.format = s.formatter.format.bind(s.formatter);
|
|
17235
|
+
}
|
|
17236
|
+
s.interpolator = new Interpolator(this.options);
|
|
17237
|
+
s.utils = {
|
|
17238
|
+
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
17239
|
+
};
|
|
17240
|
+
s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
|
|
17241
|
+
s.backendConnector.on('*', function (event) {
|
|
17242
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
17243
|
+
args[_key - 1] = arguments[_key];
|
|
17244
|
+
}
|
|
17245
|
+
_this2.emit.apply(_this2, [event].concat(args));
|
|
17246
|
+
});
|
|
17247
|
+
if (this.modules.languageDetector) {
|
|
17248
|
+
s.languageDetector = createClassOnDemand(this.modules.languageDetector);
|
|
17249
|
+
if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
|
|
17250
|
+
}
|
|
17251
|
+
if (this.modules.i18nFormat) {
|
|
17252
|
+
s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
|
|
17253
|
+
if (s.i18nFormat.init) s.i18nFormat.init(this);
|
|
17254
|
+
}
|
|
17255
|
+
this.translator = new Translator(this.services, this.options);
|
|
17256
|
+
this.translator.on('*', function (event) {
|
|
17257
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
17258
|
+
args[_key2 - 1] = arguments[_key2];
|
|
17259
|
+
}
|
|
17260
|
+
_this2.emit.apply(_this2, [event].concat(args));
|
|
17261
|
+
});
|
|
17262
|
+
this.modules.external.forEach(function (m) {
|
|
17263
|
+
if (m.init) m.init(_this2);
|
|
17264
|
+
});
|
|
17265
|
+
}
|
|
17266
|
+
this.format = this.options.interpolation.format;
|
|
17267
|
+
if (!callback) callback = noop;
|
|
17268
|
+
if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
17269
|
+
var codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
17270
|
+
if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
|
|
17271
|
+
}
|
|
17272
|
+
if (!this.services.languageDetector && !this.options.lng) {
|
|
17273
|
+
this.logger.warn('init: no languageDetector is used and no lng is defined');
|
|
17274
|
+
}
|
|
17275
|
+
var storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
|
|
17276
|
+
storeApi.forEach(function (fcName) {
|
|
17277
|
+
_this2[fcName] = function () {
|
|
17278
|
+
var _this2$store;
|
|
17279
|
+
return (_this2$store = _this2.store)[fcName].apply(_this2$store, arguments);
|
|
17280
|
+
};
|
|
17281
|
+
});
|
|
17282
|
+
var storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
|
|
17283
|
+
storeApiChained.forEach(function (fcName) {
|
|
17284
|
+
_this2[fcName] = function () {
|
|
17285
|
+
var _this2$store2;
|
|
17286
|
+
(_this2$store2 = _this2.store)[fcName].apply(_this2$store2, arguments);
|
|
17287
|
+
return _this2;
|
|
17288
|
+
};
|
|
17289
|
+
});
|
|
17290
|
+
var deferred = defer();
|
|
17291
|
+
var load = function load() {
|
|
17292
|
+
var finish = function finish(err, t) {
|
|
17293
|
+
if (_this2.isInitialized && !_this2.initializedStoreOnce) _this2.logger.warn('init: i18next is already initialized. You should call init just once!');
|
|
17294
|
+
_this2.isInitialized = true;
|
|
17295
|
+
if (!_this2.options.isClone) _this2.logger.log('initialized', _this2.options);
|
|
17296
|
+
_this2.emit('initialized', _this2.options);
|
|
17297
|
+
deferred.resolve(t);
|
|
17298
|
+
callback(err, t);
|
|
17299
|
+
};
|
|
17300
|
+
if (_this2.languages && _this2.options.compatibilityAPI !== 'v1' && !_this2.isInitialized) return finish(null, _this2.t.bind(_this2));
|
|
17301
|
+
_this2.changeLanguage(_this2.options.lng, finish);
|
|
17302
|
+
};
|
|
17303
|
+
if (this.options.resources || !this.options.initImmediate) {
|
|
17304
|
+
load();
|
|
17305
|
+
} else {
|
|
17306
|
+
setTimeout(load, 0);
|
|
17307
|
+
}
|
|
17308
|
+
return deferred;
|
|
17309
|
+
}
|
|
17310
|
+
}, {
|
|
17311
|
+
key: "loadResources",
|
|
17312
|
+
value: function loadResources(language) {
|
|
17313
|
+
var _this3 = this;
|
|
17314
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
|
17315
|
+
var usedCallback = callback;
|
|
17316
|
+
var usedLng = typeof language === 'string' ? language : this.language;
|
|
17317
|
+
if (typeof language === 'function') usedCallback = language;
|
|
17318
|
+
if (!this.options.resources || this.options.partialBundledLanguages) {
|
|
17319
|
+
if (usedLng && usedLng.toLowerCase() === 'cimode') return usedCallback();
|
|
17320
|
+
var toLoad = [];
|
|
17321
|
+
var append = function append(lng) {
|
|
17322
|
+
if (!lng) return;
|
|
17323
|
+
var lngs = _this3.services.languageUtils.toResolveHierarchy(lng);
|
|
17324
|
+
lngs.forEach(function (l) {
|
|
17325
|
+
if (toLoad.indexOf(l) < 0) toLoad.push(l);
|
|
17326
|
+
});
|
|
17327
|
+
};
|
|
17328
|
+
if (!usedLng) {
|
|
17329
|
+
var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
17330
|
+
fallbacks.forEach(function (l) {
|
|
17331
|
+
return append(l);
|
|
17332
|
+
});
|
|
17333
|
+
} else {
|
|
17334
|
+
append(usedLng);
|
|
17335
|
+
}
|
|
17336
|
+
if (this.options.preload) {
|
|
17337
|
+
this.options.preload.forEach(function (l) {
|
|
17338
|
+
return append(l);
|
|
17339
|
+
});
|
|
17340
|
+
}
|
|
17341
|
+
this.services.backendConnector.load(toLoad, this.options.ns, function (e) {
|
|
17342
|
+
if (!e && !_this3.resolvedLanguage && _this3.language) _this3.setResolvedLanguage(_this3.language);
|
|
17343
|
+
usedCallback(e);
|
|
17344
|
+
});
|
|
17345
|
+
} else {
|
|
17346
|
+
usedCallback(null);
|
|
17347
|
+
}
|
|
17348
|
+
}
|
|
17349
|
+
}, {
|
|
17350
|
+
key: "reloadResources",
|
|
17351
|
+
value: function reloadResources(lngs, ns, callback) {
|
|
17352
|
+
var deferred = defer();
|
|
17353
|
+
if (!lngs) lngs = this.languages;
|
|
17354
|
+
if (!ns) ns = this.options.ns;
|
|
17355
|
+
if (!callback) callback = noop;
|
|
17356
|
+
this.services.backendConnector.reload(lngs, ns, function (err) {
|
|
17357
|
+
deferred.resolve();
|
|
17358
|
+
callback(err);
|
|
17359
|
+
});
|
|
17360
|
+
return deferred;
|
|
17361
|
+
}
|
|
17362
|
+
}, {
|
|
17363
|
+
key: "use",
|
|
17364
|
+
value: function use(module) {
|
|
17365
|
+
if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
|
|
17366
|
+
if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
|
|
17367
|
+
if (module.type === 'backend') {
|
|
17368
|
+
this.modules.backend = module;
|
|
17369
|
+
}
|
|
17370
|
+
if (module.type === 'logger' || module.log && module.warn && module.error) {
|
|
17371
|
+
this.modules.logger = module;
|
|
17372
|
+
}
|
|
17373
|
+
if (module.type === 'languageDetector') {
|
|
17374
|
+
this.modules.languageDetector = module;
|
|
17375
|
+
}
|
|
17376
|
+
if (module.type === 'i18nFormat') {
|
|
17377
|
+
this.modules.i18nFormat = module;
|
|
17378
|
+
}
|
|
17379
|
+
if (module.type === 'postProcessor') {
|
|
17380
|
+
postProcessor.addPostProcessor(module);
|
|
17381
|
+
}
|
|
17382
|
+
if (module.type === 'formatter') {
|
|
17383
|
+
this.modules.formatter = module;
|
|
17384
|
+
}
|
|
17385
|
+
if (module.type === '3rdParty') {
|
|
17386
|
+
this.modules.external.push(module);
|
|
17387
|
+
}
|
|
17388
|
+
return this;
|
|
17389
|
+
}
|
|
17390
|
+
}, {
|
|
17391
|
+
key: "setResolvedLanguage",
|
|
17392
|
+
value: function setResolvedLanguage(l) {
|
|
17393
|
+
if (!l || !this.languages) return;
|
|
17394
|
+
if (['cimode', 'dev'].indexOf(l) > -1) return;
|
|
17395
|
+
for (var li = 0; li < this.languages.length; li++) {
|
|
17396
|
+
var lngInLngs = this.languages[li];
|
|
17397
|
+
if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
|
|
17398
|
+
if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
|
|
17399
|
+
this.resolvedLanguage = lngInLngs;
|
|
17400
|
+
break;
|
|
17401
|
+
}
|
|
17402
|
+
}
|
|
17403
|
+
}
|
|
17404
|
+
}, {
|
|
17405
|
+
key: "changeLanguage",
|
|
17406
|
+
value: function changeLanguage(lng, callback) {
|
|
17407
|
+
var _this4 = this;
|
|
17408
|
+
this.isLanguageChangingTo = lng;
|
|
17409
|
+
var deferred = defer();
|
|
17410
|
+
this.emit('languageChanging', lng);
|
|
17411
|
+
var setLngProps = function setLngProps(l) {
|
|
17412
|
+
_this4.language = l;
|
|
17413
|
+
_this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);
|
|
17414
|
+
_this4.resolvedLanguage = undefined;
|
|
17415
|
+
_this4.setResolvedLanguage(l);
|
|
17416
|
+
};
|
|
17417
|
+
var done = function done(err, l) {
|
|
17418
|
+
if (l) {
|
|
17419
|
+
setLngProps(l);
|
|
17420
|
+
_this4.translator.changeLanguage(l);
|
|
17421
|
+
_this4.isLanguageChangingTo = undefined;
|
|
17422
|
+
_this4.emit('languageChanged', l);
|
|
17423
|
+
_this4.logger.log('languageChanged', l);
|
|
17424
|
+
} else {
|
|
17425
|
+
_this4.isLanguageChangingTo = undefined;
|
|
17426
|
+
}
|
|
17427
|
+
deferred.resolve(function () {
|
|
17428
|
+
return _this4.t.apply(_this4, arguments);
|
|
17429
|
+
});
|
|
17430
|
+
if (callback) callback(err, function () {
|
|
17431
|
+
return _this4.t.apply(_this4, arguments);
|
|
17432
|
+
});
|
|
17433
|
+
};
|
|
17434
|
+
var setLng = function setLng(lngs) {
|
|
17435
|
+
if (!lng && !lngs && _this4.services.languageDetector) lngs = [];
|
|
17436
|
+
var l = typeof lngs === 'string' ? lngs : _this4.services.languageUtils.getBestMatchFromCodes(lngs);
|
|
17437
|
+
if (l) {
|
|
17438
|
+
if (!_this4.language) {
|
|
17439
|
+
setLngProps(l);
|
|
17440
|
+
}
|
|
17441
|
+
if (!_this4.translator.language) _this4.translator.changeLanguage(l);
|
|
17442
|
+
if (_this4.services.languageDetector && _this4.services.languageDetector.cacheUserLanguage) _this4.services.languageDetector.cacheUserLanguage(l);
|
|
17443
|
+
}
|
|
17444
|
+
_this4.loadResources(l, function (err) {
|
|
17445
|
+
done(err, l);
|
|
17446
|
+
});
|
|
17447
|
+
};
|
|
17448
|
+
if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
|
|
17449
|
+
setLng(this.services.languageDetector.detect());
|
|
17450
|
+
} else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
|
|
17451
|
+
if (this.services.languageDetector.detect.length === 0) {
|
|
17452
|
+
this.services.languageDetector.detect().then(setLng);
|
|
17453
|
+
} else {
|
|
17454
|
+
this.services.languageDetector.detect(setLng);
|
|
17455
|
+
}
|
|
17456
|
+
} else {
|
|
17457
|
+
setLng(lng);
|
|
17458
|
+
}
|
|
17459
|
+
return deferred;
|
|
17460
|
+
}
|
|
17461
|
+
}, {
|
|
17462
|
+
key: "getFixedT",
|
|
17463
|
+
value: function getFixedT(lng, ns, keyPrefix) {
|
|
17464
|
+
var _this5 = this;
|
|
17465
|
+
var fixedT = function fixedT(key, opts) {
|
|
17466
|
+
var options;
|
|
17467
|
+
if (_typeof(opts) !== 'object') {
|
|
17468
|
+
for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
17469
|
+
rest[_key3 - 2] = arguments[_key3];
|
|
17470
|
+
}
|
|
17471
|
+
options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
|
17472
|
+
} else {
|
|
17473
|
+
options = _objectSpread({}, opts);
|
|
17474
|
+
}
|
|
17475
|
+
options.lng = options.lng || fixedT.lng;
|
|
17476
|
+
options.lngs = options.lngs || fixedT.lngs;
|
|
17477
|
+
options.ns = options.ns || fixedT.ns;
|
|
17478
|
+
options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
|
|
17479
|
+
var keySeparator = _this5.options.keySeparator || '.';
|
|
17480
|
+
var resultKey;
|
|
17481
|
+
if (options.keyPrefix && Array.isArray(key)) {
|
|
17482
|
+
resultKey = key.map(function (k) {
|
|
17483
|
+
return ("").concat(options.keyPrefix).concat(keySeparator).concat(k);
|
|
17484
|
+
});
|
|
17485
|
+
} else {
|
|
17486
|
+
resultKey = options.keyPrefix ? ("").concat(options.keyPrefix).concat(keySeparator).concat(key) : key;
|
|
17487
|
+
}
|
|
17488
|
+
return _this5.t(resultKey, options);
|
|
17489
|
+
};
|
|
17490
|
+
if (typeof lng === 'string') {
|
|
17491
|
+
fixedT.lng = lng;
|
|
17492
|
+
} else {
|
|
17493
|
+
fixedT.lngs = lng;
|
|
17494
|
+
}
|
|
17495
|
+
fixedT.ns = ns;
|
|
17496
|
+
fixedT.keyPrefix = keyPrefix;
|
|
17497
|
+
return fixedT;
|
|
17498
|
+
}
|
|
17499
|
+
}, {
|
|
17500
|
+
key: "t",
|
|
17501
|
+
value: function t() {
|
|
17502
|
+
var _this$translator;
|
|
17503
|
+
return this.translator && (_this$translator = this.translator).translate.apply(_this$translator, arguments);
|
|
17504
|
+
}
|
|
17505
|
+
}, {
|
|
17506
|
+
key: "exists",
|
|
17507
|
+
value: function exists() {
|
|
17508
|
+
var _this$translator2;
|
|
17509
|
+
return this.translator && (_this$translator2 = this.translator).exists.apply(_this$translator2, arguments);
|
|
17510
|
+
}
|
|
17511
|
+
}, {
|
|
17512
|
+
key: "setDefaultNamespace",
|
|
17513
|
+
value: function setDefaultNamespace(ns) {
|
|
17514
|
+
this.options.defaultNS = ns;
|
|
17515
|
+
}
|
|
17516
|
+
}, {
|
|
17517
|
+
key: "hasLoadedNamespace",
|
|
17518
|
+
value: function hasLoadedNamespace(ns) {
|
|
17519
|
+
var _this6 = this;
|
|
17520
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
17521
|
+
if (!this.isInitialized) {
|
|
17522
|
+
this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
|
|
17523
|
+
return false;
|
|
17524
|
+
}
|
|
17525
|
+
if (!this.languages || !this.languages.length) {
|
|
17526
|
+
this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
|
|
17527
|
+
return false;
|
|
17528
|
+
}
|
|
17529
|
+
var lng = options.lng || this.resolvedLanguage || this.languages[0];
|
|
17530
|
+
var fallbackLng = this.options ? this.options.fallbackLng : false;
|
|
17531
|
+
var lastLng = this.languages[this.languages.length - 1];
|
|
17532
|
+
if (lng.toLowerCase() === 'cimode') return true;
|
|
17533
|
+
var loadNotPending = function loadNotPending(l, n) {
|
|
17534
|
+
var loadState = _this6.services.backendConnector.state[("").concat(l, "|").concat(n)];
|
|
17535
|
+
return loadState === -1 || loadState === 2;
|
|
17536
|
+
};
|
|
17537
|
+
if (options.precheck) {
|
|
17538
|
+
var preResult = options.precheck(this, loadNotPending);
|
|
17539
|
+
if (preResult !== undefined) return preResult;
|
|
17540
|
+
}
|
|
17541
|
+
if (this.hasResourceBundle(lng, ns)) return true;
|
|
17542
|
+
if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
|
|
17543
|
+
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
|
|
17544
|
+
return false;
|
|
17545
|
+
}
|
|
17546
|
+
}, {
|
|
17547
|
+
key: "loadNamespaces",
|
|
17548
|
+
value: function loadNamespaces(ns, callback) {
|
|
17549
|
+
var _this7 = this;
|
|
17550
|
+
var deferred = defer();
|
|
17551
|
+
if (!this.options.ns) {
|
|
17552
|
+
if (callback) callback();
|
|
17553
|
+
return Promise.resolve();
|
|
17554
|
+
}
|
|
17555
|
+
if (typeof ns === 'string') ns = [ns];
|
|
17556
|
+
ns.forEach(function (n) {
|
|
17557
|
+
if (_this7.options.ns.indexOf(n) < 0) _this7.options.ns.push(n);
|
|
17558
|
+
});
|
|
17559
|
+
this.loadResources(function (err) {
|
|
17560
|
+
deferred.resolve();
|
|
17561
|
+
if (callback) callback(err);
|
|
17562
|
+
});
|
|
17563
|
+
return deferred;
|
|
17564
|
+
}
|
|
17565
|
+
}, {
|
|
17566
|
+
key: "loadLanguages",
|
|
17567
|
+
value: function loadLanguages(lngs, callback) {
|
|
17568
|
+
var deferred = defer();
|
|
17569
|
+
if (typeof lngs === 'string') lngs = [lngs];
|
|
17570
|
+
var preloaded = this.options.preload || [];
|
|
17571
|
+
var newLngs = lngs.filter(function (lng) {
|
|
17572
|
+
return preloaded.indexOf(lng) < 0;
|
|
17573
|
+
});
|
|
17574
|
+
if (!newLngs.length) {
|
|
17575
|
+
if (callback) callback();
|
|
17576
|
+
return Promise.resolve();
|
|
17577
|
+
}
|
|
17578
|
+
this.options.preload = preloaded.concat(newLngs);
|
|
17579
|
+
this.loadResources(function (err) {
|
|
17580
|
+
deferred.resolve();
|
|
17581
|
+
if (callback) callback(err);
|
|
17582
|
+
});
|
|
17583
|
+
return deferred;
|
|
17584
|
+
}
|
|
17585
|
+
}, {
|
|
17586
|
+
key: "dir",
|
|
17587
|
+
value: function dir(lng) {
|
|
17588
|
+
if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
|
|
17589
|
+
if (!lng) return 'rtl';
|
|
17590
|
+
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'];
|
|
17591
|
+
var languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
|
|
17592
|
+
return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
|
|
17593
|
+
}
|
|
17594
|
+
}, {
|
|
17595
|
+
key: "cloneInstance",
|
|
17596
|
+
value: function cloneInstance() {
|
|
17597
|
+
var _this8 = this;
|
|
17598
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
17599
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
|
17600
|
+
var mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, this.options), options), {
|
|
17601
|
+
isClone: true
|
|
17602
|
+
});
|
|
17603
|
+
var clone = new I18n(mergedOptions);
|
|
17604
|
+
if (options.debug !== undefined || options.prefix !== undefined) {
|
|
17605
|
+
clone.logger = clone.logger.clone(options);
|
|
17606
|
+
}
|
|
17607
|
+
var membersToCopy = ['store', 'services', 'language'];
|
|
17608
|
+
membersToCopy.forEach(function (m) {
|
|
17609
|
+
clone[m] = _this8[m];
|
|
17610
|
+
});
|
|
17611
|
+
clone.services = _objectSpread({}, this.services);
|
|
17612
|
+
clone.services.utils = {
|
|
17613
|
+
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
|
17614
|
+
};
|
|
17615
|
+
clone.translator = new Translator(clone.services, clone.options);
|
|
17616
|
+
clone.translator.on('*', function (event) {
|
|
17617
|
+
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
17618
|
+
args[_key4 - 1] = arguments[_key4];
|
|
17619
|
+
}
|
|
17620
|
+
clone.emit.apply(clone, [event].concat(args));
|
|
17621
|
+
});
|
|
17622
|
+
clone.init(mergedOptions, callback);
|
|
17623
|
+
clone.translator.options = clone.options;
|
|
17624
|
+
clone.translator.backendConnector.services.utils = {
|
|
17625
|
+
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
|
17626
|
+
};
|
|
17627
|
+
return clone;
|
|
17628
|
+
}
|
|
17629
|
+
}, {
|
|
17630
|
+
key: "toJSON",
|
|
17631
|
+
value: function toJSON() {
|
|
17632
|
+
return {
|
|
17633
|
+
options: this.options,
|
|
17634
|
+
store: this.store,
|
|
17635
|
+
language: this.language,
|
|
17636
|
+
languages: this.languages,
|
|
17637
|
+
resolvedLanguage: this.resolvedLanguage
|
|
17638
|
+
};
|
|
17639
|
+
}
|
|
17640
|
+
}]);
|
|
17641
|
+
return I18n;
|
|
17642
|
+
})(EventEmitter);
|
|
17643
|
+
_defineProperty(I18n, "createInstance", function () {
|
|
17644
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
17645
|
+
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
17646
|
+
return new I18n(options, callback);
|
|
17647
|
+
});
|
|
17648
|
+
var instance = I18n.createInstance();
|
|
17649
|
+
instance.createInstance = I18n.createInstance;
|
|
17650
|
+
instance.createInstance;
|
|
17651
|
+
instance.dir;
|
|
17652
|
+
instance.init;
|
|
17653
|
+
instance.loadResources;
|
|
17654
|
+
instance.reloadResources;
|
|
17655
|
+
instance.use;
|
|
17656
|
+
instance.changeLanguage;
|
|
17657
|
+
instance.getFixedT;
|
|
17658
|
+
instance.t;
|
|
17659
|
+
instance.exists;
|
|
17660
|
+
instance.setDefaultNamespace;
|
|
17661
|
+
instance.hasLoadedNamespace;
|
|
17662
|
+
instance.loadNamespaces;
|
|
17663
|
+
instance.loadLanguages;
|
|
17664
|
+
var en = {
|
|
17665
|
+
translation: {
|
|
17666
|
+
ebsr: {
|
|
17667
|
+
part: "Part {{index}}"
|
|
17668
|
+
},
|
|
17669
|
+
numberLine: {
|
|
17670
|
+
addElementLimit_one: "You can only add {{count}} element",
|
|
17671
|
+
addElementLimit_other: "You can only add {{count}} elements",
|
|
17672
|
+
clearAll: "Clear all"
|
|
17673
|
+
},
|
|
17674
|
+
imageClozeAssociation: {
|
|
17675
|
+
reachedLimit_one: "You’ve reached the limit of {{count}} response per area. To add another response, one must first be removed.",
|
|
17676
|
+
reachedLimit_other: "You’ve reached the limit of {{count}} responses per area. To add another response, one must first be removed."
|
|
17677
|
+
},
|
|
17678
|
+
drawingResponse: {
|
|
17679
|
+
fillColor: "Fill color",
|
|
17680
|
+
outlineColor: "Outline color",
|
|
17681
|
+
noFill: "No fill",
|
|
17682
|
+
lightblue: "Light blue",
|
|
17683
|
+
lightyellow: "Light yellow",
|
|
17684
|
+
red: "Red",
|
|
17685
|
+
orange: "Orange",
|
|
17686
|
+
yellow: "Yellow",
|
|
17687
|
+
violet: "Violet",
|
|
17688
|
+
blue: "Blue",
|
|
17689
|
+
green: "Green",
|
|
17690
|
+
white: "White",
|
|
17691
|
+
black: "Black",
|
|
17692
|
+
onDoubleClick: "Double click to edit this text. Press Enter to submit."
|
|
17693
|
+
},
|
|
17694
|
+
charting: {
|
|
17695
|
+
addCategory: "Add category",
|
|
17696
|
+
newLabel: "New label"
|
|
17697
|
+
},
|
|
17698
|
+
graphing: {
|
|
17699
|
+
point: "Point",
|
|
17700
|
+
circle: "Circle",
|
|
17701
|
+
line: "Line",
|
|
17702
|
+
parabola: "Parabola",
|
|
17703
|
+
polygon: "Polygon",
|
|
17704
|
+
ray: "Ray",
|
|
17705
|
+
segment: "Segment",
|
|
17706
|
+
sine: "Sine",
|
|
17707
|
+
vector: "Vector",
|
|
17708
|
+
label: "Label",
|
|
17709
|
+
redo: "Redo",
|
|
17710
|
+
reset: "Reset"
|
|
17711
|
+
},
|
|
17712
|
+
mathInline: {
|
|
17713
|
+
primaryCorrectWithAlternates: "Note: The answer shown above is the primary correct answer specified by the author for this item, but other answers may also be recognized as correct."
|
|
17714
|
+
}
|
|
17715
|
+
},
|
|
17716
|
+
common: {
|
|
17717
|
+
undo: "Undo",
|
|
17718
|
+
clearAll: "Clear all",
|
|
17719
|
+
correct: "Correct",
|
|
17720
|
+
incorrect: "Incorrect",
|
|
17721
|
+
showCorrectAnswer: "Show correct answer",
|
|
17722
|
+
hideCorrectAnswer: "Hide correct answer",
|
|
17723
|
+
commonCorrectAnswerWithAlternates: "Note: The answer shown above is the most common correct answer for this item. One or more additional correct answers are also defined, and will also be recognized as correct."
|
|
17724
|
+
}
|
|
17725
|
+
};
|
|
17726
|
+
var es = {
|
|
17727
|
+
translation: {
|
|
17728
|
+
ebsr: {
|
|
17729
|
+
part: "Parte {{index}}"
|
|
17730
|
+
},
|
|
17731
|
+
numberLine: {
|
|
17732
|
+
addElementLimit_one: "Solo puedes agregar {{count}} elemento",
|
|
17733
|
+
addElementLimit_other: "Solo puedes agregar {{count}} elementos",
|
|
17734
|
+
clearAll: "Borrar todo"
|
|
17735
|
+
},
|
|
17736
|
+
imageClozeAssociation: {
|
|
17737
|
+
reachedLimit_one: "Has alcanzado el límite de {{count}} respuesta por área. Para agregar otra respuesta, primero se debe eliminar una respuesta.",
|
|
17738
|
+
reachedLimit_other: "Has alcanzado el límite de {{count}} respuestas por área. Para agregar otra respuesta, primero se debe eliminar una respuesta."
|
|
17739
|
+
},
|
|
17740
|
+
drawingResponse: {
|
|
17741
|
+
fillColor: "Color de relleno",
|
|
17742
|
+
outlineColor: "Color del contorno",
|
|
17743
|
+
noFill: "Sin relleno",
|
|
17744
|
+
lightblue: "Azul claro",
|
|
17745
|
+
lightyellow: "Amarillo claro",
|
|
17746
|
+
red: "Rojo",
|
|
17747
|
+
orange: "Naranja",
|
|
17748
|
+
yellow: "Amarillo",
|
|
17749
|
+
violet: "Violeta",
|
|
17750
|
+
blue: "Azul",
|
|
17751
|
+
green: "Verde",
|
|
17752
|
+
white: "Blanco",
|
|
17753
|
+
black: "Negro",
|
|
17754
|
+
onDoubleClick: "Haz doble clic para revisar este texto. Presiona el botón de ingreso para enviar"
|
|
17755
|
+
},
|
|
17756
|
+
charting: {
|
|
17757
|
+
addCategory: "Añadir categoría",
|
|
17758
|
+
newLabel: "Nueva etiqueta"
|
|
17759
|
+
},
|
|
17760
|
+
graphing: {
|
|
17761
|
+
point: "Punto",
|
|
17762
|
+
circle: "Circulo",
|
|
17763
|
+
line: "Línea",
|
|
17764
|
+
parabola: "Parábola",
|
|
17765
|
+
polygon: "Polígono",
|
|
17766
|
+
ray: "Semirrecta",
|
|
17767
|
+
segment: "Segmento ",
|
|
17768
|
+
sine: "Seno",
|
|
17769
|
+
vector: "Vector",
|
|
17770
|
+
label: "Etiqueta",
|
|
17771
|
+
redo: "Rehacer",
|
|
17772
|
+
reset: "Reiniciar"
|
|
17773
|
+
},
|
|
17774
|
+
mathInline: {
|
|
17775
|
+
primaryCorrectWithAlternates: "Nota: La respuesta que se muestra arriba es la respuesta correcta principal especificada por el autor para esta pregunta, pero también se pueden reconocer otras respuestas como correctas."
|
|
17776
|
+
}
|
|
17777
|
+
},
|
|
17778
|
+
common: {
|
|
17779
|
+
undo: "Deshacer",
|
|
17780
|
+
clearAll: "Borrar todo",
|
|
17781
|
+
correct: "Correct",
|
|
17782
|
+
incorrect: "Incorrect",
|
|
17783
|
+
showCorrectAnswer: "Mostrar respuesta correcta",
|
|
17784
|
+
hideCorrectAnswer: "Ocultar respuesta correcta",
|
|
17785
|
+
commonCorrectAnswerWithAlternates: "Nota: La respuesta que se muestra arriba es la respuesta correcta más común para esta pregunta. También se definen una o más respuestas correctas adicionales, y también se reconocerán como correctas."
|
|
17786
|
+
}
|
|
17787
|
+
};
|
|
17788
|
+
instance.init({
|
|
17789
|
+
fallbackLng: "en",
|
|
17790
|
+
lng: "en",
|
|
17791
|
+
debug: true,
|
|
17792
|
+
resources: {
|
|
17793
|
+
en: en,
|
|
17794
|
+
es: es
|
|
17795
|
+
}
|
|
17796
|
+
});
|
|
17797
|
+
var translator = {
|
|
17798
|
+
...instance,
|
|
17799
|
+
t: (key, options) => {
|
|
17800
|
+
const {lng} = options;
|
|
17801
|
+
switch (lng) {
|
|
17802
|
+
case "en_US":
|
|
17803
|
+
case "en-US":
|
|
17804
|
+
options.lng = "en";
|
|
17805
|
+
break;
|
|
17806
|
+
case "es_ES":
|
|
17807
|
+
case "es-ES":
|
|
17808
|
+
case "es_MX":
|
|
17809
|
+
case "es-MX":
|
|
17810
|
+
options.lng = "es";
|
|
17811
|
+
break;
|
|
17812
|
+
}
|
|
17813
|
+
return instance.t(key, {
|
|
17814
|
+
lng,
|
|
17815
|
+
...options
|
|
17816
|
+
});
|
|
17817
|
+
}
|
|
17818
|
+
};
|
|
17819
|
+
const React$5 = _dll_react;
|
|
17820
|
+
const PropTypes$5 = _dll_prop_types;
|
|
17821
|
+
const {withStyles: withStyles$3} = _dll_material_ui__core_styles;
|
|
17822
|
+
const cn = _dll_classnames;
|
|
17823
|
+
const {Button: Button$1} = _dll_material_ui__core;
|
|
17824
|
+
const {color: color$3} = _dll_pie_lib__render_ui;
|
|
17825
|
+
const {withDragContext: withDragContext} = _dll_pie_lib__drag;
|
|
17826
|
+
const {DragSource: DragSource} = _dll_pie_lib__drag;
|
|
17827
|
+
const {DropTarget: DropTarget} = _dll_pie_lib__drag;
|
|
17828
|
+
const _jsxFileName$5 = "/home/circleci/repo/packages/graphing/src/toggle-bar.jsx";
|
|
17829
|
+
function _optionalChain(ops) {
|
|
17830
|
+
let lastAccessLHS = undefined;
|
|
17831
|
+
let value = ops[0];
|
|
17832
|
+
let i = 1;
|
|
17833
|
+
while (i < ops.length) {
|
|
17834
|
+
const op = ops[i];
|
|
17835
|
+
const fn = ops[i + 1];
|
|
17836
|
+
i += 2;
|
|
17837
|
+
if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
|
|
17838
|
+
return undefined;
|
|
17839
|
+
}
|
|
17840
|
+
if (op === 'access' || op === 'optionalAccess') {
|
|
17841
|
+
lastAccessLHS = value;
|
|
17842
|
+
value = fn(value);
|
|
17843
|
+
} else if (op === 'call' || op === 'optionalCall') {
|
|
17844
|
+
value = fn((...args) => value.call(lastAccessLHS, ...args));
|
|
17845
|
+
lastAccessLHS = undefined;
|
|
17846
|
+
}
|
|
17847
|
+
}
|
|
17848
|
+
return value;
|
|
17849
|
+
}
|
|
17850
|
+
const buttonStyles = () => ({
|
|
17851
|
+
root: {
|
|
17852
|
+
color: color$3.text(),
|
|
17853
|
+
'&:hover': {
|
|
17854
|
+
backgroundColor: color$3.primary()
|
|
17855
|
+
}
|
|
17856
|
+
},
|
|
17857
|
+
selected: {
|
|
17858
|
+
backgroundColor: color$3.background(),
|
|
17859
|
+
border: `1px solid ${color$3.secondary()}`
|
|
17860
|
+
},
|
|
17861
|
+
notSelected: {
|
|
17862
|
+
'& span': {
|
|
17863
|
+
color: color$3.primary()
|
|
17864
|
+
},
|
|
17865
|
+
backgroundColor: color$3.background()
|
|
17866
|
+
},
|
|
17867
|
+
disabled: {
|
|
17868
|
+
'& span': {
|
|
17869
|
+
color: color$3.primary()
|
|
17870
|
+
},
|
|
17871
|
+
backgroundColor: color$3.disabled()
|
|
17872
|
+
}
|
|
17873
|
+
});
|
|
17874
|
+
const MiniButton = withStyles$3(buttonStyles)(props => {
|
|
17875
|
+
const {disabled, classes, className, selected, value, onClick, language} = props;
|
|
17876
|
+
const translatorKey = value.toLowerCase();
|
|
17877
|
+
return React$5.createElement(Button$1, {
|
|
17878
|
+
size: "small",
|
|
17879
|
+
disabled: disabled,
|
|
17880
|
+
className: cn(classes.root, selected && classes.selected, className),
|
|
17881
|
+
classes: {
|
|
17882
|
+
disabled: cn(disabled && classes.disabled)
|
|
17883
|
+
},
|
|
17884
|
+
value: value,
|
|
17885
|
+
key: value,
|
|
17886
|
+
variant: "outlined",
|
|
17887
|
+
onClick: onClick,
|
|
17888
|
+
__self: undefined,
|
|
17889
|
+
__source: {
|
|
17890
|
+
fileName: _jsxFileName$5,
|
|
17891
|
+
lineNumber: 41
|
|
17892
|
+
}
|
|
17893
|
+
}, translator.t(`graphing.${translatorKey}`, {
|
|
17894
|
+
lng: language
|
|
17895
|
+
}));
|
|
17896
|
+
});
|
|
17897
|
+
MiniButton.propTypes = {
|
|
17898
|
+
disabled: PropTypes$5.bool,
|
|
17899
|
+
classes: PropTypes$5.object,
|
|
17900
|
+
className: PropTypes$5.string,
|
|
17901
|
+
disabledClassName: PropTypes$5.string,
|
|
17902
|
+
selected: PropTypes$5.bool,
|
|
17903
|
+
value: PropTypes$5.string,
|
|
17904
|
+
onClick: PropTypes$5.func
|
|
17905
|
+
};
|
|
17906
|
+
class ToggleBar extends React$5.Component {
|
|
17907
|
+
constructor(...args) {
|
|
17908
|
+
super(...args);
|
|
17909
|
+
ToggleBar.prototype.__init.call(this);
|
|
17910
|
+
ToggleBar.prototype.__init2.call(this);
|
|
17911
|
+
}
|
|
17912
|
+
static __initStatic() {
|
|
17913
|
+
this.propTypes = {
|
|
17914
|
+
classes: PropTypes$5.object.isRequired,
|
|
17915
|
+
className: PropTypes$5.string,
|
|
17916
|
+
options: PropTypes$5.arrayOf(PropTypes$5.string),
|
|
17917
|
+
selectedToolType: PropTypes$5.string,
|
|
17918
|
+
disabled: PropTypes$5.bool,
|
|
17919
|
+
draggableTools: PropTypes$5.bool,
|
|
17920
|
+
onChange: PropTypes$5.func,
|
|
17921
|
+
onChangeToolsOrder: PropTypes$5.func,
|
|
17922
|
+
language: PropTypes$5.string
|
|
17923
|
+
};
|
|
17924
|
+
}
|
|
17925
|
+
static __initStatic2() {
|
|
17926
|
+
this.defaultProps = {};
|
|
17927
|
+
}
|
|
17928
|
+
__init() {
|
|
17929
|
+
this.select = e => this.props.onChange(e.target.textContent);
|
|
17930
|
+
}
|
|
17931
|
+
__init2() {
|
|
17932
|
+
this.moveTool = (dragIndex, hoverIndex) => {
|
|
17933
|
+
const {options, onChangeToolsOrder} = this.props;
|
|
17934
|
+
const dragged = options[dragIndex];
|
|
17935
|
+
options.splice(dragIndex, 1);
|
|
17936
|
+
options.splice(hoverIndex, 0, dragged);
|
|
17937
|
+
onChangeToolsOrder(options);
|
|
17938
|
+
};
|
|
17939
|
+
}
|
|
17940
|
+
render() {
|
|
17941
|
+
const {classes, className, disabled, options, selectedToolType, draggableTools, language} = this.props;
|
|
17942
|
+
return React$5.createElement('div', {
|
|
17943
|
+
className: cn(className, classes.toolsContainer),
|
|
17944
|
+
__self: this,
|
|
17945
|
+
__source: {
|
|
17946
|
+
fileName: _jsxFileName$5,
|
|
17947
|
+
lineNumber: 97
|
|
17948
|
+
}
|
|
17949
|
+
}, (options || []).map((option, index) => {
|
|
17950
|
+
if ((allTools || []).includes(option)) {
|
|
17951
|
+
const isSelected = option === selectedToolType;
|
|
17952
|
+
const toolRef = React$5.createRef();
|
|
17953
|
+
return React$5.createElement(DragTool, {
|
|
17954
|
+
key: option,
|
|
14971
17955
|
index: index,
|
|
14972
17956
|
draggable: draggableTools,
|
|
14973
17957
|
moveTool: this.moveTool,
|
|
@@ -14976,7 +17960,7 @@ class ToggleBar extends React$5.Component {
|
|
|
14976
17960
|
__self: this,
|
|
14977
17961
|
__source: {
|
|
14978
17962
|
fileName: _jsxFileName$5,
|
|
14979
|
-
lineNumber:
|
|
17963
|
+
lineNumber: 104
|
|
14980
17964
|
}
|
|
14981
17965
|
}, React$5.createElement(MiniButton, {
|
|
14982
17966
|
className: cn(classes.button, isSelected && classes.selected),
|
|
@@ -14985,10 +17969,11 @@ class ToggleBar extends React$5.Component {
|
|
|
14985
17969
|
onClick: this.select,
|
|
14986
17970
|
value: option,
|
|
14987
17971
|
selected: isSelected,
|
|
17972
|
+
language: language,
|
|
14988
17973
|
__self: this,
|
|
14989
17974
|
__source: {
|
|
14990
17975
|
fileName: _jsxFileName$5,
|
|
14991
|
-
lineNumber:
|
|
17976
|
+
lineNumber: 112
|
|
14992
17977
|
}
|
|
14993
17978
|
}));
|
|
14994
17979
|
}
|
|
@@ -15048,21 +18033,21 @@ class Item extends React$5.Component {
|
|
|
15048
18033
|
__self: this,
|
|
15049
18034
|
__source: {
|
|
15050
18035
|
fileName: _jsxFileName$5,
|
|
15051
|
-
lineNumber:
|
|
18036
|
+
lineNumber: 186
|
|
15052
18037
|
}
|
|
15053
18038
|
}, connectDragSource(connectDropTarget(React$5.createElement('div', {
|
|
15054
18039
|
className: isDragging && classes.hidden,
|
|
15055
18040
|
__self: this,
|
|
15056
18041
|
__source: {
|
|
15057
18042
|
fileName: _jsxFileName$5,
|
|
15058
|
-
lineNumber:
|
|
18043
|
+
lineNumber: 187
|
|
15059
18044
|
}
|
|
15060
18045
|
}, children))), connectDragPreview(React$5.createElement('div', {
|
|
15061
18046
|
className: classes.under,
|
|
15062
18047
|
__self: this,
|
|
15063
18048
|
__source: {
|
|
15064
18049
|
fileName: _jsxFileName$5,
|
|
15065
|
-
lineNumber:
|
|
18050
|
+
lineNumber: 188
|
|
15066
18051
|
}
|
|
15067
18052
|
}, children)));
|
|
15068
18053
|
}
|
|
@@ -15128,7 +18113,8 @@ class ToolMenu extends React$4.Component {
|
|
|
15128
18113
|
onChange: PropTypes$4.func,
|
|
15129
18114
|
onToggleLabelMode: PropTypes$4.func,
|
|
15130
18115
|
onChangeTools: PropTypes$4.func,
|
|
15131
|
-
toolbarTools: PropTypes$4.arrayOf(PropTypes$4.string)
|
|
18116
|
+
toolbarTools: PropTypes$4.arrayOf(PropTypes$4.string),
|
|
18117
|
+
language: PropTypes$4.string
|
|
15132
18118
|
};
|
|
15133
18119
|
}
|
|
15134
18120
|
static __initStatic2() {
|
|
@@ -15146,7 +18132,7 @@ class ToolMenu extends React$4.Component {
|
|
|
15146
18132
|
};
|
|
15147
18133
|
}
|
|
15148
18134
|
render() {
|
|
15149
|
-
const {className, currentToolType, disabled, draggableTools, labelModeEnabled, onToggleLabelMode, onChange} = this.props;
|
|
18135
|
+
const {className, currentToolType, disabled, draggableTools, labelModeEnabled, onToggleLabelMode, onChange, language} = this.props;
|
|
15150
18136
|
let {toolbarTools} = this.props;
|
|
15151
18137
|
const showLabel = toolbarTools && toolbarTools.some(t => t === 'label');
|
|
15152
18138
|
toolbarTools = (toolbarTools || []).filter(tT => tT !== 'label');
|
|
@@ -15155,7 +18141,7 @@ class ToolMenu extends React$4.Component {
|
|
|
15155
18141
|
__self: this,
|
|
15156
18142
|
__source: {
|
|
15157
18143
|
fileName: _jsxFileName$4,
|
|
15158
|
-
lineNumber:
|
|
18144
|
+
lineNumber: 53
|
|
15159
18145
|
}
|
|
15160
18146
|
}, React$4.createElement(ToggleBar$1, {
|
|
15161
18147
|
disabled: disabled,
|
|
@@ -15164,20 +18150,22 @@ class ToolMenu extends React$4.Component {
|
|
|
15164
18150
|
selectedToolType: currentToolType,
|
|
15165
18151
|
onChange: onChange,
|
|
15166
18152
|
onChangeToolsOrder: tools => this.updateToolsOrder(tools, showLabel),
|
|
18153
|
+
language: language,
|
|
15167
18154
|
__self: this,
|
|
15168
18155
|
__source: {
|
|
15169
18156
|
fileName: _jsxFileName$4,
|
|
15170
|
-
lineNumber:
|
|
18157
|
+
lineNumber: 54
|
|
15171
18158
|
}
|
|
15172
18159
|
}), showLabel && React$4.createElement(MiniButton, {
|
|
15173
18160
|
disabled: disabled,
|
|
15174
18161
|
value: 'Label',
|
|
15175
18162
|
onClick: onToggleLabelMode,
|
|
15176
18163
|
selected: labelModeEnabled,
|
|
18164
|
+
language: language,
|
|
15177
18165
|
__self: this,
|
|
15178
18166
|
__source: {
|
|
15179
18167
|
fileName: _jsxFileName$4,
|
|
15180
|
-
lineNumber:
|
|
18168
|
+
lineNumber: 65
|
|
15181
18169
|
}
|
|
15182
18170
|
}));
|
|
15183
18171
|
}
|
|
@@ -15198,20 +18186,21 @@ class UndoRedo extends React$3.Component {
|
|
|
15198
18186
|
className: PropTypes$3.string,
|
|
15199
18187
|
onUndo: PropTypes$3.func.isRequired,
|
|
15200
18188
|
onRedo: PropTypes$3.func.isRequired,
|
|
15201
|
-
onReset: PropTypes$3.func.isRequired
|
|
18189
|
+
onReset: PropTypes$3.func.isRequired,
|
|
18190
|
+
language: PropTypes$3.string
|
|
15202
18191
|
};
|
|
15203
18192
|
}
|
|
15204
18193
|
static __initStatic2() {
|
|
15205
18194
|
this.defaultProps = {};
|
|
15206
18195
|
}
|
|
15207
18196
|
render() {
|
|
15208
|
-
const {classes, className, onUndo, onRedo, onReset} = this.props;
|
|
18197
|
+
const {classes, className, onUndo, onRedo, onReset, language} = this.props;
|
|
15209
18198
|
return React$3.createElement('div', {
|
|
15210
18199
|
className: classNames$1(className),
|
|
15211
18200
|
__self: this,
|
|
15212
18201
|
__source: {
|
|
15213
18202
|
fileName: _jsxFileName$3,
|
|
15214
|
-
lineNumber:
|
|
18203
|
+
lineNumber: 23
|
|
15215
18204
|
}
|
|
15216
18205
|
}, React$3.createElement(Button, {
|
|
15217
18206
|
classes: {
|
|
@@ -15221,9 +18210,11 @@ class UndoRedo extends React$3.Component {
|
|
|
15221
18210
|
__self: this,
|
|
15222
18211
|
__source: {
|
|
15223
18212
|
fileName: _jsxFileName$3,
|
|
15224
|
-
lineNumber:
|
|
18213
|
+
lineNumber: 24
|
|
15225
18214
|
}
|
|
15226
|
-
}, "
|
|
18215
|
+
}, translator.t("common:undo", {
|
|
18216
|
+
lng: language
|
|
18217
|
+
})), React$3.createElement(Button, {
|
|
15227
18218
|
classes: {
|
|
15228
18219
|
root: classes.button
|
|
15229
18220
|
},
|
|
@@ -15231,9 +18222,11 @@ class UndoRedo extends React$3.Component {
|
|
|
15231
18222
|
__self: this,
|
|
15232
18223
|
__source: {
|
|
15233
18224
|
fileName: _jsxFileName$3,
|
|
15234
|
-
lineNumber:
|
|
18225
|
+
lineNumber: 27
|
|
15235
18226
|
}
|
|
15236
|
-
}, "
|
|
18227
|
+
}, translator.t("graphing.redo", {
|
|
18228
|
+
lng: language
|
|
18229
|
+
})), React$3.createElement(Button, {
|
|
15237
18230
|
classes: {
|
|
15238
18231
|
root: classes.button
|
|
15239
18232
|
},
|
|
@@ -15241,9 +18234,11 @@ class UndoRedo extends React$3.Component {
|
|
|
15241
18234
|
__self: this,
|
|
15242
18235
|
__source: {
|
|
15243
18236
|
fileName: _jsxFileName$3,
|
|
15244
|
-
lineNumber:
|
|
18237
|
+
lineNumber: 30
|
|
15245
18238
|
}
|
|
15246
|
-
}, "
|
|
18239
|
+
}, translator.t("graphing.reset", {
|
|
18240
|
+
lng: language
|
|
18241
|
+
})));
|
|
15247
18242
|
}
|
|
15248
18243
|
}
|
|
15249
18244
|
UndoRedo.__initStatic();
|
|
@@ -15253,10 +18248,10 @@ const styles$2 = theme => ({
|
|
|
15253
18248
|
color: color$2.text(),
|
|
15254
18249
|
backgroundColor: color$2.background(),
|
|
15255
18250
|
marginBottom: theme.spacing.unit / 2,
|
|
15256
|
-
|
|
18251
|
+
"&:not(:last-of-type)": {
|
|
15257
18252
|
marginRight: theme.spacing.unit / 2
|
|
15258
18253
|
},
|
|
15259
|
-
|
|
18254
|
+
"&:hover": {
|
|
15260
18255
|
backgroundColor: color$2.primary()
|
|
15261
18256
|
}
|
|
15262
18257
|
}
|
|
@@ -15338,7 +18333,8 @@ class GraphWithControls extends React$2.Component {
|
|
|
15338
18333
|
onUndo: PropTypes$2.func,
|
|
15339
18334
|
onRedo: PropTypes$2.func,
|
|
15340
18335
|
onReset: PropTypes$2.func,
|
|
15341
|
-
toolbarTools: PropTypes$2.arrayOf(PropTypes$2.string)
|
|
18336
|
+
toolbarTools: PropTypes$2.arrayOf(PropTypes$2.string),
|
|
18337
|
+
language: PropTypes$2.string
|
|
15342
18338
|
};
|
|
15343
18339
|
}
|
|
15344
18340
|
static __initStatic2() {
|
|
@@ -15382,7 +18378,7 @@ class GraphWithControls extends React$2.Component {
|
|
|
15382
18378
|
}
|
|
15383
18379
|
render() {
|
|
15384
18380
|
let {currentTool, labelModeEnabled} = this.state;
|
|
15385
|
-
const {axesSettings, classes, className, coordinatesOnHover, collapsibleToolbar, collapsibleToolbarTitle, disabled, disabledLabels, disabledTitle, domain, draggableTools, labels, labelsPlaceholders, onChangeLabels, onChangeMarks, onChangeTitle, onChangeTools, onUndo, onRedo, onReset, range, size, showLabels, showPixelGuides, showTitle, title, titlePlaceholder} = this.props;
|
|
18381
|
+
const {axesSettings, classes, className, coordinatesOnHover, collapsibleToolbar, collapsibleToolbarTitle, disabled, disabledLabels, disabledTitle, domain, draggableTools, labels, labelsPlaceholders, onChangeLabels, onChangeMarks, onChangeTitle, onChangeTools, onUndo, onRedo, onReset, range, size, showLabels, showPixelGuides, showTitle, title, titlePlaceholder, language} = this.props;
|
|
15386
18382
|
let {backgroundMarks, marks, toolbarTools} = this.props;
|
|
15387
18383
|
toolbarTools = uniq(toolbarTools || []).filter(tT => !!isString(tT)) || [];
|
|
15388
18384
|
backgroundMarks = filterByValidToolTypes(backgroundMarks || []);
|
|
@@ -15395,7 +18391,7 @@ class GraphWithControls extends React$2.Component {
|
|
|
15395
18391
|
__self: this,
|
|
15396
18392
|
__source: {
|
|
15397
18393
|
fileName: _jsxFileName$2,
|
|
15398
|
-
lineNumber:
|
|
18394
|
+
lineNumber: 147
|
|
15399
18395
|
}
|
|
15400
18396
|
}, React$2.createElement(ToolMenu, {
|
|
15401
18397
|
currentToolType: currentTool && currentTool.type,
|
|
@@ -15406,19 +18402,21 @@ class GraphWithControls extends React$2.Component {
|
|
|
15406
18402
|
onToggleLabelMode: this.toggleLabelMode,
|
|
15407
18403
|
toolbarTools: toolbarTools,
|
|
15408
18404
|
onChangeTools: onChangeTools,
|
|
18405
|
+
language: language,
|
|
15409
18406
|
__self: this,
|
|
15410
18407
|
__source: {
|
|
15411
18408
|
fileName: _jsxFileName$2,
|
|
15412
|
-
lineNumber:
|
|
18409
|
+
lineNumber: 148
|
|
15413
18410
|
}
|
|
15414
18411
|
}), !disabled && React$2.createElement(UndoRedo$1, {
|
|
15415
18412
|
onUndo: onUndo,
|
|
15416
18413
|
onRedo: onRedo,
|
|
15417
18414
|
onReset: onReset,
|
|
18415
|
+
language: language,
|
|
15418
18416
|
__self: this,
|
|
15419
18417
|
__source: {
|
|
15420
18418
|
fileName: _jsxFileName$2,
|
|
15421
|
-
lineNumber:
|
|
18419
|
+
lineNumber: 160
|
|
15422
18420
|
}
|
|
15423
18421
|
}));
|
|
15424
18422
|
return React$2.createElement('div', {
|
|
@@ -15426,14 +18424,14 @@ class GraphWithControls extends React$2.Component {
|
|
|
15426
18424
|
__self: this,
|
|
15427
18425
|
__source: {
|
|
15428
18426
|
fileName: _jsxFileName$2,
|
|
15429
|
-
lineNumber:
|
|
18427
|
+
lineNumber: 165
|
|
15430
18428
|
}
|
|
15431
18429
|
}, React$2.createElement('div', {
|
|
15432
18430
|
className: classes.controls,
|
|
15433
18431
|
__self: this,
|
|
15434
18432
|
__source: {
|
|
15435
18433
|
fileName: _jsxFileName$2,
|
|
15436
|
-
lineNumber:
|
|
18434
|
+
lineNumber: 166
|
|
15437
18435
|
}
|
|
15438
18436
|
}, collapsibleToolbar ? React$2.createElement(Collapsible, {
|
|
15439
18437
|
classes: classes,
|
|
@@ -15441,14 +18439,14 @@ class GraphWithControls extends React$2.Component {
|
|
|
15441
18439
|
__self: this,
|
|
15442
18440
|
__source: {
|
|
15443
18441
|
fileName: _jsxFileName$2,
|
|
15444
|
-
lineNumber:
|
|
18442
|
+
lineNumber: 168
|
|
15445
18443
|
}
|
|
15446
18444
|
}, graphActions) : graphActions), React$2.createElement('div', {
|
|
15447
18445
|
ref: r => this.labelNode = r,
|
|
15448
18446
|
__self: this,
|
|
15449
18447
|
__source: {
|
|
15450
18448
|
fileName: _jsxFileName$2,
|
|
15451
|
-
lineNumber:
|
|
18449
|
+
lineNumber: 176
|
|
15452
18450
|
}
|
|
15453
18451
|
}), React$2.createElement(Graph, {
|
|
15454
18452
|
axesSettings: axesSettings,
|
|
@@ -15476,7 +18474,7 @@ class GraphWithControls extends React$2.Component {
|
|
|
15476
18474
|
__self: this,
|
|
15477
18475
|
__source: {
|
|
15478
18476
|
fileName: _jsxFileName$2,
|
|
15479
|
-
lineNumber:
|
|
18477
|
+
lineNumber: 178
|
|
15480
18478
|
}
|
|
15481
18479
|
}));
|
|
15482
18480
|
}
|