andoncloud-prometheus-widget 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8,29 +8,66 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
10
 
11
- function _objectWithoutPropertiesLoose(source, excluded) {
11
+ function _typeof(obj) {
12
+ "@babel/helpers - typeof";
13
+
14
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
15
+ return typeof obj;
16
+ } : function (obj) {
17
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
18
+ }, _typeof(obj);
19
+ }
20
+
21
+ function _toPrimitive(input, hint) {
22
+ if (_typeof(input) !== "object" || input === null) return input;
23
+ var prim = input[Symbol.toPrimitive];
24
+ if (prim !== undefined) {
25
+ var res = prim.call(input, hint || "default");
26
+ if (_typeof(res) !== "object") return res;
27
+ throw new TypeError("@@toPrimitive must return a primitive value.");
28
+ }
29
+ return (hint === "string" ? String : Number)(input);
30
+ }
31
+
32
+ function _toPropertyKey(arg) {
33
+ var key = _toPrimitive(arg, "string");
34
+ return _typeof(key) === "symbol" ? key : String(key);
35
+ }
36
+
37
+ function _defineProperty(obj, key, value) {
38
+ key = _toPropertyKey(key);
39
+ if (key in obj) {
40
+ Object.defineProperty(obj, key, {
41
+ value: value,
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true
45
+ });
46
+ } else {
47
+ obj[key] = value;
48
+ }
49
+ return obj;
50
+ }
51
+
52
+ function _objectWithoutPropertiesLoose$1(source, excluded) {
12
53
  if (source == null) return {};
13
54
  var target = {};
14
55
  var sourceKeys = Object.keys(source);
15
56
  var key, i;
16
-
17
57
  for (i = 0; i < sourceKeys.length; i++) {
18
58
  key = sourceKeys[i];
19
59
  if (excluded.indexOf(key) >= 0) continue;
20
60
  target[key] = source[key];
21
61
  }
22
-
23
62
  return target;
24
63
  }
25
64
 
26
65
  function _objectWithoutProperties(source, excluded) {
27
66
  if (source == null) return {};
28
- var target = _objectWithoutPropertiesLoose(source, excluded);
67
+ var target = _objectWithoutPropertiesLoose$1(source, excluded);
29
68
  var key, i;
30
-
31
69
  if (Object.getOwnPropertySymbols) {
32
70
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
33
-
34
71
  for (i = 0; i < sourceSymbolKeys.length; i++) {
35
72
  key = sourceSymbolKeys[i];
36
73
  if (excluded.indexOf(key) >= 0) continue;
@@ -38,35 +75,9 @@ function _objectWithoutProperties(source, excluded) {
38
75
  target[key] = source[key];
39
76
  }
40
77
  }
41
-
42
78
  return target;
43
79
  }
44
80
 
45
- function _typeof(obj) {
46
- "@babel/helpers - typeof";
47
-
48
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
49
- return typeof obj;
50
- } : function (obj) {
51
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
52
- }, _typeof(obj);
53
- }
54
-
55
- function _defineProperty(obj, key, value) {
56
- if (key in obj) {
57
- Object.defineProperty(obj, key, {
58
- value: value,
59
- enumerable: true,
60
- configurable: true,
61
- writable: true
62
- });
63
- } else {
64
- obj[key] = value;
65
- }
66
-
67
- return obj;
68
- }
69
-
70
81
  /**
71
82
  * This file automatically generated from `pre-publish.js`.
72
83
  * Do not manually edit.
@@ -90,122 +101,6 @@ var voidElements = {
90
101
 
91
102
  var t=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function n(n){var r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},i=n.match(/<\/?([^\s]+?)[/\s>]/);if(i&&(r.name=i[1],(voidElements[i[1]]||"/"===n.charAt(n.length-2))&&(r.voidElement=!0),r.name.startsWith("!--"))){var s=n.indexOf("--\x3e");return {type:"comment",comment:-1!==s?n.slice(4,s):""}}for(var a=new RegExp(t),c=null;null!==(c=a.exec(n));)if(c[0].trim())if(c[1]){var o=c[1].trim(),l=[o,""];o.indexOf("=")>-1&&(l=o.split("=")),r.attrs[l[0]]=l[1],a.lastIndex--;}else c[2]&&(r.attrs[c[2]]=c[3].trim().substring(1,c[3].length-1));return r}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,i=/^\s*$/,s=Object.create(null);function a(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(a,"")+"</"+t.name+">";case"comment":return e+"\x3c!--"+t.comment+"--\x3e"}}var c={parse:function(e,t){t||(t={}),t.components||(t.components=s);var a,c=[],o=[],l=-1,m=!1;if(0!==e.indexOf("<")){var u=e.indexOf("<");c.push({type:"text",content:-1===u?e:e.substring(0,u)});}return e.replace(r,function(r,s){if(m){if(r!=="</"+a.name+">")return;m=!1;}var u,f="/"!==r.charAt(1),h=r.startsWith("\x3c!--"),p=s+r.length,d=e.charAt(p);if(h){var v=n(r);return l<0?(c.push(v),c):((u=o[l]).children.push(v),c)}if(f&&(l++,"tag"===(a=n(r)).type&&t.components[a.name]&&(a.type="component",m=!0),a.voidElement||m||!d||"<"===d||a.children.push({type:"text",content:e.slice(p,e.indexOf("<",p))}),0===l&&c.push(a),(u=o[l-1])&&u.children.push(a),o[l]=a),(!f||a.voidElement)&&(l>-1&&(a.voidElement||a.name===r.slice(2,-1))&&(l--,a=-1===l?c:o[l]),!m&&"<"!==d&&d)){u=-1===l?c:o[l].children;var x=e.indexOf("<",p),g=e.slice(p,-1===x?void 0:x);i.test(g)&&(g=" "),(x>-1&&l+u.length>=0||" "!==g)&&u.push({type:"text",content:g});}}),c},stringify:function(e){return e.reduce(function(e,t){return e+a("",t)},"")}};
92
103
 
93
- function _classCallCheck(instance, Constructor) {
94
- if (!(instance instanceof Constructor)) {
95
- throw new TypeError("Cannot call a class as a function");
96
- }
97
- }
98
-
99
- function _defineProperties(target, props) {
100
- for (var i = 0; i < props.length; i++) {
101
- var descriptor = props[i];
102
- descriptor.enumerable = descriptor.enumerable || false;
103
- descriptor.configurable = true;
104
- if ("value" in descriptor) descriptor.writable = true;
105
- Object.defineProperty(target, descriptor.key, descriptor);
106
- }
107
- }
108
-
109
- function _createClass(Constructor, protoProps, staticProps) {
110
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
111
- if (staticProps) _defineProperties(Constructor, staticProps);
112
- Object.defineProperty(Constructor, "prototype", {
113
- writable: false
114
- });
115
- return Constructor;
116
- }
117
-
118
- var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230);/g;
119
- var htmlEntities = {
120
- '&amp;': '&',
121
- '&#38;': '&',
122
- '&lt;': '<',
123
- '&#60;': '<',
124
- '&gt;': '>',
125
- '&#62;': '>',
126
- '&apos;': "'",
127
- '&#39;': "'",
128
- '&quot;': '"',
129
- '&#34;': '"',
130
- '&nbsp;': ' ',
131
- '&#160;': ' ',
132
- '&copy;': '©',
133
- '&#169;': '©',
134
- '&reg;': '®',
135
- '&#174;': '®',
136
- '&hellip;': '…',
137
- '&#8230;': '…'
138
- };
139
-
140
- var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
141
- return htmlEntities[m];
142
- };
143
-
144
- var unescape$1 = function unescape(text) {
145
- return text.replace(matchHtmlEntity, unescapeHtmlEntity);
146
- };
147
-
148
- function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
149
-
150
- function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$9(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
151
- var defaultOptions = {
152
- bindI18n: 'languageChanged',
153
- bindI18nStore: '',
154
- transEmptyNodeValue: '',
155
- transSupportBasicHtmlNodes: true,
156
- transWrapTextNodes: '',
157
- transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
158
- useSuspense: true,
159
- unescape: unescape$1
160
- };
161
- var i18nInstance;
162
- var I18nContext = React.createContext();
163
- function setDefaults() {
164
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
165
- defaultOptions = _objectSpread$9(_objectSpread$9({}, defaultOptions), options);
166
- }
167
- function getDefaults() {
168
- return defaultOptions;
169
- }
170
- var ReportNamespaces = function () {
171
- function ReportNamespaces() {
172
- _classCallCheck(this, ReportNamespaces);
173
-
174
- this.usedNamespaces = {};
175
- }
176
-
177
- _createClass(ReportNamespaces, [{
178
- key: "addUsedNamespaces",
179
- value: function addUsedNamespaces(namespaces) {
180
- var _this = this;
181
-
182
- namespaces.forEach(function (ns) {
183
- if (!_this.usedNamespaces[ns]) _this.usedNamespaces[ns] = true;
184
- });
185
- }
186
- }, {
187
- key: "getUsedNamespaces",
188
- value: function getUsedNamespaces() {
189
- return Object.keys(this.usedNamespaces);
190
- }
191
- }]);
192
-
193
- return ReportNamespaces;
194
- }();
195
- function setI18n(instance) {
196
- i18nInstance = instance;
197
- }
198
- function getI18n() {
199
- return i18nInstance;
200
- }
201
- var initReactI18next = {
202
- type: '3rdParty',
203
- init: function init(instance) {
204
- setDefaults(instance.options.react);
205
- setI18n(instance);
206
- }
207
- };
208
-
209
104
  function warn() {
210
105
  if (console && console.warn) {
211
106
  var _console;
@@ -286,12 +181,73 @@ function hasLoadedNamespace(ns, i18n) {
286
181
  });
287
182
  }
288
183
 
289
- var _excluded = ["format"],
184
+ var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
185
+ var htmlEntities = {
186
+ '&amp;': '&',
187
+ '&#38;': '&',
188
+ '&lt;': '<',
189
+ '&#60;': '<',
190
+ '&gt;': '>',
191
+ '&#62;': '>',
192
+ '&apos;': "'",
193
+ '&#39;': "'",
194
+ '&quot;': '"',
195
+ '&#34;': '"',
196
+ '&nbsp;': ' ',
197
+ '&#160;': ' ',
198
+ '&copy;': '©',
199
+ '&#169;': '©',
200
+ '&reg;': '®',
201
+ '&#174;': '®',
202
+ '&hellip;': '…',
203
+ '&#8230;': '…',
204
+ '&#x2F;': '/',
205
+ '&#47;': '/'
206
+ };
207
+
208
+ var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
209
+ return htmlEntities[m];
210
+ };
211
+
212
+ var unescape$1 = function unescape(text) {
213
+ return text.replace(matchHtmlEntity, unescapeHtmlEntity);
214
+ };
215
+
216
+ function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
217
+
218
+ function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$a(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
219
+ var defaultOptions = {
220
+ bindI18n: 'languageChanged',
221
+ bindI18nStore: '',
222
+ transEmptyNodeValue: '',
223
+ transSupportBasicHtmlNodes: true,
224
+ transWrapTextNodes: '',
225
+ transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
226
+ useSuspense: true,
227
+ unescape: unescape$1
228
+ };
229
+ function setDefaults() {
230
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
231
+ defaultOptions = _objectSpread$a(_objectSpread$a({}, defaultOptions), options);
232
+ }
233
+ function getDefaults() {
234
+ return defaultOptions;
235
+ }
236
+
237
+ var i18nInstance;
238
+ function setI18n(instance) {
239
+ i18nInstance = instance;
240
+ }
241
+ function getI18n() {
242
+ return i18nInstance;
243
+ }
244
+
245
+ var _excluded$2 = ["format"],
290
246
  _excluded2 = ["children", "count", "parent", "i18nKey", "context", "tOptions", "values", "defaults", "components", "ns", "i18n", "t", "shouldUnescape"];
291
247
 
292
- function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
248
+ function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
293
249
 
294
- function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$8(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
250
+ function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$9(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
295
251
 
296
252
  function hasChildren(node, checkLength) {
297
253
  if (!node) return false;
@@ -317,7 +273,7 @@ function getAsArray(data) {
317
273
  }
318
274
 
319
275
  function mergeProps(source, target) {
320
- var newTarget = _objectSpread$8({}, target);
276
+ var newTarget = _objectSpread$9({}, target);
321
277
 
322
278
  newTarget.props = Object.assign(source.props, target.props);
323
279
  return newTarget;
@@ -352,7 +308,7 @@ function nodesToString(children, i18nOptions) {
352
308
  warn("Trans: the passed in value is invalid - seems you passed in a null child.");
353
309
  } else if (_typeof(child) === 'object') {
354
310
  var format = child.format,
355
- clone = _objectWithoutProperties(child, _excluded);
311
+ clone = _objectWithoutProperties(child, _excluded$2);
356
312
 
357
313
  var keys = Object.keys(clone);
358
314
 
@@ -387,7 +343,7 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, s
387
343
  getData(children);
388
344
  var ast = c.parse("<0>".concat(targetString, "</0>"));
389
345
 
390
- var opts = _objectSpread$8(_objectSpread$8({}, data), combinedTOpts);
346
+ var opts = _objectSpread$9(_objectSpread$9({}, data), combinedTOpts);
391
347
 
392
348
  function renderInner(child, node, rootReactNode) {
393
349
  var childs = getChildren(child);
@@ -397,7 +353,7 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, s
397
353
 
398
354
  function pushTranslatedJSX(child, inner, mem, i, isVoid) {
399
355
  if (child.dummy) child.children = inner;
400
- mem.push(React.cloneElement(child, _objectSpread$8(_objectSpread$8({}, child.props), {}, {
356
+ mem.push(React.cloneElement(child, _objectSpread$9(_objectSpread$9({}, child.props), {}, {
401
357
  key: i
402
358
  }), isVoid ? undefined : inner));
403
359
  }
@@ -429,7 +385,7 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, s
429
385
  } else if (isEmptyTransWithHTML) {
430
386
  var _inner = mapAST(reactNodes, node.children, rootReactNode);
431
387
 
432
- mem.push(React.cloneElement(child, _objectSpread$8(_objectSpread$8({}, child.props), {}, {
388
+ mem.push(React.cloneElement(child, _objectSpread$9(_objectSpread$9({}, child.props), {}, {
433
389
  key: i
434
390
  }), _inner));
435
391
  } else if (Number.isNaN(parseFloat(node.name))) {
@@ -460,11 +416,11 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, s
460
416
  var content = node.children[0] ? translationContent : null;
461
417
  if (content) mem.push(content);
462
418
  } else if (node.children.length === 1 && translationContent) {
463
- mem.push(React.cloneElement(child, _objectSpread$8(_objectSpread$8({}, child.props), {}, {
419
+ mem.push(React.cloneElement(child, _objectSpread$9(_objectSpread$9({}, child.props), {}, {
464
420
  key: i
465
421
  }), translationContent));
466
422
  } else {
467
- mem.push(React.cloneElement(child, _objectSpread$8(_objectSpread$8({}, child.props), {}, {
423
+ mem.push(React.cloneElement(child, _objectSpread$9(_objectSpread$9({}, child.props), {}, {
468
424
  key: i
469
425
  })));
470
426
  }
@@ -493,7 +449,7 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, s
493
449
  return getChildren(result[0]);
494
450
  }
495
451
 
496
- function Trans(_ref) {
452
+ function Trans$1(_ref) {
497
453
  var children = _ref.children,
498
454
  count = _ref.count,
499
455
  parent = _ref.parent,
@@ -510,11 +466,7 @@ function Trans(_ref) {
510
466
  shouldUnescape = _ref.shouldUnescape,
511
467
  additionalProps = _objectWithoutProperties(_ref, _excluded2);
512
468
 
513
- var _ref2 = React.useContext(I18nContext) || {},
514
- i18nFromContext = _ref2.i18n,
515
- defaultNSFromContext = _ref2.defaultNS;
516
-
517
- var i18n = i18nFromProps || i18nFromContext || getI18n();
469
+ var i18n = i18nFromProps || getI18n();
518
470
 
519
471
  if (!i18n) {
520
472
  warnOnce('You will need to pass in an i18next instance by using i18nextReactModule');
@@ -527,21 +479,21 @@ function Trans(_ref) {
527
479
 
528
480
  if (context) tOptions.context = context;
529
481
 
530
- var reactI18nextOptions = _objectSpread$8(_objectSpread$8({}, getDefaults()), i18n.options && i18n.options.react);
482
+ var reactI18nextOptions = _objectSpread$9(_objectSpread$9({}, getDefaults()), i18n.options && i18n.options.react);
531
483
 
532
- var namespaces = ns || t.ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
484
+ var namespaces = ns || t.ns || i18n.options && i18n.options.defaultNS;
533
485
  namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
534
486
  var defaultValue = defaults || nodesToString(children, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue || i18nKey;
535
487
  var hashTransKey = reactI18nextOptions.hashTransKey;
536
488
  var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
537
489
  var interpolationOverride = values ? tOptions.interpolation : {
538
- interpolation: _objectSpread$8(_objectSpread$8({}, tOptions.interpolation), {}, {
490
+ interpolation: _objectSpread$9(_objectSpread$9({}, tOptions.interpolation), {}, {
539
491
  prefix: '#$?',
540
492
  suffix: '?$#'
541
493
  })
542
494
  };
543
495
 
544
- var combinedTOpts = _objectSpread$8(_objectSpread$8(_objectSpread$8(_objectSpread$8({}, tOptions), {}, {
496
+ var combinedTOpts = _objectSpread$9(_objectSpread$9(_objectSpread$9(_objectSpread$9({}, tOptions), {}, {
545
497
  count: count
546
498
  }, values), interpolationOverride), {}, {
547
499
  defaultValue: defaultValue,
@@ -554,47 +506,145 @@ function Trans(_ref) {
554
506
  return useAsParent ? React.createElement(useAsParent, additionalProps, content) : content;
555
507
  }
556
508
 
557
- function _arrayWithHoles(arr) {
558
- if (Array.isArray(arr)) return arr;
509
+ function _classCallCheck(instance, Constructor) {
510
+ if (!(instance instanceof Constructor)) {
511
+ throw new TypeError("Cannot call a class as a function");
512
+ }
559
513
  }
560
514
 
561
- function _iterableToArrayLimit(arr, i) {
562
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
515
+ function _defineProperties(target, props) {
516
+ for (var i = 0; i < props.length; i++) {
517
+ var descriptor = props[i];
518
+ descriptor.enumerable = descriptor.enumerable || false;
519
+ descriptor.configurable = true;
520
+ if ("value" in descriptor) descriptor.writable = true;
521
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
522
+ }
523
+ }
524
+ function _createClass(Constructor, protoProps, staticProps) {
525
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
526
+ if (staticProps) _defineProperties(Constructor, staticProps);
527
+ Object.defineProperty(Constructor, "prototype", {
528
+ writable: false
529
+ });
530
+ return Constructor;
531
+ }
532
+
533
+ var initReactI18next = {
534
+ type: '3rdParty',
535
+ init: function init(instance) {
536
+ setDefaults(instance.options.react);
537
+ setI18n(instance);
538
+ }
539
+ };
540
+
541
+ var I18nContext = React.createContext();
542
+ var ReportNamespaces = function () {
543
+ function ReportNamespaces() {
544
+ _classCallCheck(this, ReportNamespaces);
545
+
546
+ this.usedNamespaces = {};
547
+ }
548
+
549
+ _createClass(ReportNamespaces, [{
550
+ key: "addUsedNamespaces",
551
+ value: function addUsedNamespaces(namespaces) {
552
+ var _this = this;
553
+
554
+ namespaces.forEach(function (ns) {
555
+ if (!_this.usedNamespaces[ns]) _this.usedNamespaces[ns] = true;
556
+ });
557
+ }
558
+ }, {
559
+ key: "getUsedNamespaces",
560
+ value: function getUsedNamespaces() {
561
+ return Object.keys(this.usedNamespaces);
562
+ }
563
+ }]);
564
+
565
+ return ReportNamespaces;
566
+ }();
567
+
568
+ var _excluded$1 = ["children", "count", "parent", "i18nKey", "context", "tOptions", "values", "defaults", "components", "ns", "i18n", "t", "shouldUnescape"];
569
+
570
+ function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
571
+
572
+ function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$8(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
573
+ function Trans(_ref) {
574
+ var children = _ref.children,
575
+ count = _ref.count,
576
+ parent = _ref.parent,
577
+ i18nKey = _ref.i18nKey,
578
+ context = _ref.context,
579
+ _ref$tOptions = _ref.tOptions,
580
+ tOptions = _ref$tOptions === void 0 ? {} : _ref$tOptions,
581
+ values = _ref.values,
582
+ defaults = _ref.defaults,
583
+ components = _ref.components,
584
+ ns = _ref.ns,
585
+ i18nFromProps = _ref.i18n,
586
+ tFromProps = _ref.t,
587
+ shouldUnescape = _ref.shouldUnescape,
588
+ additionalProps = _objectWithoutProperties(_ref, _excluded$1);
563
589
 
564
- if (_i == null) return;
565
- var _arr = [];
566
- var _n = true;
567
- var _d = false;
590
+ var _ref2 = React.useContext(I18nContext) || {},
591
+ i18nFromContext = _ref2.i18n,
592
+ defaultNSFromContext = _ref2.defaultNS;
568
593
 
569
- var _s, _e;
594
+ var i18n = i18nFromProps || i18nFromContext || getI18n();
595
+ var t = tFromProps || i18n && i18n.t.bind(i18n);
596
+ return Trans$1(_objectSpread$8({
597
+ children: children,
598
+ count: count,
599
+ parent: parent,
600
+ i18nKey: i18nKey,
601
+ context: context,
602
+ tOptions: tOptions,
603
+ values: values,
604
+ defaults: defaults,
605
+ components: components,
606
+ ns: ns || t && t.ns || defaultNSFromContext || i18n && i18n.options && i18n.options.defaultNS,
607
+ i18n: i18n,
608
+ t: tFromProps,
609
+ shouldUnescape: shouldUnescape
610
+ }, additionalProps));
611
+ }
570
612
 
571
- try {
572
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
573
- _arr.push(_s.value);
613
+ function _arrayWithHoles(arr) {
614
+ if (Array.isArray(arr)) return arr;
615
+ }
574
616
 
575
- if (i && _arr.length === i) break;
576
- }
577
- } catch (err) {
578
- _d = true;
579
- _e = err;
580
- } finally {
617
+ function _iterableToArrayLimit(arr, i) {
618
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
619
+ if (null != _i) {
620
+ var _s,
621
+ _e,
622
+ _x,
623
+ _r,
624
+ _arr = [],
625
+ _n = !0,
626
+ _d = !1;
581
627
  try {
582
- if (!_n && _i["return"] != null) _i["return"]();
628
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
629
+ if (Object(_i) !== _i) return;
630
+ _n = !1;
631
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
632
+ } catch (err) {
633
+ _d = !0, _e = err;
583
634
  } finally {
584
- if (_d) throw _e;
635
+ try {
636
+ if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
637
+ } finally {
638
+ if (_d) throw _e;
639
+ }
585
640
  }
641
+ return _arr;
586
642
  }
587
-
588
- return _arr;
589
643
  }
590
644
 
591
645
  function _arrayLikeToArray(arr, len) {
592
646
  if (len == null || len > arr.length) len = arr.length;
593
-
594
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
595
- arr2[i] = arr[i];
596
- }
597
-
647
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
598
648
  return arr2;
599
649
  }
600
650
 
@@ -733,7 +783,6 @@ function _assertThisInitialized(self) {
733
783
  if (self === void 0) {
734
784
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
735
785
  }
736
-
737
786
  return self;
738
787
  }
739
788
 
@@ -749,7 +798,6 @@ function _inherits(subClass, superClass) {
749
798
  if (typeof superClass !== "function" && superClass !== null) {
750
799
  throw new TypeError("Super expression must either be null or a function");
751
800
  }
752
-
753
801
  subClass.prototype = Object.create(superClass && superClass.prototype, {
754
802
  constructor: {
755
803
  value: subClass,
@@ -769,7 +817,6 @@ function _possibleConstructorReturn(self, call) {
769
817
  } else if (call !== void 0) {
770
818
  throw new TypeError("Derived constructors may only return object or undefined");
771
819
  }
772
-
773
820
  return _assertThisInitialized(self);
774
821
  }
775
822
 
@@ -788,10 +835,8 @@ function _toArray(arr) {
788
835
  return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
789
836
  }
790
837
 
791
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
792
-
793
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
794
-
838
+ function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
839
+ function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
795
840
  var consoleLogger = {
796
841
  type: 'logger',
797
842
  log: function log(args) {
@@ -807,16 +852,12 @@ var consoleLogger = {
807
852
  if (console && console[type]) console[type].apply(console, args);
808
853
  }
809
854
  };
810
-
811
855
  var Logger = function () {
812
856
  function Logger(concreteLogger) {
813
857
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
814
-
815
858
  _classCallCheck(this, Logger);
816
-
817
859
  this.init(concreteLogger, options);
818
860
  }
819
-
820
861
  _createClass(Logger, [{
821
862
  key: "init",
822
863
  value: function init(concreteLogger) {
@@ -837,7 +878,6 @@ var Logger = function () {
837
878
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
838
879
  args[_key] = arguments[_key];
839
880
  }
840
-
841
881
  return this.forward(args, 'log', '', true);
842
882
  }
843
883
  }, {
@@ -846,7 +886,6 @@ var Logger = function () {
846
886
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
847
887
  args[_key2] = arguments[_key2];
848
888
  }
849
-
850
889
  return this.forward(args, 'warn', '', true);
851
890
  }
852
891
  }, {
@@ -855,7 +894,6 @@ var Logger = function () {
855
894
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
856
895
  args[_key3] = arguments[_key3];
857
896
  }
858
-
859
897
  return this.forward(args, 'error', '');
860
898
  }
861
899
  }, {
@@ -864,7 +902,6 @@ var Logger = function () {
864
902
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
865
903
  args[_key4] = arguments[_key4];
866
904
  }
867
-
868
905
  return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
869
906
  }
870
907
  }, {
@@ -877,32 +914,33 @@ var Logger = function () {
877
914
  }, {
878
915
  key: "create",
879
916
  value: function create(moduleName) {
880
- return new Logger(this.logger, _objectSpread(_objectSpread({}, {
917
+ return new Logger(this.logger, _objectSpread$6(_objectSpread$6({}, {
881
918
  prefix: "".concat(this.prefix, ":").concat(moduleName, ":")
882
919
  }), this.options));
883
920
  }
921
+ }, {
922
+ key: "clone",
923
+ value: function clone(options) {
924
+ options = options || this.options;
925
+ options.prefix = options.prefix || this.prefix;
926
+ return new Logger(this.logger, options);
927
+ }
884
928
  }]);
885
-
886
929
  return Logger;
887
930
  }();
888
-
889
931
  var baseLogger = new Logger();
890
932
 
891
933
  var EventEmitter = function () {
892
934
  function EventEmitter() {
893
935
  _classCallCheck(this, EventEmitter);
894
-
895
936
  this.observers = {};
896
937
  }
897
-
898
938
  _createClass(EventEmitter, [{
899
939
  key: "on",
900
940
  value: function on(events, listener) {
901
941
  var _this = this;
902
-
903
942
  events.split(' ').forEach(function (event) {
904
943
  _this.observers[event] = _this.observers[event] || [];
905
-
906
944
  _this.observers[event].push(listener);
907
945
  });
908
946
  return this;
@@ -911,12 +949,10 @@ var EventEmitter = function () {
911
949
  key: "off",
912
950
  value: function off(event, listener) {
913
951
  if (!this.observers[event]) return;
914
-
915
952
  if (!listener) {
916
953
  delete this.observers[event];
917
954
  return;
918
955
  }
919
-
920
956
  this.observers[event] = this.observers[event].filter(function (l) {
921
957
  return l !== listener;
922
958
  });
@@ -927,24 +963,20 @@ var EventEmitter = function () {
927
963
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
928
964
  args[_key - 1] = arguments[_key];
929
965
  }
930
-
931
966
  if (this.observers[event]) {
932
967
  var cloned = [].concat(this.observers[event]);
933
968
  cloned.forEach(function (observer) {
934
969
  observer.apply(void 0, args);
935
970
  });
936
971
  }
937
-
938
972
  if (this.observers['*']) {
939
973
  var _cloned = [].concat(this.observers['*']);
940
-
941
974
  _cloned.forEach(function (observer) {
942
975
  observer.apply(observer, [event].concat(args));
943
976
  });
944
977
  }
945
978
  }
946
979
  }]);
947
-
948
980
  return EventEmitter;
949
981
  }();
950
982
 
@@ -968,68 +1000,56 @@ function copy(a, s, t) {
968
1000
  if (s[m]) t[m] = s[m];
969
1001
  });
970
1002
  }
971
-
972
1003
  function getLastOfPath(object, path, Empty) {
973
1004
  function cleanKey(key) {
974
1005
  return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
975
1006
  }
976
-
977
1007
  function canNotTraverseDeeper() {
978
1008
  return !object || typeof object === 'string';
979
1009
  }
980
-
981
1010
  var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
982
-
983
1011
  while (stack.length > 1) {
984
1012
  if (canNotTraverseDeeper()) return {};
985
1013
  var key = cleanKey(stack.shift());
986
1014
  if (!object[key] && Empty) object[key] = new Empty();
987
-
988
1015
  if (Object.prototype.hasOwnProperty.call(object, key)) {
989
1016
  object = object[key];
990
1017
  } else {
991
1018
  object = {};
992
1019
  }
993
1020
  }
994
-
995
1021
  if (canNotTraverseDeeper()) return {};
996
1022
  return {
997
1023
  obj: object,
998
1024
  k: cleanKey(stack.shift())
999
1025
  };
1000
1026
  }
1001
-
1002
1027
  function setPath(object, path, newValue) {
1003
1028
  var _getLastOfPath = getLastOfPath(object, path, Object),
1004
- obj = _getLastOfPath.obj,
1005
- k = _getLastOfPath.k;
1006
-
1029
+ obj = _getLastOfPath.obj,
1030
+ k = _getLastOfPath.k;
1007
1031
  obj[k] = newValue;
1008
1032
  }
1009
1033
  function pushPath(object, path, newValue, concat) {
1010
1034
  var _getLastOfPath2 = getLastOfPath(object, path, Object),
1011
- obj = _getLastOfPath2.obj,
1012
- k = _getLastOfPath2.k;
1013
-
1035
+ obj = _getLastOfPath2.obj,
1036
+ k = _getLastOfPath2.k;
1014
1037
  obj[k] = obj[k] || [];
1015
1038
  if (concat) obj[k] = obj[k].concat(newValue);
1016
1039
  if (!concat) obj[k].push(newValue);
1017
1040
  }
1018
1041
  function getPath(object, path) {
1019
1042
  var _getLastOfPath3 = getLastOfPath(object, path),
1020
- obj = _getLastOfPath3.obj,
1021
- k = _getLastOfPath3.k;
1022
-
1043
+ obj = _getLastOfPath3.obj,
1044
+ k = _getLastOfPath3.k;
1023
1045
  if (!obj) return undefined;
1024
1046
  return obj[k];
1025
1047
  }
1026
1048
  function getPathWithDefaults(data, defaultData, key) {
1027
1049
  var value = getPath(data, key);
1028
-
1029
1050
  if (value !== undefined) {
1030
1051
  return value;
1031
1052
  }
1032
-
1033
1053
  return getPath(defaultData, key);
1034
1054
  }
1035
1055
  function deepExtend(target, source, overwrite) {
@@ -1046,7 +1066,6 @@ function deepExtend(target, source, overwrite) {
1046
1066
  }
1047
1067
  }
1048
1068
  }
1049
-
1050
1069
  return target;
1051
1070
  }
1052
1071
  function regexEscape(str) {
@@ -1066,7 +1085,6 @@ function escape(data) {
1066
1085
  return _entityMap[s];
1067
1086
  });
1068
1087
  }
1069
-
1070
1088
  return data;
1071
1089
  }
1072
1090
  var isIE10 = typeof window !== 'undefined' && window.navigator && typeof window.navigator.userAgentData === 'undefined' && window.navigator.userAgent && window.navigator.userAgent.indexOf('MSIE') > -1;
@@ -1082,105 +1100,77 @@ function looksLikeObjectPath(key, nsSeparator, keySeparator) {
1082
1100
  return c === '?' ? '\\?' : c;
1083
1101
  }).join('|'), ")"));
1084
1102
  var matched = !r.test(key);
1085
-
1086
1103
  if (!matched) {
1087
1104
  var ki = key.indexOf(keySeparator);
1088
-
1089
1105
  if (ki > 0 && !r.test(key.substring(0, ki))) {
1090
1106
  matched = true;
1091
1107
  }
1092
1108
  }
1093
-
1094
1109
  return matched;
1095
1110
  }
1096
1111
 
1097
- function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
1098
-
1099
- function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
1100
-
1101
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1102
-
1103
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1104
-
1112
+ function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1113
+ function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1114
+ function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1115
+ function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1105
1116
  function deepFind(obj, path) {
1106
1117
  var keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
1107
1118
  if (!obj) return undefined;
1108
1119
  if (obj[path]) return obj[path];
1109
1120
  var paths = path.split(keySeparator);
1110
1121
  var current = obj;
1111
-
1112
1122
  for (var i = 0; i < paths.length; ++i) {
1113
1123
  if (!current) return undefined;
1114
-
1115
1124
  if (typeof current[paths[i]] === 'string' && i + 1 < paths.length) {
1116
1125
  return undefined;
1117
1126
  }
1118
-
1119
1127
  if (current[paths[i]] === undefined) {
1120
1128
  var j = 2;
1121
1129
  var p = paths.slice(i, i + j).join(keySeparator);
1122
1130
  var mix = current[p];
1123
-
1124
1131
  while (mix === undefined && paths.length > i + j) {
1125
1132
  j++;
1126
1133
  p = paths.slice(i, i + j).join(keySeparator);
1127
1134
  mix = current[p];
1128
1135
  }
1129
-
1130
1136
  if (mix === undefined) return undefined;
1131
1137
  if (mix === null) return null;
1132
-
1133
1138
  if (path.endsWith(p)) {
1134
1139
  if (typeof mix === 'string') return mix;
1135
1140
  if (p && typeof mix[p] === 'string') return mix[p];
1136
1141
  }
1137
-
1138
1142
  var joinedPath = paths.slice(i + j).join(keySeparator);
1139
1143
  if (joinedPath) return deepFind(mix, joinedPath, keySeparator);
1140
1144
  return undefined;
1141
1145
  }
1142
-
1143
1146
  current = current[paths[i]];
1144
1147
  }
1145
-
1146
1148
  return current;
1147
1149
  }
1148
-
1149
1150
  var ResourceStore = function (_EventEmitter) {
1150
1151
  _inherits(ResourceStore, _EventEmitter);
1151
-
1152
- var _super = _createSuper(ResourceStore);
1153
-
1152
+ var _super = _createSuper$3(ResourceStore);
1154
1153
  function ResourceStore(data) {
1155
1154
  var _this;
1156
-
1157
1155
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1158
1156
  ns: ['translation'],
1159
1157
  defaultNS: 'translation'
1160
1158
  };
1161
-
1162
1159
  _classCallCheck(this, ResourceStore);
1163
-
1164
1160
  _this = _super.call(this);
1165
-
1166
1161
  if (isIE10) {
1167
1162
  EventEmitter.call(_assertThisInitialized(_this));
1168
1163
  }
1169
-
1170
1164
  _this.data = data || {};
1171
1165
  _this.options = options;
1172
-
1173
1166
  if (_this.options.keySeparator === undefined) {
1174
1167
  _this.options.keySeparator = '.';
1175
1168
  }
1176
-
1177
1169
  if (_this.options.ignoreJSONStructure === undefined) {
1178
1170
  _this.options.ignoreJSONStructure = true;
1179
1171
  }
1180
-
1181
1172
  return _this;
1182
1173
  }
1183
-
1184
1174
  _createClass(ResourceStore, [{
1185
1175
  key: "addNamespaces",
1186
1176
  value: function addNamespaces(ns) {
@@ -1192,7 +1182,6 @@ var ResourceStore = function (_EventEmitter) {
1192
1182
  key: "removeNamespaces",
1193
1183
  value: function removeNamespaces(ns) {
1194
1184
  var index = this.options.ns.indexOf(ns);
1195
-
1196
1185
  if (index > -1) {
1197
1186
  this.options.ns.splice(index, 1);
1198
1187
  }
@@ -1206,11 +1195,9 @@ var ResourceStore = function (_EventEmitter) {
1206
1195
  var path = [lng, ns];
1207
1196
  if (key && typeof key !== 'string') path = path.concat(key);
1208
1197
  if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
1209
-
1210
1198
  if (lng.indexOf('.') > -1) {
1211
1199
  path = lng.split('.');
1212
1200
  }
1213
-
1214
1201
  var result = getPath(this.data, path);
1215
1202
  if (result || !ignoreJSONStructure || typeof key !== 'string') return result;
1216
1203
  return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
@@ -1225,13 +1212,11 @@ var ResourceStore = function (_EventEmitter) {
1225
1212
  if (keySeparator === undefined) keySeparator = '.';
1226
1213
  var path = [lng, ns];
1227
1214
  if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
1228
-
1229
1215
  if (lng.indexOf('.') > -1) {
1230
1216
  path = lng.split('.');
1231
1217
  value = ns;
1232
1218
  ns = path[1];
1233
1219
  }
1234
-
1235
1220
  this.addNamespaces(ns);
1236
1221
  setPath(this.data, path, value);
1237
1222
  if (!options.silent) this.emit('added', lng, ns, key, value);
@@ -1242,13 +1227,11 @@ var ResourceStore = function (_EventEmitter) {
1242
1227
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
1243
1228
  silent: false
1244
1229
  };
1245
-
1246
1230
  for (var m in resources) {
1247
1231
  if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
1248
1232
  silent: true
1249
1233
  });
1250
1234
  }
1251
-
1252
1235
  if (!options.silent) this.emit('added', lng, ns, resources);
1253
1236
  }
1254
1237
  }, {
@@ -1258,23 +1241,19 @@ var ResourceStore = function (_EventEmitter) {
1258
1241
  silent: false
1259
1242
  };
1260
1243
  var path = [lng, ns];
1261
-
1262
1244
  if (lng.indexOf('.') > -1) {
1263
1245
  path = lng.split('.');
1264
1246
  deep = resources;
1265
1247
  resources = ns;
1266
1248
  ns = path[1];
1267
1249
  }
1268
-
1269
1250
  this.addNamespaces(ns);
1270
1251
  var pack = getPath(this.data, path) || {};
1271
-
1272
1252
  if (deep) {
1273
1253
  deepExtend(pack, resources, overwrite);
1274
1254
  } else {
1275
- pack = _objectSpread$1(_objectSpread$1({}, pack), resources);
1255
+ pack = _objectSpread$5(_objectSpread$5({}, pack), resources);
1276
1256
  }
1277
-
1278
1257
  setPath(this.data, path, pack);
1279
1258
  if (!options.silent) this.emit('added', lng, ns, resources);
1280
1259
  }
@@ -1284,7 +1263,6 @@ var ResourceStore = function (_EventEmitter) {
1284
1263
  if (this.hasResourceBundle(lng, ns)) {
1285
1264
  delete this.data[lng][ns];
1286
1265
  }
1287
-
1288
1266
  this.removeNamespaces(ns);
1289
1267
  this.emit('removed', lng, ns);
1290
1268
  }
@@ -1297,7 +1275,7 @@ var ResourceStore = function (_EventEmitter) {
1297
1275
  key: "getResourceBundle",
1298
1276
  value: function getResourceBundle(lng, ns) {
1299
1277
  if (!ns) ns = this.options.defaultNS;
1300
- if (this.options.compatibilityAPI === 'v1') return _objectSpread$1(_objectSpread$1({}, {}), this.getResource(lng, ns));
1278
+ if (this.options.compatibilityAPI === 'v1') return _objectSpread$5(_objectSpread$5({}, {}), this.getResource(lng, ns));
1301
1279
  return this.getResource(lng, ns);
1302
1280
  }
1303
1281
  }, {
@@ -1320,7 +1298,6 @@ var ResourceStore = function (_EventEmitter) {
1320
1298
  return this.data;
1321
1299
  }
1322
1300
  }]);
1323
-
1324
1301
  return ResourceStore;
1325
1302
  }(EventEmitter);
1326
1303
 
@@ -1331,7 +1308,6 @@ var postProcessor = {
1331
1308
  },
1332
1309
  handle: function handle(processors, value, key, options, translator) {
1333
1310
  var _this = this;
1334
-
1335
1311
  processors.forEach(function (processor) {
1336
1312
  if (_this.processors[processor]) value = _this.processors[processor].process(value, key, options, translator);
1337
1313
  });
@@ -1339,44 +1315,30 @@ var postProcessor = {
1339
1315
  }
1340
1316
  };
1341
1317
 
1342
- function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
1343
-
1344
- function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
1345
-
1346
- function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1347
-
1348
- function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1318
+ function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1319
+ function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1320
+ function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1321
+ function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1349
1322
  var checkedLoadedFor = {};
1350
-
1351
1323
  var Translator = function (_EventEmitter) {
1352
1324
  _inherits(Translator, _EventEmitter);
1353
-
1354
- var _super = _createSuper$1(Translator);
1355
-
1325
+ var _super = _createSuper$2(Translator);
1356
1326
  function Translator(services) {
1357
1327
  var _this;
1358
-
1359
1328
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1360
-
1361
1329
  _classCallCheck(this, Translator);
1362
-
1363
1330
  _this = _super.call(this);
1364
-
1365
1331
  if (isIE10) {
1366
1332
  EventEmitter.call(_assertThisInitialized(_this));
1367
1333
  }
1368
-
1369
1334
  copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, _assertThisInitialized(_this));
1370
1335
  _this.options = options;
1371
-
1372
1336
  if (_this.options.keySeparator === undefined) {
1373
1337
  _this.options.keySeparator = '.';
1374
1338
  }
1375
-
1376
1339
  _this.logger = baseLogger.create('translator');
1377
1340
  return _this;
1378
1341
  }
1379
-
1380
1342
  _createClass(Translator, [{
1381
1343
  key: "changeLanguage",
1382
1344
  value: function changeLanguage(lng) {
@@ -1388,11 +1350,9 @@ var Translator = function (_EventEmitter) {
1388
1350
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1389
1351
  interpolation: {}
1390
1352
  };
1391
-
1392
1353
  if (key === undefined || key === null) {
1393
1354
  return false;
1394
1355
  }
1395
-
1396
1356
  var resolved = this.resolve(key, options);
1397
1357
  return resolved && resolved.res !== undefined;
1398
1358
  }
@@ -1405,22 +1365,18 @@ var Translator = function (_EventEmitter) {
1405
1365
  var namespaces = options.ns || this.options.defaultNS || [];
1406
1366
  var wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
1407
1367
  var seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
1408
-
1409
1368
  if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
1410
1369
  var m = key.match(this.interpolator.nestingRegexp);
1411
-
1412
1370
  if (m && m.length > 0) {
1413
1371
  return {
1414
1372
  key: key,
1415
1373
  namespaces: namespaces
1416
1374
  };
1417
1375
  }
1418
-
1419
1376
  var parts = key.split(nsSeparator);
1420
1377
  if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
1421
1378
  key = parts.join(keySeparator);
1422
1379
  }
1423
-
1424
1380
  if (typeof namespaces === 'string') namespaces = [namespaces];
1425
1381
  return {
1426
1382
  key: key,
@@ -1431,45 +1387,35 @@ var Translator = function (_EventEmitter) {
1431
1387
  key: "translate",
1432
1388
  value: function translate(keys, options, lastKey) {
1433
1389
  var _this2 = this;
1434
-
1435
1390
  if (_typeof(options) !== 'object' && this.options.overloadTranslationOptionHandler) {
1436
1391
  options = this.options.overloadTranslationOptionHandler(arguments);
1437
1392
  }
1438
-
1439
1393
  if (!options) options = {};
1440
1394
  if (keys === undefined || keys === null) return '';
1441
1395
  if (!Array.isArray(keys)) keys = [String(keys)];
1442
1396
  var returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
1443
1397
  var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
1444
-
1445
1398
  var _this$extractFromKey = this.extractFromKey(keys[keys.length - 1], options),
1446
- key = _this$extractFromKey.key,
1447
- namespaces = _this$extractFromKey.namespaces;
1448
-
1399
+ key = _this$extractFromKey.key,
1400
+ namespaces = _this$extractFromKey.namespaces;
1449
1401
  var namespace = namespaces[namespaces.length - 1];
1450
1402
  var lng = options.lng || this.language;
1451
1403
  var appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
1452
-
1453
1404
  if (lng && lng.toLowerCase() === 'cimode') {
1454
1405
  if (appendNamespaceToCIMode) {
1455
1406
  var nsSeparator = options.nsSeparator || this.options.nsSeparator;
1456
-
1457
1407
  if (returnDetails) {
1458
1408
  resolved.res = "".concat(namespace).concat(nsSeparator).concat(key);
1459
1409
  return resolved;
1460
1410
  }
1461
-
1462
1411
  return "".concat(namespace).concat(nsSeparator).concat(key);
1463
1412
  }
1464
-
1465
1413
  if (returnDetails) {
1466
1414
  resolved.res = key;
1467
1415
  return resolved;
1468
1416
  }
1469
-
1470
1417
  return key;
1471
1418
  }
1472
-
1473
1419
  var resolved = this.resolve(keys, options);
1474
1420
  var res = resolved && resolved.res;
1475
1421
  var resUsedKey = resolved && resolved.usedKey || key;
@@ -1479,41 +1425,34 @@ var Translator = function (_EventEmitter) {
1479
1425
  var joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
1480
1426
  var handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
1481
1427
  var handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
1482
-
1483
1428
  if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
1484
1429
  if (!options.returnObjects && !this.options.returnObjects) {
1485
1430
  if (!this.options.returnedObjectHandler) {
1486
1431
  this.logger.warn('accessing an object - but returnObjects options is not enabled!');
1487
1432
  }
1488
-
1489
- var r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread$2(_objectSpread$2({}, options), {}, {
1433
+ var r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread$4(_objectSpread$4({}, options), {}, {
1490
1434
  ns: namespaces
1491
1435
  })) : "key '".concat(key, " (").concat(this.language, ")' returned an object instead of string.");
1492
-
1493
1436
  if (returnDetails) {
1494
1437
  resolved.res = r;
1495
1438
  return resolved;
1496
1439
  }
1497
-
1498
1440
  return r;
1499
1441
  }
1500
-
1501
1442
  if (keySeparator) {
1502
1443
  var resTypeIsArray = resType === '[object Array]';
1503
1444
  var copy = resTypeIsArray ? [] : {};
1504
1445
  var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
1505
-
1506
1446
  for (var m in res) {
1507
1447
  if (Object.prototype.hasOwnProperty.call(res, m)) {
1508
1448
  var deepKey = "".concat(newKeyToUse).concat(keySeparator).concat(m);
1509
- copy[m] = this.translate(deepKey, _objectSpread$2(_objectSpread$2({}, options), {
1449
+ copy[m] = this.translate(deepKey, _objectSpread$4(_objectSpread$4({}, options), {
1510
1450
  joinArrays: false,
1511
1451
  ns: namespaces
1512
1452
  }));
1513
1453
  if (copy[m] === deepKey) copy[m] = res[m];
1514
1454
  }
1515
1455
  }
1516
-
1517
1456
  res = copy;
1518
1457
  }
1519
1458
  } else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
@@ -1526,34 +1465,27 @@ var Translator = function (_EventEmitter) {
1526
1465
  var hasDefaultValue = Translator.hasDefaultValue(options);
1527
1466
  var defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
1528
1467
  var defaultValue = options["defaultValue".concat(defaultValueSuffix)] || options.defaultValue;
1529
-
1530
1468
  if (!this.isValidLookup(res) && hasDefaultValue) {
1531
1469
  usedDefault = true;
1532
1470
  res = defaultValue;
1533
1471
  }
1534
-
1535
1472
  if (!this.isValidLookup(res)) {
1536
1473
  usedKey = true;
1537
1474
  res = key;
1538
1475
  }
1539
-
1540
1476
  var missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
1541
1477
  var resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
1542
1478
  var updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
1543
-
1544
1479
  if (usedKey || usedDefault || updateMissing) {
1545
1480
  this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
1546
-
1547
1481
  if (keySeparator) {
1548
- var fk = this.resolve(key, _objectSpread$2(_objectSpread$2({}, options), {}, {
1482
+ var fk = this.resolve(key, _objectSpread$4(_objectSpread$4({}, options), {}, {
1549
1483
  keySeparator: false
1550
1484
  }));
1551
1485
  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.');
1552
1486
  }
1553
-
1554
1487
  var lngs = [];
1555
1488
  var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
1556
-
1557
1489
  if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
1558
1490
  for (var i = 0; i < fallbackLngs.length; i++) {
1559
1491
  lngs.push(fallbackLngs[i]);
@@ -1563,19 +1495,15 @@ var Translator = function (_EventEmitter) {
1563
1495
  } else {
1564
1496
  lngs.push(options.lng || this.language);
1565
1497
  }
1566
-
1567
1498
  var send = function send(l, k, specificDefaultValue) {
1568
1499
  var defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
1569
-
1570
1500
  if (_this2.options.missingKeyHandler) {
1571
1501
  _this2.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
1572
1502
  } else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {
1573
1503
  _this2.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
1574
1504
  }
1575
-
1576
1505
  _this2.emit('missingKey', l, namespace, k, res);
1577
1506
  };
1578
-
1579
1507
  if (this.options.saveMissing) {
1580
1508
  if (this.options.saveMissingPlurals && needsPluralHandling) {
1581
1509
  lngs.forEach(function (language) {
@@ -1588,10 +1516,8 @@ var Translator = function (_EventEmitter) {
1588
1516
  }
1589
1517
  }
1590
1518
  }
1591
-
1592
1519
  res = this.extendTranslation(res, keys, options, resolved, lastKey);
1593
1520
  if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = "".concat(namespace, ":").concat(key);
1594
-
1595
1521
  if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
1596
1522
  if (this.options.compatibilityAPI !== 'v1') {
1597
1523
  res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? "".concat(namespace, ":").concat(key) : key, usedDefault ? res : undefined);
@@ -1600,77 +1526,63 @@ var Translator = function (_EventEmitter) {
1600
1526
  }
1601
1527
  }
1602
1528
  }
1603
-
1604
1529
  if (returnDetails) {
1605
1530
  resolved.res = res;
1606
1531
  return resolved;
1607
1532
  }
1608
-
1609
1533
  return res;
1610
1534
  }
1611
1535
  }, {
1612
1536
  key: "extendTranslation",
1613
1537
  value: function extendTranslation(res, key, options, resolved, lastKey) {
1614
1538
  var _this3 = this;
1615
-
1616
1539
  if (this.i18nFormat && this.i18nFormat.parse) {
1617
- res = this.i18nFormat.parse(res, _objectSpread$2(_objectSpread$2({}, this.options.interpolation.defaultVariables), options), resolved.usedLng, resolved.usedNS, resolved.usedKey, {
1540
+ res = this.i18nFormat.parse(res, _objectSpread$4(_objectSpread$4({}, this.options.interpolation.defaultVariables), options), resolved.usedLng, resolved.usedNS, resolved.usedKey, {
1618
1541
  resolved: resolved
1619
1542
  });
1620
1543
  } else if (!options.skipInterpolation) {
1621
- if (options.interpolation) this.interpolator.init(_objectSpread$2(_objectSpread$2({}, options), {
1622
- interpolation: _objectSpread$2(_objectSpread$2({}, this.options.interpolation), options.interpolation)
1544
+ if (options.interpolation) this.interpolator.init(_objectSpread$4(_objectSpread$4({}, options), {
1545
+ interpolation: _objectSpread$4(_objectSpread$4({}, this.options.interpolation), options.interpolation)
1623
1546
  }));
1624
1547
  var skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
1625
1548
  var nestBef;
1626
-
1627
1549
  if (skipOnVariables) {
1628
1550
  var nb = res.match(this.interpolator.nestingRegexp);
1629
1551
  nestBef = nb && nb.length;
1630
1552
  }
1631
-
1632
1553
  var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
1633
- if (this.options.interpolation.defaultVariables) data = _objectSpread$2(_objectSpread$2({}, this.options.interpolation.defaultVariables), data);
1554
+ if (this.options.interpolation.defaultVariables) data = _objectSpread$4(_objectSpread$4({}, this.options.interpolation.defaultVariables), data);
1634
1555
  res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
1635
-
1636
1556
  if (skipOnVariables) {
1637
1557
  var na = res.match(this.interpolator.nestingRegexp);
1638
1558
  var nestAft = na && na.length;
1639
1559
  if (nestBef < nestAft) options.nest = false;
1640
1560
  }
1641
-
1642
1561
  if (options.nest !== false) res = this.interpolator.nest(res, function () {
1643
1562
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1644
1563
  args[_key] = arguments[_key];
1645
1564
  }
1646
-
1647
1565
  if (lastKey && lastKey[0] === args[0] && !options.context) {
1648
1566
  _this3.logger.warn("It seems you are nesting recursively key: ".concat(args[0], " in key: ").concat(key[0]));
1649
-
1650
1567
  return null;
1651
1568
  }
1652
-
1653
1569
  return _this3.translate.apply(_this3, args.concat([key]));
1654
1570
  }, options);
1655
1571
  if (options.interpolation) this.interpolator.reset();
1656
1572
  }
1657
-
1658
1573
  var postProcess = options.postProcess || this.options.postProcess;
1659
1574
  var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
1660
-
1661
1575
  if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
1662
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread$2({
1576
+ res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread$4({
1663
1577
  i18nResolved: resolved
1664
1578
  }, options) : options, this);
1665
1579
  }
1666
-
1667
1580
  return res;
1668
1581
  }
1669
1582
  }, {
1670
1583
  key: "resolve",
1671
1584
  value: function resolve(keys) {
1672
1585
  var _this4 = this;
1673
-
1674
1586
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1675
1587
  var found;
1676
1588
  var usedKey;
@@ -1680,65 +1592,50 @@ var Translator = function (_EventEmitter) {
1680
1592
  if (typeof keys === 'string') keys = [keys];
1681
1593
  keys.forEach(function (k) {
1682
1594
  if (_this4.isValidLookup(found)) return;
1683
-
1684
1595
  var extracted = _this4.extractFromKey(k, options);
1685
-
1686
1596
  var key = extracted.key;
1687
1597
  usedKey = key;
1688
1598
  var namespaces = extracted.namespaces;
1689
1599
  if (_this4.options.fallbackNS) namespaces = namespaces.concat(_this4.options.fallbackNS);
1690
1600
  var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
1691
-
1692
1601
  var needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && _this4.pluralResolver.shouldUseIntlApi();
1693
-
1694
1602
  var needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';
1695
1603
  var codes = options.lngs ? options.lngs : _this4.languageUtils.toResolveHierarchy(options.lng || _this4.language, options.fallbackLng);
1696
1604
  namespaces.forEach(function (ns) {
1697
1605
  if (_this4.isValidLookup(found)) return;
1698
1606
  usedNS = ns;
1699
-
1700
1607
  if (!checkedLoadedFor["".concat(codes[0], "-").concat(ns)] && _this4.utils && _this4.utils.hasLoadedNamespace && !_this4.utils.hasLoadedNamespace(usedNS)) {
1701
1608
  checkedLoadedFor["".concat(codes[0], "-").concat(ns)] = true;
1702
-
1703
1609
  _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!!!');
1704
1610
  }
1705
-
1706
1611
  codes.forEach(function (code) {
1707
1612
  if (_this4.isValidLookup(found)) return;
1708
1613
  usedLng = code;
1709
1614
  var finalKeys = [key];
1710
-
1711
1615
  if (_this4.i18nFormat && _this4.i18nFormat.addLookupKeys) {
1712
1616
  _this4.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
1713
1617
  } else {
1714
1618
  var pluralSuffix;
1715
1619
  if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count, options);
1716
- var zeroSuffix = '_zero';
1717
-
1620
+ var zeroSuffix = "".concat(_this4.options.pluralSeparator, "zero");
1718
1621
  if (needsPluralHandling) {
1719
1622
  finalKeys.push(key + pluralSuffix);
1720
-
1721
1623
  if (needsZeroSuffixLookup) {
1722
1624
  finalKeys.push(key + zeroSuffix);
1723
1625
  }
1724
1626
  }
1725
-
1726
1627
  if (needsContextHandling) {
1727
1628
  var contextKey = "".concat(key).concat(_this4.options.contextSeparator).concat(options.context);
1728
1629
  finalKeys.push(contextKey);
1729
-
1730
1630
  if (needsPluralHandling) {
1731
1631
  finalKeys.push(contextKey + pluralSuffix);
1732
-
1733
1632
  if (needsZeroSuffixLookup) {
1734
1633
  finalKeys.push(contextKey + zeroSuffix);
1735
1634
  }
1736
1635
  }
1737
1636
  }
1738
1637
  }
1739
-
1740
1638
  var possibleKey;
1741
-
1742
1639
  while (possibleKey = finalKeys.pop()) {
1743
1640
  if (!_this4.isValidLookup(found)) {
1744
1641
  exactUsedKey = possibleKey;
@@ -1772,33 +1669,27 @@ var Translator = function (_EventEmitter) {
1772
1669
  key: "hasDefaultValue",
1773
1670
  value: function hasDefaultValue(options) {
1774
1671
  var prefix = 'defaultValue';
1775
-
1776
1672
  for (var option in options) {
1777
1673
  if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
1778
1674
  return true;
1779
1675
  }
1780
1676
  }
1781
-
1782
1677
  return false;
1783
1678
  }
1784
1679
  }]);
1785
-
1786
1680
  return Translator;
1787
1681
  }(EventEmitter);
1788
1682
 
1789
1683
  function capitalize(string) {
1790
1684
  return string.charAt(0).toUpperCase() + string.slice(1);
1791
1685
  }
1792
-
1793
1686
  var LanguageUtil = function () {
1794
1687
  function LanguageUtil(options) {
1795
1688
  _classCallCheck(this, LanguageUtil);
1796
-
1797
1689
  this.options = options;
1798
1690
  this.supportedLngs = this.options.supportedLngs || false;
1799
1691
  this.logger = baseLogger.create('languageUtils');
1800
1692
  }
1801
-
1802
1693
  _createClass(LanguageUtil, [{
1803
1694
  key: "getScriptPartFromCode",
1804
1695
  value: function getScriptPartFromCode(code) {
@@ -1822,7 +1713,6 @@ var LanguageUtil = function () {
1822
1713
  if (typeof code === 'string' && code.indexOf('-') > -1) {
1823
1714
  var specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
1824
1715
  var p = code.split('-');
1825
-
1826
1716
  if (this.options.lowerCaseLng) {
1827
1717
  p = p.map(function (part) {
1828
1718
  return part.toLowerCase();
@@ -1838,10 +1728,8 @@ var LanguageUtil = function () {
1838
1728
  if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
1839
1729
  if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
1840
1730
  }
1841
-
1842
1731
  return p.join('-');
1843
1732
  }
1844
-
1845
1733
  return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
1846
1734
  }
1847
1735
  }, {
@@ -1850,37 +1738,29 @@ var LanguageUtil = function () {
1850
1738
  if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
1851
1739
  code = this.getLanguagePartFromCode(code);
1852
1740
  }
1853
-
1854
1741
  return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
1855
1742
  }
1856
1743
  }, {
1857
1744
  key: "getBestMatchFromCodes",
1858
1745
  value: function getBestMatchFromCodes(codes) {
1859
1746
  var _this = this;
1860
-
1861
1747
  if (!codes) return null;
1862
1748
  var found;
1863
1749
  codes.forEach(function (code) {
1864
1750
  if (found) return;
1865
-
1866
1751
  var cleanedLng = _this.formatLanguageCode(code);
1867
-
1868
1752
  if (!_this.options.supportedLngs || _this.isSupportedCode(cleanedLng)) found = cleanedLng;
1869
1753
  });
1870
-
1871
1754
  if (!found && this.options.supportedLngs) {
1872
1755
  codes.forEach(function (code) {
1873
1756
  if (found) return;
1874
-
1875
1757
  var lngOnly = _this.getLanguagePartFromCode(code);
1876
-
1877
1758
  if (_this.isSupportedCode(lngOnly)) return found = lngOnly;
1878
1759
  found = _this.options.supportedLngs.find(function (supportedLng) {
1879
1760
  if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;
1880
1761
  });
1881
1762
  });
1882
1763
  }
1883
-
1884
1764
  if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
1885
1765
  return found;
1886
1766
  }
@@ -1903,20 +1783,16 @@ var LanguageUtil = function () {
1903
1783
  key: "toResolveHierarchy",
1904
1784
  value: function toResolveHierarchy(code, fallbackCode) {
1905
1785
  var _this2 = this;
1906
-
1907
1786
  var fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
1908
1787
  var codes = [];
1909
-
1910
1788
  var addCode = function addCode(c) {
1911
1789
  if (!c) return;
1912
-
1913
1790
  if (_this2.isSupportedCode(c)) {
1914
1791
  codes.push(c);
1915
1792
  } else {
1916
1793
  _this2.logger.warn("rejecting language code not found in supportedLngs: ".concat(c));
1917
1794
  }
1918
1795
  };
1919
-
1920
1796
  if (typeof code === 'string' && code.indexOf('-') > -1) {
1921
1797
  if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
1922
1798
  if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
@@ -1924,14 +1800,12 @@ var LanguageUtil = function () {
1924
1800
  } else if (typeof code === 'string') {
1925
1801
  addCode(this.formatLanguageCode(code));
1926
1802
  }
1927
-
1928
1803
  fallbackCodes.forEach(function (fc) {
1929
1804
  if (codes.indexOf(fc) < 0) addCode(_this2.formatLanguageCode(fc));
1930
1805
  });
1931
1806
  return codes;
1932
1807
  }
1933
1808
  }]);
1934
-
1935
1809
  return LanguageUtil;
1936
1810
  }();
1937
1811
 
@@ -2105,7 +1979,6 @@ var suffixesOrder = {
2105
1979
  many: 4,
2106
1980
  other: 5
2107
1981
  };
2108
-
2109
1982
  function createRules() {
2110
1983
  var rules = {};
2111
1984
  sets.forEach(function (set) {
@@ -2118,25 +1991,19 @@ function createRules() {
2118
1991
  });
2119
1992
  return rules;
2120
1993
  }
2121
-
2122
1994
  var PluralResolver = function () {
2123
1995
  function PluralResolver(languageUtils) {
2124
1996
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2125
-
2126
1997
  _classCallCheck(this, PluralResolver);
2127
-
2128
1998
  this.languageUtils = languageUtils;
2129
1999
  this.options = options;
2130
2000
  this.logger = baseLogger.create('pluralResolver');
2131
-
2132
2001
  if ((!this.options.compatibilityJSON || this.options.compatibilityJSON === 'v4') && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
2133
2002
  this.options.compatibilityJSON = 'v3';
2134
2003
  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.');
2135
2004
  }
2136
-
2137
2005
  this.rules = createRules();
2138
2006
  }
2139
-
2140
2007
  _createClass(PluralResolver, [{
2141
2008
  key: "addRule",
2142
2009
  value: function addRule(lng, obj) {
@@ -2146,7 +2013,6 @@ var PluralResolver = function () {
2146
2013
  key: "getRule",
2147
2014
  value: function getRule(code) {
2148
2015
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2149
-
2150
2016
  if (this.shouldUseIntlApi()) {
2151
2017
  try {
2152
2018
  return new Intl.PluralRules(code, {
@@ -2156,7 +2022,6 @@ var PluralResolver = function () {
2156
2022
  return;
2157
2023
  }
2158
2024
  }
2159
-
2160
2025
  return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
2161
2026
  }
2162
2027
  }, {
@@ -2164,11 +2029,9 @@ var PluralResolver = function () {
2164
2029
  value: function needsPlural(code) {
2165
2030
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2166
2031
  var rule = this.getRule(code, options);
2167
-
2168
2032
  if (this.shouldUseIntlApi()) {
2169
2033
  return rule && rule.resolvedOptions().pluralCategories.length > 1;
2170
2034
  }
2171
-
2172
2035
  return rule && rule.numbers.length > 1;
2173
2036
  }
2174
2037
  }, {
@@ -2183,14 +2046,11 @@ var PluralResolver = function () {
2183
2046
  key: "getSuffixes",
2184
2047
  value: function getSuffixes(code) {
2185
2048
  var _this = this;
2186
-
2187
2049
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2188
2050
  var rule = this.getRule(code, options);
2189
-
2190
2051
  if (!rule) {
2191
2052
  return [];
2192
2053
  }
2193
-
2194
2054
  if (this.shouldUseIntlApi()) {
2195
2055
  return rule.resolvedOptions().pluralCategories.sort(function (pluralCategory1, pluralCategory2) {
2196
2056
  return suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2];
@@ -2198,7 +2058,6 @@ var PluralResolver = function () {
2198
2058
  return "".concat(_this.options.prepend).concat(pluralCategory);
2199
2059
  });
2200
2060
  }
2201
-
2202
2061
  return rule.numbers.map(function (number) {
2203
2062
  return _this.getSuffix(code, number, options);
2204
2063
  });
@@ -2208,15 +2067,12 @@ var PluralResolver = function () {
2208
2067
  value: function getSuffix(code, count) {
2209
2068
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2210
2069
  var rule = this.getRule(code, options);
2211
-
2212
2070
  if (rule) {
2213
2071
  if (this.shouldUseIntlApi()) {
2214
2072
  return "".concat(this.options.prepend).concat(rule.select(count));
2215
2073
  }
2216
-
2217
2074
  return this.getSuffixRetroCompatible(rule, count);
2218
2075
  }
2219
-
2220
2076
  this.logger.warn("no plural rule found for: ".concat(code));
2221
2077
  return '';
2222
2078
  }
@@ -2224,10 +2080,8 @@ var PluralResolver = function () {
2224
2080
  key: "getSuffixRetroCompatible",
2225
2081
  value: function getSuffixRetroCompatible(rule, count) {
2226
2082
  var _this2 = this;
2227
-
2228
2083
  var idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
2229
2084
  var suffix = rule.numbers[idx];
2230
-
2231
2085
  if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
2232
2086
  if (suffix === 2) {
2233
2087
  suffix = 'plural';
@@ -2235,11 +2089,9 @@ var PluralResolver = function () {
2235
2089
  suffix = '';
2236
2090
  }
2237
2091
  }
2238
-
2239
2092
  var returnSuffix = function returnSuffix() {
2240
2093
  return _this2.options.prepend && suffix.toString() ? _this2.options.prepend + suffix.toString() : suffix.toString();
2241
2094
  };
2242
-
2243
2095
  if (this.options.compatibilityJSON === 'v1') {
2244
2096
  if (suffix === 1) return '';
2245
2097
  if (typeof suffix === 'number') return "_plural_".concat(suffix.toString());
@@ -2249,7 +2101,6 @@ var PluralResolver = function () {
2249
2101
  } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
2250
2102
  return returnSuffix();
2251
2103
  }
2252
-
2253
2104
  return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
2254
2105
  }
2255
2106
  }, {
@@ -2258,30 +2109,22 @@ var PluralResolver = function () {
2258
2109
  return !deprecatedJsonVersions.includes(this.options.compatibilityJSON);
2259
2110
  }
2260
2111
  }]);
2261
-
2262
2112
  return PluralResolver;
2263
2113
  }();
2264
2114
 
2265
- function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
2266
-
2267
- function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
2268
-
2115
+ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2116
+ function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2269
2117
  var Interpolator = function () {
2270
2118
  function Interpolator() {
2271
2119
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2272
-
2273
2120
  _classCallCheck(this, Interpolator);
2274
-
2275
2121
  this.logger = baseLogger.create('interpolator');
2276
2122
  this.options = options;
2277
-
2278
2123
  this.format = options.interpolation && options.interpolation.format || function (value) {
2279
2124
  return value;
2280
2125
  };
2281
-
2282
2126
  this.init(options);
2283
2127
  }
2284
-
2285
2128
  _createClass(Interpolator, [{
2286
2129
  key: "init",
2287
2130
  value: function init() {
@@ -2324,16 +2167,13 @@ var Interpolator = function () {
2324
2167
  key: "interpolate",
2325
2168
  value: function interpolate(str, data, lng, options) {
2326
2169
  var _this = this;
2327
-
2328
2170
  var match;
2329
2171
  var value;
2330
2172
  var replaces;
2331
2173
  var defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
2332
-
2333
2174
  function regexSafe(val) {
2334
2175
  return val.replace(/\$/g, '$$$$');
2335
2176
  }
2336
-
2337
2177
  var handleFormat = function handleFormat(key) {
2338
2178
  if (key.indexOf(_this.formatSeparator) < 0) {
2339
2179
  var path = getPathWithDefaults(data, defaultData, key);
@@ -2341,7 +2181,6 @@ var Interpolator = function () {
2341
2181
  interpolationkey: key
2342
2182
  })) : path;
2343
2183
  }
2344
-
2345
2184
  var p = key.split(_this.formatSeparator);
2346
2185
  var k = p.shift().trim();
2347
2186
  var f = p.join(_this.formatSeparator).trim();
@@ -2349,7 +2188,6 @@ var Interpolator = function () {
2349
2188
  interpolationkey: k
2350
2189
  }));
2351
2190
  };
2352
-
2353
2191
  this.resetRegExp();
2354
2192
  var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
2355
2193
  var skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
@@ -2366,11 +2204,9 @@ var Interpolator = function () {
2366
2204
  }];
2367
2205
  todos.forEach(function (todo) {
2368
2206
  replaces = 0;
2369
-
2370
2207
  while (match = todo.regex.exec(str)) {
2371
2208
  var matchedVar = match[1].trim();
2372
2209
  value = handleFormat(matchedVar);
2373
-
2374
2210
  if (value === undefined) {
2375
2211
  if (typeof missingInterpolationHandler === 'function') {
2376
2212
  var temp = missingInterpolationHandler(str, match, options);
@@ -2382,25 +2218,20 @@ var Interpolator = function () {
2382
2218
  continue;
2383
2219
  } else {
2384
2220
  _this.logger.warn("missed to pass in variable ".concat(matchedVar, " for interpolating ").concat(str));
2385
-
2386
2221
  value = '';
2387
2222
  }
2388
2223
  } else if (typeof value !== 'string' && !_this.useRawValueToEscape) {
2389
2224
  value = makeString(value);
2390
2225
  }
2391
-
2392
2226
  var safeValue = todo.safeValue(value);
2393
2227
  str = str.replace(match[0], safeValue);
2394
-
2395
2228
  if (skipOnVariables) {
2396
2229
  todo.regex.lastIndex += value.length;
2397
2230
  todo.regex.lastIndex -= match[0].length;
2398
2231
  } else {
2399
2232
  todo.regex.lastIndex = 0;
2400
2233
  }
2401
-
2402
2234
  replaces++;
2403
-
2404
2235
  if (replaces >= _this.maxReplaces) {
2405
2236
  break;
2406
2237
  }
@@ -2412,16 +2243,10 @@ var Interpolator = function () {
2412
2243
  key: "nest",
2413
2244
  value: function nest(str, fc) {
2414
2245
  var _this2 = this;
2415
-
2416
2246
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2417
2247
  var match;
2418
2248
  var value;
2419
-
2420
- var clonedOptions = _objectSpread$3({}, options);
2421
-
2422
- clonedOptions.applyPostProcessor = false;
2423
- delete clonedOptions.defaultValue;
2424
-
2249
+ var clonedOptions;
2425
2250
  function handleHasOptions(key, inheritedOptions) {
2426
2251
  var sep = this.nestingOptionsSeparator;
2427
2252
  if (key.indexOf(sep) < 0) return key;
@@ -2429,8 +2254,11 @@ var Interpolator = function () {
2429
2254
  var optionsString = "{".concat(c[1]);
2430
2255
  key = c[0];
2431
2256
  optionsString = this.interpolate(optionsString, clonedOptions);
2432
- optionsString = optionsString.replace(/'/g, '"');
2433
-
2257
+ var matchedSingleQuotes = optionsString.match(/'/g);
2258
+ var matchedDoubleQuotes = optionsString.match(/"/g);
2259
+ if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
2260
+ optionsString = optionsString.replace(/'/g, '"');
2261
+ }
2434
2262
  try {
2435
2263
  clonedOptions = JSON.parse(optionsString);
2436
2264
  if (inheritedOptions) clonedOptions = _objectSpread$3(_objectSpread$3({}, inheritedOptions), clonedOptions);
@@ -2438,15 +2266,16 @@ var Interpolator = function () {
2438
2266
  this.logger.warn("failed parsing options string in nesting for key ".concat(key), e);
2439
2267
  return "".concat(key).concat(sep).concat(optionsString);
2440
2268
  }
2441
-
2442
2269
  delete clonedOptions.defaultValue;
2443
2270
  return key;
2444
2271
  }
2445
-
2446
2272
  while (match = this.nestingRegexp.exec(str)) {
2447
2273
  var formatters = [];
2274
+ clonedOptions = _objectSpread$3({}, options);
2275
+ clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;
2276
+ clonedOptions.applyPostProcessor = false;
2277
+ delete clonedOptions.defaultValue;
2448
2278
  var doReduce = false;
2449
-
2450
2279
  if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
2451
2280
  var r = match[1].split(this.formatSeparator).map(function (elem) {
2452
2281
  return elem.trim();
@@ -2455,16 +2284,13 @@ var Interpolator = function () {
2455
2284
  formatters = r;
2456
2285
  doReduce = true;
2457
2286
  }
2458
-
2459
2287
  value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
2460
2288
  if (value && match[0] === str && typeof value !== 'string') return value;
2461
2289
  if (typeof value !== 'string') value = makeString(value);
2462
-
2463
2290
  if (!value) {
2464
2291
  this.logger.warn("missed to resolve ".concat(match[1], " for nesting ").concat(str));
2465
2292
  value = '';
2466
2293
  }
2467
-
2468
2294
  if (doReduce) {
2469
2295
  value = formatters.reduce(function (v, f) {
2470
2296
  return _this2.format(v, f, options.lng, _objectSpread$3(_objectSpread$3({}, options), {}, {
@@ -2472,31 +2298,24 @@ var Interpolator = function () {
2472
2298
  }));
2473
2299
  }, value.trim());
2474
2300
  }
2475
-
2476
2301
  str = str.replace(match[0], value);
2477
2302
  this.regexp.lastIndex = 0;
2478
2303
  }
2479
-
2480
2304
  return str;
2481
2305
  }
2482
2306
  }]);
2483
-
2484
2307
  return Interpolator;
2485
2308
  }();
2486
2309
 
2487
- function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
2488
-
2489
- function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
2490
-
2310
+ function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2311
+ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2491
2312
  function parseFormatStr(formatStr) {
2492
2313
  var formatName = formatStr.toLowerCase().trim();
2493
2314
  var formatOptions = {};
2494
-
2495
2315
  if (formatStr.indexOf('(') > -1) {
2496
2316
  var p = formatStr.split('(');
2497
2317
  formatName = p[0].toLowerCase().trim();
2498
2318
  var optStr = p[1].substring(0, p[1].length - 1);
2499
-
2500
2319
  if (formatName === 'currency' && optStr.indexOf(':') < 0) {
2501
2320
  if (!formatOptions.currency) formatOptions.currency = optStr.trim();
2502
2321
  } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
@@ -2505,12 +2324,10 @@ function parseFormatStr(formatStr) {
2505
2324
  var opts = optStr.split(';');
2506
2325
  opts.forEach(function (opt) {
2507
2326
  if (!opt) return;
2508
-
2509
2327
  var _opt$split = opt.split(':'),
2510
- _opt$split2 = _toArray(_opt$split),
2511
- key = _opt$split2[0],
2512
- rest = _opt$split2.slice(1);
2513
-
2328
+ _opt$split2 = _toArray(_opt$split),
2329
+ key = _opt$split2[0],
2330
+ rest = _opt$split2.slice(1);
2514
2331
  var val = rest.join(':').trim().replace(/^'+|'+$/g, '');
2515
2332
  if (!formatOptions[key.trim()]) formatOptions[key.trim()] = val;
2516
2333
  if (val === 'false') formatOptions[key.trim()] = false;
@@ -2519,43 +2336,65 @@ function parseFormatStr(formatStr) {
2519
2336
  });
2520
2337
  }
2521
2338
  }
2522
-
2523
2339
  return {
2524
2340
  formatName: formatName,
2525
2341
  formatOptions: formatOptions
2526
2342
  };
2527
2343
  }
2528
-
2344
+ function createCachedFormatter(fn) {
2345
+ var cache = {};
2346
+ return function invokeFormatter(val, lng, options) {
2347
+ var key = lng + JSON.stringify(options);
2348
+ var formatter = cache[key];
2349
+ if (!formatter) {
2350
+ formatter = fn(lng, options);
2351
+ cache[key] = formatter;
2352
+ }
2353
+ return formatter(val);
2354
+ };
2355
+ }
2529
2356
  var Formatter = function () {
2530
2357
  function Formatter() {
2531
2358
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2532
-
2533
2359
  _classCallCheck(this, Formatter);
2534
-
2535
2360
  this.logger = baseLogger.create('formatter');
2536
2361
  this.options = options;
2537
2362
  this.formats = {
2538
- number: function number(val, lng, options) {
2539
- return new Intl.NumberFormat(lng, options).format(val);
2540
- },
2541
- currency: function currency(val, lng, options) {
2542
- return new Intl.NumberFormat(lng, _objectSpread$4(_objectSpread$4({}, options), {}, {
2363
+ number: createCachedFormatter(function (lng, options) {
2364
+ var formatter = new Intl.NumberFormat(lng, options);
2365
+ return function (val) {
2366
+ return formatter.format(val);
2367
+ };
2368
+ }),
2369
+ currency: createCachedFormatter(function (lng, options) {
2370
+ var formatter = new Intl.NumberFormat(lng, _objectSpread$2(_objectSpread$2({}, options), {}, {
2543
2371
  style: 'currency'
2544
- })).format(val);
2545
- },
2546
- datetime: function datetime(val, lng, options) {
2547
- return new Intl.DateTimeFormat(lng, _objectSpread$4({}, options)).format(val);
2548
- },
2549
- relativetime: function relativetime(val, lng, options) {
2550
- return new Intl.RelativeTimeFormat(lng, _objectSpread$4({}, options)).format(val, options.range || 'day');
2551
- },
2552
- list: function list(val, lng, options) {
2553
- return new Intl.ListFormat(lng, _objectSpread$4({}, options)).format(val);
2554
- }
2372
+ }));
2373
+ return function (val) {
2374
+ return formatter.format(val);
2375
+ };
2376
+ }),
2377
+ datetime: createCachedFormatter(function (lng, options) {
2378
+ var formatter = new Intl.DateTimeFormat(lng, _objectSpread$2({}, options));
2379
+ return function (val) {
2380
+ return formatter.format(val);
2381
+ };
2382
+ }),
2383
+ relativetime: createCachedFormatter(function (lng, options) {
2384
+ var formatter = new Intl.RelativeTimeFormat(lng, _objectSpread$2({}, options));
2385
+ return function (val) {
2386
+ return formatter.format(val, options.range || 'day');
2387
+ };
2388
+ }),
2389
+ list: createCachedFormatter(function (lng, options) {
2390
+ var formatter = new Intl.ListFormat(lng, _objectSpread$2({}, options));
2391
+ return function (val) {
2392
+ return formatter.format(val);
2393
+ };
2394
+ })
2555
2395
  };
2556
2396
  this.init(options);
2557
2397
  }
2558
-
2559
2398
  _createClass(Formatter, [{
2560
2399
  key: "init",
2561
2400
  value: function init(services) {
@@ -2570,76 +2409,62 @@ var Formatter = function () {
2570
2409
  value: function add(name, fc) {
2571
2410
  this.formats[name.toLowerCase().trim()] = fc;
2572
2411
  }
2412
+ }, {
2413
+ key: "addCached",
2414
+ value: function addCached(name, fc) {
2415
+ this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
2416
+ }
2573
2417
  }, {
2574
2418
  key: "format",
2575
2419
  value: function format(value, _format, lng, options) {
2576
2420
  var _this = this;
2577
-
2578
2421
  var formats = _format.split(this.formatSeparator);
2579
-
2580
2422
  var result = formats.reduce(function (mem, f) {
2581
2423
  var _parseFormatStr = parseFormatStr(f),
2582
- formatName = _parseFormatStr.formatName,
2583
- formatOptions = _parseFormatStr.formatOptions;
2584
-
2424
+ formatName = _parseFormatStr.formatName,
2425
+ formatOptions = _parseFormatStr.formatOptions;
2585
2426
  if (_this.formats[formatName]) {
2586
2427
  var formatted = mem;
2587
-
2588
2428
  try {
2589
2429
  var valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
2590
2430
  var l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
2591
- formatted = _this.formats[formatName](mem, l, _objectSpread$4(_objectSpread$4(_objectSpread$4({}, formatOptions), options), valOptions));
2431
+ formatted = _this.formats[formatName](mem, l, _objectSpread$2(_objectSpread$2(_objectSpread$2({}, formatOptions), options), valOptions));
2592
2432
  } catch (error) {
2593
2433
  _this.logger.warn(error);
2594
2434
  }
2595
-
2596
2435
  return formatted;
2597
2436
  } else {
2598
2437
  _this.logger.warn("there was no format function for ".concat(formatName));
2599
2438
  }
2600
-
2601
2439
  return mem;
2602
2440
  }, value);
2603
2441
  return result;
2604
2442
  }
2605
2443
  }]);
2606
-
2607
2444
  return Formatter;
2608
2445
  }();
2609
2446
 
2610
- function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
2611
-
2612
- function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
2613
-
2614
- function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
2615
-
2616
- function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
2617
-
2447
+ function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2448
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2449
+ function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
2450
+ function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
2618
2451
  function removePending(q, name) {
2619
2452
  if (q.pending[name] !== undefined) {
2620
2453
  delete q.pending[name];
2621
2454
  q.pendingCount--;
2622
2455
  }
2623
2456
  }
2624
-
2625
2457
  var Connector = function (_EventEmitter) {
2626
2458
  _inherits(Connector, _EventEmitter);
2627
-
2628
- var _super = _createSuper$2(Connector);
2629
-
2459
+ var _super = _createSuper$1(Connector);
2630
2460
  function Connector(backend, store, services) {
2631
2461
  var _this;
2632
-
2633
2462
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2634
-
2635
2463
  _classCallCheck(this, Connector);
2636
-
2637
2464
  _this = _super.call(this);
2638
-
2639
2465
  if (isIE10) {
2640
2466
  EventEmitter.call(_assertThisInitialized(_this));
2641
2467
  }
2642
-
2643
2468
  _this.backend = backend;
2644
2469
  _this.store = store;
2645
2470
  _this.services = services;
@@ -2649,21 +2474,19 @@ var Connector = function (_EventEmitter) {
2649
2474
  _this.waitingReads = [];
2650
2475
  _this.maxParallelReads = options.maxParallelReads || 10;
2651
2476
  _this.readingCalls = 0;
2477
+ _this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
2478
+ _this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
2652
2479
  _this.state = {};
2653
2480
  _this.queue = [];
2654
-
2655
2481
  if (_this.backend && _this.backend.init) {
2656
2482
  _this.backend.init(services, options.backend, options);
2657
2483
  }
2658
-
2659
2484
  return _this;
2660
2485
  }
2661
-
2662
2486
  _createClass(Connector, [{
2663
2487
  key: "queueLoad",
2664
2488
  value: function queueLoad(languages, namespaces, options, callback) {
2665
2489
  var _this2 = this;
2666
-
2667
2490
  var toLoad = {};
2668
2491
  var pending = {};
2669
2492
  var toLoadLanguages = {};
@@ -2672,7 +2495,6 @@ var Connector = function (_EventEmitter) {
2672
2495
  var hasAllNamespaces = true;
2673
2496
  namespaces.forEach(function (ns) {
2674
2497
  var name = "".concat(lng, "|").concat(ns);
2675
-
2676
2498
  if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
2677
2499
  _this2.state[name] = 2;
2678
2500
  } else if (_this2.state[name] < 0) ; else if (_this2.state[name] === 1) {
@@ -2687,7 +2509,6 @@ var Connector = function (_EventEmitter) {
2687
2509
  });
2688
2510
  if (!hasAllNamespaces) toLoadLanguages[lng] = true;
2689
2511
  });
2690
-
2691
2512
  if (Object.keys(toLoad).length || Object.keys(pending).length) {
2692
2513
  this.queue.push({
2693
2514
  pending: pending,
@@ -2697,7 +2518,6 @@ var Connector = function (_EventEmitter) {
2697
2518
  callback: callback
2698
2519
  });
2699
2520
  }
2700
-
2701
2521
  return {
2702
2522
  toLoad: Object.keys(toLoad),
2703
2523
  pending: Object.keys(pending),
@@ -2712,23 +2532,19 @@ var Connector = function (_EventEmitter) {
2712
2532
  var lng = s[0];
2713
2533
  var ns = s[1];
2714
2534
  if (err) this.emit('failedLoading', lng, ns, err);
2715
-
2716
2535
  if (data) {
2717
2536
  this.store.addResourceBundle(lng, ns, data);
2718
2537
  }
2719
-
2720
2538
  this.state[name] = err ? -1 : 2;
2721
2539
  var loaded = {};
2722
2540
  this.queue.forEach(function (q) {
2723
2541
  pushPath(q.loaded, [lng], ns);
2724
2542
  removePending(q, name);
2725
2543
  if (err) q.errors.push(err);
2726
-
2727
2544
  if (q.pendingCount === 0 && !q.done) {
2728
2545
  Object.keys(q.loaded).forEach(function (l) {
2729
2546
  if (!loaded[l]) loaded[l] = {};
2730
2547
  var loadedKeys = q.loaded[l];
2731
-
2732
2548
  if (loadedKeys.length) {
2733
2549
  loadedKeys.forEach(function (ns) {
2734
2550
  if (loaded[l][ns] === undefined) loaded[l][ns] = true;
@@ -2736,7 +2552,6 @@ var Connector = function (_EventEmitter) {
2736
2552
  }
2737
2553
  });
2738
2554
  q.done = true;
2739
-
2740
2555
  if (q.errors.length) {
2741
2556
  q.callback(q.errors);
2742
2557
  } else {
@@ -2753,12 +2568,10 @@ var Connector = function (_EventEmitter) {
2753
2568
  key: "read",
2754
2569
  value: function read(lng, ns, fcName) {
2755
2570
  var _this3 = this;
2756
-
2757
2571
  var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
2758
- var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 350;
2572
+ var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
2759
2573
  var callback = arguments.length > 5 ? arguments[5] : undefined;
2760
2574
  if (!lng.length) return callback(null, {});
2761
-
2762
2575
  if (this.readingCalls >= this.maxParallelReads) {
2763
2576
  this.waitingReads.push({
2764
2577
  lng: lng,
@@ -2770,49 +2583,56 @@ var Connector = function (_EventEmitter) {
2770
2583
  });
2771
2584
  return;
2772
2585
  }
2773
-
2774
2586
  this.readingCalls++;
2775
- return this.backend[fcName](lng, ns, function (err, data) {
2776
- if (err && data && tried < 5) {
2777
- setTimeout(function () {
2778
- _this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
2779
- }, wait);
2780
- return;
2781
- }
2782
-
2587
+ var resolver = function resolver(err, data) {
2783
2588
  _this3.readingCalls--;
2784
-
2785
2589
  if (_this3.waitingReads.length > 0) {
2786
2590
  var next = _this3.waitingReads.shift();
2787
-
2788
2591
  _this3.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
2789
2592
  }
2790
-
2593
+ if (err && data && tried < _this3.maxRetries) {
2594
+ setTimeout(function () {
2595
+ _this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
2596
+ }, wait);
2597
+ return;
2598
+ }
2791
2599
  callback(err, data);
2792
- });
2600
+ };
2601
+ var fc = this.backend[fcName].bind(this.backend);
2602
+ if (fc.length === 2) {
2603
+ try {
2604
+ var r = fc(lng, ns);
2605
+ if (r && typeof r.then === 'function') {
2606
+ r.then(function (data) {
2607
+ return resolver(null, data);
2608
+ })["catch"](resolver);
2609
+ } else {
2610
+ resolver(null, r);
2611
+ }
2612
+ } catch (err) {
2613
+ resolver(err);
2614
+ }
2615
+ return;
2616
+ }
2617
+ return fc(lng, ns, resolver);
2793
2618
  }
2794
2619
  }, {
2795
2620
  key: "prepareLoading",
2796
2621
  value: function prepareLoading(languages, namespaces) {
2797
2622
  var _this4 = this;
2798
-
2799
2623
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2800
2624
  var callback = arguments.length > 3 ? arguments[3] : undefined;
2801
-
2802
2625
  if (!this.backend) {
2803
2626
  this.logger.warn('No backend was added via i18next.use. Will not load resources.');
2804
2627
  return callback && callback();
2805
2628
  }
2806
-
2807
2629
  if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
2808
2630
  if (typeof namespaces === 'string') namespaces = [namespaces];
2809
2631
  var toLoad = this.queueLoad(languages, namespaces, options, callback);
2810
-
2811
2632
  if (!toLoad.toLoad.length) {
2812
2633
  if (!toLoad.pending.length) callback();
2813
2634
  return null;
2814
2635
  }
2815
-
2816
2636
  toLoad.toLoad.forEach(function (name) {
2817
2637
  _this4.loadOne(name);
2818
2638
  });
@@ -2833,7 +2653,6 @@ var Connector = function (_EventEmitter) {
2833
2653
  key: "loadOne",
2834
2654
  value: function loadOne(name) {
2835
2655
  var _this5 = this;
2836
-
2837
2656
  var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2838
2657
  var s = name.split('|');
2839
2658
  var lng = s[0];
@@ -2841,7 +2660,6 @@ var Connector = function (_EventEmitter) {
2841
2660
  this.read(lng, ns, 'read', undefined, undefined, function (err, data) {
2842
2661
  if (err) _this5.logger.warn("".concat(prefix, "loading namespace ").concat(ns, " for language ").concat(lng, " failed"), err);
2843
2662
  if (!err && data) _this5.logger.log("".concat(prefix, "loaded namespace ").concat(ns, " for language ").concat(lng), data);
2844
-
2845
2663
  _this5.loaded(name, err, data);
2846
2664
  });
2847
2665
  }
@@ -2849,25 +2667,43 @@ var Connector = function (_EventEmitter) {
2849
2667
  key: "saveMissing",
2850
2668
  value: function saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
2851
2669
  var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
2852
-
2670
+ var clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : function () {};
2853
2671
  if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
2854
2672
  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!!!');
2855
2673
  return;
2856
2674
  }
2857
-
2858
2675
  if (key === undefined || key === null || key === '') return;
2859
-
2860
2676
  if (this.backend && this.backend.create) {
2861
- this.backend.create(languages, namespace, key, fallbackValue, null, _objectSpread$5(_objectSpread$5({}, options), {}, {
2677
+ var opts = _objectSpread$1(_objectSpread$1({}, options), {}, {
2862
2678
  isUpdate: isUpdate
2863
- }));
2679
+ });
2680
+ var fc = this.backend.create.bind(this.backend);
2681
+ if (fc.length < 6) {
2682
+ try {
2683
+ var r;
2684
+ if (fc.length === 5) {
2685
+ r = fc(languages, namespace, key, fallbackValue, opts);
2686
+ } else {
2687
+ r = fc(languages, namespace, key, fallbackValue);
2688
+ }
2689
+ if (r && typeof r.then === 'function') {
2690
+ r.then(function (data) {
2691
+ return clb(null, data);
2692
+ })["catch"](clb);
2693
+ } else {
2694
+ clb(null, r);
2695
+ }
2696
+ } catch (err) {
2697
+ clb(err);
2698
+ }
2699
+ } else {
2700
+ fc(languages, namespace, key, fallbackValue, clb, opts);
2701
+ }
2864
2702
  }
2865
-
2866
2703
  if (!languages || !languages[0]) return;
2867
2704
  this.store.addResource(languages[0], namespace, key, fallbackValue);
2868
2705
  }
2869
2706
  }]);
2870
-
2871
2707
  return Connector;
2872
2708
  }(EventEmitter);
2873
2709
 
@@ -2910,14 +2746,12 @@ function get() {
2910
2746
  if (_typeof(args[1]) === 'object') ret = args[1];
2911
2747
  if (typeof args[1] === 'string') ret.defaultValue = args[1];
2912
2748
  if (typeof args[2] === 'string') ret.tDescription = args[2];
2913
-
2914
2749
  if (_typeof(args[2]) === 'object' || _typeof(args[3]) === 'object') {
2915
2750
  var options = args[3] || args[2];
2916
2751
  Object.keys(options).forEach(function (key) {
2917
2752
  ret[key] = options[key];
2918
2753
  });
2919
2754
  }
2920
-
2921
2755
  return ret;
2922
2756
  },
2923
2757
  interpolation: {
@@ -2941,24 +2775,17 @@ function transformOptions(options) {
2941
2775
  if (typeof options.ns === 'string') options.ns = [options.ns];
2942
2776
  if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
2943
2777
  if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
2944
-
2945
2778
  if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
2946
2779
  options.supportedLngs = options.supportedLngs.concat(['cimode']);
2947
2780
  }
2948
-
2949
2781
  return options;
2950
2782
  }
2951
2783
 
2952
- function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
2953
-
2954
- function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
2955
-
2956
- function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
2957
-
2958
- function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
2959
-
2784
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2785
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2786
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
2787
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
2960
2788
  function noop() {}
2961
-
2962
2789
  function bindMemberFunctions(inst) {
2963
2790
  var mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
2964
2791
  mems.forEach(function (mem) {
@@ -2967,26 +2794,18 @@ function bindMemberFunctions(inst) {
2967
2794
  }
2968
2795
  });
2969
2796
  }
2970
-
2971
2797
  var I18n = function (_EventEmitter) {
2972
2798
  _inherits(I18n, _EventEmitter);
2973
-
2974
- var _super = _createSuper$3(I18n);
2975
-
2799
+ var _super = _createSuper(I18n);
2976
2800
  function I18n() {
2977
2801
  var _this;
2978
-
2979
2802
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2980
2803
  var callback = arguments.length > 1 ? arguments[1] : undefined;
2981
-
2982
2804
  _classCallCheck(this, I18n);
2983
-
2984
2805
  _this = _super.call(this);
2985
-
2986
2806
  if (isIE10) {
2987
2807
  EventEmitter.call(_assertThisInitialized(_this));
2988
2808
  }
2989
-
2990
2809
  _this.options = transformOptions(options);
2991
2810
  _this.services = {};
2992
2811
  _this.logger = baseLogger;
@@ -2994,79 +2813,62 @@ var I18n = function (_EventEmitter) {
2994
2813
  external: []
2995
2814
  };
2996
2815
  bindMemberFunctions(_assertThisInitialized(_this));
2997
-
2998
2816
  if (callback && !_this.isInitialized && !options.isClone) {
2999
2817
  if (!_this.options.initImmediate) {
3000
2818
  _this.init(options, callback);
3001
-
3002
2819
  return _possibleConstructorReturn(_this, _assertThisInitialized(_this));
3003
2820
  }
3004
-
3005
2821
  setTimeout(function () {
3006
2822
  _this.init(options, callback);
3007
2823
  }, 0);
3008
2824
  }
3009
-
3010
2825
  return _this;
3011
2826
  }
3012
-
3013
2827
  _createClass(I18n, [{
3014
2828
  key: "init",
3015
2829
  value: function init() {
3016
2830
  var _this2 = this;
3017
-
3018
2831
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3019
2832
  var callback = arguments.length > 1 ? arguments[1] : undefined;
3020
-
3021
2833
  if (typeof options === 'function') {
3022
2834
  callback = options;
3023
2835
  options = {};
3024
2836
  }
3025
-
3026
- if (!options.defaultNS && options.ns) {
2837
+ if (!options.defaultNS && options.defaultNS !== false && options.ns) {
3027
2838
  if (typeof options.ns === 'string') {
3028
2839
  options.defaultNS = options.ns;
3029
2840
  } else if (options.ns.indexOf('translation') < 0) {
3030
2841
  options.defaultNS = options.ns[0];
3031
2842
  }
3032
2843
  }
3033
-
3034
2844
  var defOpts = get();
3035
- this.options = _objectSpread$6(_objectSpread$6(_objectSpread$6({}, defOpts), this.options), transformOptions(options));
3036
-
2845
+ this.options = _objectSpread(_objectSpread(_objectSpread({}, defOpts), this.options), transformOptions(options));
3037
2846
  if (this.options.compatibilityAPI !== 'v1') {
3038
- this.options.interpolation = _objectSpread$6(_objectSpread$6({}, defOpts.interpolation), this.options.interpolation);
2847
+ this.options.interpolation = _objectSpread(_objectSpread({}, defOpts.interpolation), this.options.interpolation);
3039
2848
  }
3040
-
3041
2849
  if (options.keySeparator !== undefined) {
3042
2850
  this.options.userDefinedKeySeparator = options.keySeparator;
3043
2851
  }
3044
-
3045
2852
  if (options.nsSeparator !== undefined) {
3046
2853
  this.options.userDefinedNsSeparator = options.nsSeparator;
3047
2854
  }
3048
-
3049
2855
  function createClassOnDemand(ClassOrObject) {
3050
2856
  if (!ClassOrObject) return null;
3051
2857
  if (typeof ClassOrObject === 'function') return new ClassOrObject();
3052
2858
  return ClassOrObject;
3053
2859
  }
3054
-
3055
2860
  if (!this.options.isClone) {
3056
2861
  if (this.modules.logger) {
3057
2862
  baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
3058
2863
  } else {
3059
2864
  baseLogger.init(null, this.options);
3060
2865
  }
3061
-
3062
2866
  var formatter;
3063
-
3064
2867
  if (this.modules.formatter) {
3065
2868
  formatter = this.modules.formatter;
3066
2869
  } else if (typeof Intl !== 'undefined') {
3067
2870
  formatter = Formatter;
3068
2871
  }
3069
-
3070
2872
  var lu = new LanguageUtil(this.options);
3071
2873
  this.store = new ResourceStore(this.options.resources, this.options);
3072
2874
  var s = this.services;
@@ -3078,13 +2880,11 @@ var I18n = function (_EventEmitter) {
3078
2880
  compatibilityJSON: this.options.compatibilityJSON,
3079
2881
  simplifyPluralSuffix: this.options.simplifyPluralSuffix
3080
2882
  });
3081
-
3082
2883
  if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
3083
2884
  s.formatter = createClassOnDemand(formatter);
3084
2885
  s.formatter.init(s, this.options);
3085
2886
  this.options.interpolation.format = s.formatter.format.bind(s.formatter);
3086
2887
  }
3087
-
3088
2888
  s.interpolator = new Interpolator(this.options);
3089
2889
  s.utils = {
3090
2890
  hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
@@ -3094,50 +2894,40 @@ var I18n = function (_EventEmitter) {
3094
2894
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
3095
2895
  args[_key - 1] = arguments[_key];
3096
2896
  }
3097
-
3098
2897
  _this2.emit.apply(_this2, [event].concat(args));
3099
2898
  });
3100
-
3101
2899
  if (this.modules.languageDetector) {
3102
2900
  s.languageDetector = createClassOnDemand(this.modules.languageDetector);
3103
- s.languageDetector.init(s, this.options.detection, this.options);
2901
+ if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
3104
2902
  }
3105
-
3106
2903
  if (this.modules.i18nFormat) {
3107
2904
  s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
3108
2905
  if (s.i18nFormat.init) s.i18nFormat.init(this);
3109
2906
  }
3110
-
3111
2907
  this.translator = new Translator(this.services, this.options);
3112
2908
  this.translator.on('*', function (event) {
3113
2909
  for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
3114
2910
  args[_key2 - 1] = arguments[_key2];
3115
2911
  }
3116
-
3117
2912
  _this2.emit.apply(_this2, [event].concat(args));
3118
2913
  });
3119
2914
  this.modules.external.forEach(function (m) {
3120
2915
  if (m.init) m.init(_this2);
3121
2916
  });
3122
2917
  }
3123
-
3124
2918
  this.format = this.options.interpolation.format;
3125
2919
  if (!callback) callback = noop;
3126
-
3127
2920
  if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
3128
2921
  var codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
3129
2922
  if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
3130
2923
  }
3131
-
3132
2924
  if (!this.services.languageDetector && !this.options.lng) {
3133
2925
  this.logger.warn('init: no languageDetector is used and no lng is defined');
3134
2926
  }
3135
-
3136
2927
  var storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
3137
2928
  storeApi.forEach(function (fcName) {
3138
2929
  _this2[fcName] = function () {
3139
2930
  var _this2$store;
3140
-
3141
2931
  return (_this2$store = _this2.store)[fcName].apply(_this2$store, arguments);
3142
2932
  };
3143
2933
  });
@@ -3145,63 +2935,48 @@ var I18n = function (_EventEmitter) {
3145
2935
  storeApiChained.forEach(function (fcName) {
3146
2936
  _this2[fcName] = function () {
3147
2937
  var _this2$store2;
3148
-
3149
2938
  (_this2$store2 = _this2.store)[fcName].apply(_this2$store2, arguments);
3150
-
3151
2939
  return _this2;
3152
2940
  };
3153
2941
  });
3154
2942
  var deferred = defer();
3155
-
3156
2943
  var load = function load() {
3157
2944
  var finish = function finish(err, t) {
3158
2945
  if (_this2.isInitialized && !_this2.initializedStoreOnce) _this2.logger.warn('init: i18next is already initialized. You should call init just once!');
3159
2946
  _this2.isInitialized = true;
3160
2947
  if (!_this2.options.isClone) _this2.logger.log('initialized', _this2.options);
3161
-
3162
2948
  _this2.emit('initialized', _this2.options);
3163
-
3164
2949
  deferred.resolve(t);
3165
2950
  callback(err, t);
3166
2951
  };
3167
-
3168
2952
  if (_this2.languages && _this2.options.compatibilityAPI !== 'v1' && !_this2.isInitialized) return finish(null, _this2.t.bind(_this2));
3169
-
3170
2953
  _this2.changeLanguage(_this2.options.lng, finish);
3171
2954
  };
3172
-
3173
2955
  if (this.options.resources || !this.options.initImmediate) {
3174
2956
  load();
3175
2957
  } else {
3176
2958
  setTimeout(load, 0);
3177
2959
  }
3178
-
3179
2960
  return deferred;
3180
2961
  }
3181
2962
  }, {
3182
2963
  key: "loadResources",
3183
2964
  value: function loadResources(language) {
3184
2965
  var _this3 = this;
3185
-
3186
2966
  var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
3187
2967
  var usedCallback = callback;
3188
2968
  var usedLng = typeof language === 'string' ? language : this.language;
3189
2969
  if (typeof language === 'function') usedCallback = language;
3190
-
3191
2970
  if (!this.options.resources || this.options.partialBundledLanguages) {
3192
2971
  if (usedLng && usedLng.toLowerCase() === 'cimode') return usedCallback();
3193
2972
  var toLoad = [];
3194
-
3195
2973
  var append = function append(lng) {
3196
2974
  if (!lng) return;
3197
-
3198
2975
  var lngs = _this3.services.languageUtils.toResolveHierarchy(lng);
3199
-
3200
2976
  lngs.forEach(function (l) {
3201
2977
  if (toLoad.indexOf(l) < 0) toLoad.push(l);
3202
2978
  });
3203
2979
  };
3204
-
3205
2980
  if (!usedLng) {
3206
2981
  var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
3207
2982
  fallbacks.forEach(function (l) {
@@ -3210,13 +2985,11 @@ var I18n = function (_EventEmitter) {
3210
2985
  } else {
3211
2986
  append(usedLng);
3212
2987
  }
3213
-
3214
2988
  if (this.options.preload) {
3215
2989
  this.options.preload.forEach(function (l) {
3216
2990
  return append(l);
3217
2991
  });
3218
2992
  }
3219
-
3220
2993
  this.services.backendConnector.load(toLoad, this.options.ns, function (e) {
3221
2994
  if (!e && !_this3.resolvedLanguage && _this3.language) _this3.setResolvedLanguage(_this3.language);
3222
2995
  usedCallback(e);
@@ -3243,35 +3016,27 @@ var I18n = function (_EventEmitter) {
3243
3016
  value: function use(module) {
3244
3017
  if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
3245
3018
  if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
3246
-
3247
3019
  if (module.type === 'backend') {
3248
3020
  this.modules.backend = module;
3249
3021
  }
3250
-
3251
3022
  if (module.type === 'logger' || module.log && module.warn && module.error) {
3252
3023
  this.modules.logger = module;
3253
3024
  }
3254
-
3255
3025
  if (module.type === 'languageDetector') {
3256
3026
  this.modules.languageDetector = module;
3257
3027
  }
3258
-
3259
3028
  if (module.type === 'i18nFormat') {
3260
3029
  this.modules.i18nFormat = module;
3261
3030
  }
3262
-
3263
3031
  if (module.type === 'postProcessor') {
3264
3032
  postProcessor.addPostProcessor(module);
3265
3033
  }
3266
-
3267
3034
  if (module.type === 'formatter') {
3268
3035
  this.modules.formatter = module;
3269
3036
  }
3270
-
3271
3037
  if (module.type === '3rdParty') {
3272
3038
  this.modules.external.push(module);
3273
3039
  }
3274
-
3275
3040
  return this;
3276
3041
  }
3277
3042
  }, {
@@ -3279,11 +3044,9 @@ var I18n = function (_EventEmitter) {
3279
3044
  value: function setResolvedLanguage(l) {
3280
3045
  if (!l || !this.languages) return;
3281
3046
  if (['cimode', 'dev'].indexOf(l) > -1) return;
3282
-
3283
3047
  for (var li = 0; li < this.languages.length; li++) {
3284
3048
  var lngInLngs = this.languages[li];
3285
3049
  if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
3286
-
3287
3050
  if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
3288
3051
  this.resolvedLanguage = lngInLngs;
3289
3052
  break;
@@ -3294,34 +3057,25 @@ var I18n = function (_EventEmitter) {
3294
3057
  key: "changeLanguage",
3295
3058
  value: function changeLanguage(lng, callback) {
3296
3059
  var _this4 = this;
3297
-
3298
3060
  this.isLanguageChangingTo = lng;
3299
3061
  var deferred = defer();
3300
3062
  this.emit('languageChanging', lng);
3301
-
3302
3063
  var setLngProps = function setLngProps(l) {
3303
3064
  _this4.language = l;
3304
3065
  _this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);
3305
3066
  _this4.resolvedLanguage = undefined;
3306
-
3307
3067
  _this4.setResolvedLanguage(l);
3308
3068
  };
3309
-
3310
3069
  var done = function done(err, l) {
3311
3070
  if (l) {
3312
3071
  setLngProps(l);
3313
-
3314
3072
  _this4.translator.changeLanguage(l);
3315
-
3316
3073
  _this4.isLanguageChangingTo = undefined;
3317
-
3318
3074
  _this4.emit('languageChanged', l);
3319
-
3320
3075
  _this4.logger.log('languageChanged', l);
3321
3076
  } else {
3322
3077
  _this4.isLanguageChangingTo = undefined;
3323
3078
  }
3324
-
3325
3079
  deferred.resolve(function () {
3326
3080
  return _this4.t.apply(_this4, arguments);
3327
3081
  });
@@ -3329,67 +3083,67 @@ var I18n = function (_EventEmitter) {
3329
3083
  return _this4.t.apply(_this4, arguments);
3330
3084
  });
3331
3085
  };
3332
-
3333
3086
  var setLng = function setLng(lngs) {
3334
3087
  if (!lng && !lngs && _this4.services.languageDetector) lngs = [];
3335
3088
  var l = typeof lngs === 'string' ? lngs : _this4.services.languageUtils.getBestMatchFromCodes(lngs);
3336
-
3337
3089
  if (l) {
3338
3090
  if (!_this4.language) {
3339
3091
  setLngProps(l);
3340
3092
  }
3341
-
3342
3093
  if (!_this4.translator.language) _this4.translator.changeLanguage(l);
3343
- if (_this4.services.languageDetector) _this4.services.languageDetector.cacheUserLanguage(l);
3094
+ if (_this4.services.languageDetector && _this4.services.languageDetector.cacheUserLanguage) _this4.services.languageDetector.cacheUserLanguage(l);
3344
3095
  }
3345
-
3346
3096
  _this4.loadResources(l, function (err) {
3347
3097
  done(err, l);
3348
3098
  });
3349
3099
  };
3350
-
3351
3100
  if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
3352
3101
  setLng(this.services.languageDetector.detect());
3353
3102
  } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
3354
- this.services.languageDetector.detect(setLng);
3103
+ if (this.services.languageDetector.detect.length === 0) {
3104
+ this.services.languageDetector.detect().then(setLng);
3105
+ } else {
3106
+ this.services.languageDetector.detect(setLng);
3107
+ }
3355
3108
  } else {
3356
3109
  setLng(lng);
3357
3110
  }
3358
-
3359
3111
  return deferred;
3360
3112
  }
3361
3113
  }, {
3362
3114
  key: "getFixedT",
3363
3115
  value: function getFixedT(lng, ns, keyPrefix) {
3364
3116
  var _this5 = this;
3365
-
3366
3117
  var fixedT = function fixedT(key, opts) {
3367
3118
  var options;
3368
-
3369
3119
  if (_typeof(opts) !== 'object') {
3370
3120
  for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
3371
3121
  rest[_key3 - 2] = arguments[_key3];
3372
3122
  }
3373
-
3374
3123
  options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
3375
3124
  } else {
3376
- options = _objectSpread$6({}, opts);
3125
+ options = _objectSpread({}, opts);
3377
3126
  }
3378
-
3379
3127
  options.lng = options.lng || fixedT.lng;
3380
3128
  options.lngs = options.lngs || fixedT.lngs;
3381
3129
  options.ns = options.ns || fixedT.ns;
3130
+ options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
3382
3131
  var keySeparator = _this5.options.keySeparator || '.';
3383
- var resultKey = keyPrefix ? "".concat(keyPrefix).concat(keySeparator).concat(key) : key;
3132
+ var resultKey;
3133
+ if (options.keyPrefix && Array.isArray(key)) {
3134
+ resultKey = key.map(function (k) {
3135
+ return "".concat(options.keyPrefix).concat(keySeparator).concat(k);
3136
+ });
3137
+ } else {
3138
+ resultKey = options.keyPrefix ? "".concat(options.keyPrefix).concat(keySeparator).concat(key) : key;
3139
+ }
3384
3140
  return _this5.t(resultKey, options);
3385
3141
  };
3386
-
3387
3142
  if (typeof lng === 'string') {
3388
3143
  fixedT.lng = lng;
3389
3144
  } else {
3390
3145
  fixedT.lngs = lng;
3391
3146
  }
3392
-
3393
3147
  fixedT.ns = ns;
3394
3148
  fixedT.keyPrefix = keyPrefix;
3395
3149
  return fixedT;
@@ -3398,14 +3152,12 @@ var I18n = function (_EventEmitter) {
3398
3152
  key: "t",
3399
3153
  value: function t() {
3400
3154
  var _this$translator;
3401
-
3402
3155
  return this.translator && (_this$translator = this.translator).translate.apply(_this$translator, arguments);
3403
3156
  }
3404
3157
  }, {
3405
3158
  key: "exists",
3406
3159
  value: function exists() {
3407
3160
  var _this$translator2;
3408
-
3409
3161
  return this.translator && (_this$translator2 = this.translator).exists.apply(_this$translator2, arguments);
3410
3162
  }
3411
3163
  }, {
@@ -3417,35 +3169,27 @@ var I18n = function (_EventEmitter) {
3417
3169
  key: "hasLoadedNamespace",
3418
3170
  value: function hasLoadedNamespace(ns) {
3419
3171
  var _this6 = this;
3420
-
3421
3172
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3422
-
3423
3173
  if (!this.isInitialized) {
3424
3174
  this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
3425
3175
  return false;
3426
3176
  }
3427
-
3428
3177
  if (!this.languages || !this.languages.length) {
3429
3178
  this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
3430
3179
  return false;
3431
3180
  }
3432
-
3433
3181
  var lng = this.resolvedLanguage || this.languages[0];
3434
3182
  var fallbackLng = this.options ? this.options.fallbackLng : false;
3435
3183
  var lastLng = this.languages[this.languages.length - 1];
3436
3184
  if (lng.toLowerCase() === 'cimode') return true;
3437
-
3438
3185
  var loadNotPending = function loadNotPending(l, n) {
3439
3186
  var loadState = _this6.services.backendConnector.state["".concat(l, "|").concat(n)];
3440
-
3441
3187
  return loadState === -1 || loadState === 2;
3442
3188
  };
3443
-
3444
3189
  if (options.precheck) {
3445
3190
  var preResult = options.precheck(this, loadNotPending);
3446
3191
  if (preResult !== undefined) return preResult;
3447
3192
  }
3448
-
3449
3193
  if (this.hasResourceBundle(lng, ns)) return true;
3450
3194
  if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
3451
3195
  if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
@@ -3455,14 +3199,11 @@ var I18n = function (_EventEmitter) {
3455
3199
  key: "loadNamespaces",
3456
3200
  value: function loadNamespaces(ns, callback) {
3457
3201
  var _this7 = this;
3458
-
3459
3202
  var deferred = defer();
3460
-
3461
3203
  if (!this.options.ns) {
3462
3204
  callback && callback();
3463
3205
  return Promise.resolve();
3464
3206
  }
3465
-
3466
3207
  if (typeof ns === 'string') ns = [ns];
3467
3208
  ns.forEach(function (n) {
3468
3209
  if (_this7.options.ns.indexOf(n) < 0) _this7.options.ns.push(n);
@@ -3482,12 +3223,10 @@ var I18n = function (_EventEmitter) {
3482
3223
  var newLngs = lngs.filter(function (lng) {
3483
3224
  return preloaded.indexOf(lng) < 0;
3484
3225
  });
3485
-
3486
3226
  if (!newLngs.length) {
3487
3227
  if (callback) callback();
3488
3228
  return Promise.resolve();
3489
3229
  }
3490
-
3491
3230
  this.options.preload = preloaded.concat(newLngs);
3492
3231
  this.loadResources(function (err) {
3493
3232
  deferred.resolve();
@@ -3501,26 +3240,27 @@ var I18n = function (_EventEmitter) {
3501
3240
  if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
3502
3241
  if (!lng) return 'rtl';
3503
3242
  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'];
3504
- return rtlLngs.indexOf(this.services.languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
3243
+ var languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
3244
+ return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
3505
3245
  }
3506
3246
  }, {
3507
3247
  key: "cloneInstance",
3508
3248
  value: function cloneInstance() {
3509
3249
  var _this8 = this;
3510
-
3511
3250
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3512
3251
  var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
3513
-
3514
- var mergedOptions = _objectSpread$6(_objectSpread$6(_objectSpread$6({}, this.options), options), {
3252
+ var mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, this.options), options), {
3515
3253
  isClone: true
3516
3254
  });
3517
-
3518
3255
  var clone = new I18n(mergedOptions);
3256
+ if (options.debug !== undefined || options.prefix !== undefined) {
3257
+ clone.logger = clone.logger.clone(options);
3258
+ }
3519
3259
  var membersToCopy = ['store', 'services', 'language'];
3520
3260
  membersToCopy.forEach(function (m) {
3521
3261
  clone[m] = _this8[m];
3522
3262
  });
3523
- clone.services = _objectSpread$6({}, this.services);
3263
+ clone.services = _objectSpread({}, this.services);
3524
3264
  clone.services.utils = {
3525
3265
  hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
3526
3266
  };
@@ -3529,7 +3269,6 @@ var I18n = function (_EventEmitter) {
3529
3269
  for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
3530
3270
  args[_key4 - 1] = arguments[_key4];
3531
3271
  }
3532
-
3533
3272
  clone.emit.apply(clone, [event].concat(args));
3534
3273
  });
3535
3274
  clone.init(mergedOptions, callback);
@@ -3551,16 +3290,13 @@ var I18n = function (_EventEmitter) {
3551
3290
  };
3552
3291
  }
3553
3292
  }]);
3554
-
3555
3293
  return I18n;
3556
3294
  }(EventEmitter);
3557
-
3558
3295
  _defineProperty(I18n, "createInstance", function () {
3559
3296
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3560
3297
  var callback = arguments.length > 1 ? arguments[1] : undefined;
3561
3298
  return new I18n(options, callback);
3562
3299
  });
3563
-
3564
3300
  var instance = I18n.createInstance();
3565
3301
  instance.createInstance = I18n.createInstance;
3566
3302
 
@@ -3644,7 +3380,22 @@ function _extends() {
3644
3380
  return _extends.apply(this, arguments);
3645
3381
  }
3646
3382
 
3647
- var LIBRARY_VERSION = '1.2.0';
3383
+ function _objectWithoutPropertiesLoose(source, excluded) {
3384
+ if (source == null) return {};
3385
+ var target = {};
3386
+ var sourceKeys = Object.keys(source);
3387
+ var key, i;
3388
+
3389
+ for (i = 0; i < sourceKeys.length; i++) {
3390
+ key = sourceKeys[i];
3391
+ if (excluded.indexOf(key) >= 0) continue;
3392
+ target[key] = source[key];
3393
+ }
3394
+
3395
+ return target;
3396
+ }
3397
+
3398
+ var LIBRARY_VERSION = '1.2.2';
3648
3399
 
3649
3400
  var QueriesPeriod;
3650
3401
 
@@ -25683,16 +25434,19 @@ return src;
25683
25434
  })));
25684
25435
  });
25685
25436
 
25686
- const defaultDatasetIdKey = 'label';
25437
+ const defaultDatasetIdKey = "label";
25687
25438
  function reforwardRef(ref, value) {
25688
- if (typeof ref === 'function') {
25439
+ if (typeof ref === "function") {
25689
25440
  ref(value);
25690
25441
  } else if (ref) {
25691
25442
  ref.current = value;
25692
25443
  }
25693
25444
  }
25694
25445
  function setOptions(chart, nextOptions) {
25695
- Object.assign(chart.options, nextOptions);
25446
+ const options = chart.options;
25447
+ if (options && nextOptions) {
25448
+ Object.assign(options, nextOptions);
25449
+ }
25696
25450
  }
25697
25451
  function setLabels(currentData, nextLabels) {
25698
25452
  currentData.labels = nextLabels;
@@ -25702,8 +25456,7 @@ function setDatasets(currentData, nextDatasets) {
25702
25456
  const addedDatasets = [];
25703
25457
  currentData.datasets = nextDatasets.map((nextDataset)=>{
25704
25458
  // given the new set, find it's current match
25705
- const currentDataset = currentData.datasets.find((dataset)=>dataset[datasetIdKey] === nextDataset[datasetIdKey]
25706
- );
25459
+ const currentDataset = currentData.datasets.find((dataset)=>dataset[datasetIdKey] === nextDataset[datasetIdKey]);
25707
25460
  // There is no original to update, so simply add new one
25708
25461
  if (!currentDataset || !nextDataset.data || addedDatasets.includes(currentDataset)) {
25709
25462
  return {
@@ -25726,8 +25479,8 @@ function cloneData(data) {
25726
25479
  return nextData;
25727
25480
  }
25728
25481
 
25729
- function ChartComponent(param, ref) {
25730
- let { height =150 , width =300 , redraw =false , datasetIdKey , type , data , options , plugins =[] , fallbackContent , updateMode , ...props } = param;
25482
+ function ChartComponent(props, ref) {
25483
+ const { height =150 , width =300 , redraw =false , datasetIdKey , type , data , options , plugins =[] , fallbackContent , updateMode , ...canvasProps } = props;
25731
25484
  const canvasRef = React.useRef(null);
25732
25485
  const chartRef = React.useRef();
25733
25486
  const renderChart = ()=>{
@@ -25797,15 +25550,14 @@ function ChartComponent(param, ref) {
25797
25550
  ]);
25798
25551
  React.useEffect(()=>{
25799
25552
  renderChart();
25800
- return ()=>destroyChart()
25801
- ;
25553
+ return ()=>destroyChart();
25802
25554
  }, []);
25803
- return(/*#__PURE__*/ React__default["default"].createElement("canvas", Object.assign({
25555
+ return /*#__PURE__*/ React__default["default"].createElement("canvas", Object.assign({
25804
25556
  ref: canvasRef,
25805
25557
  role: "img",
25806
25558
  height: height,
25807
25559
  width: width
25808
- }, props), fallbackContent));
25560
+ }, canvasProps), fallbackContent);
25809
25561
  }
25810
25562
  const Chart = /*#__PURE__*/ React.forwardRef(ChartComponent);
25811
25563
 
@@ -28535,17 +28287,14 @@ var WidgetView = function WidgetView(_ref) {
28535
28287
  }));
28536
28288
  };
28537
28289
 
28290
+ var _excluded = ["url", "token", "lang", "data"];
28291
+
28538
28292
  var Widget = function Widget(_ref) {
28539
- var id = _ref.id,
28540
- url = _ref.url,
28293
+ var url = _ref.url,
28541
28294
  token = _ref.token,
28542
28295
  lang = _ref.lang,
28543
28296
  data = _ref.data,
28544
- settings = _ref.settings,
28545
- editMode = _ref.editMode,
28546
- openSettingsModal = _ref.openSettingsModal,
28547
- onSettingsModalOpened = _ref.onSettingsModalOpened,
28548
- onSettingsModalClosed = _ref.onSettingsModalClosed;
28297
+ widgetProps = _objectWithoutPropertiesLoose(_ref, _excluded);
28549
28298
 
28550
28299
  var _useState = React.useState(),
28551
28300
  graphqlSdk = _useState[0],
@@ -28572,21 +28321,16 @@ var Widget = function Widget(_ref) {
28572
28321
  })["catch"](function () {});
28573
28322
  }
28574
28323
  }, [data, graphqlSdk]);
28575
- return React__default["default"].createElement(andoncloudWidgetBase.BaseWidget, {
28576
- id: id,
28324
+ return React__default["default"].createElement(andoncloudWidgetBase.BaseWidget, _extends({
28577
28325
  url: url,
28578
28326
  token: token,
28579
28327
  lang: lang,
28580
28328
  data: widgetData,
28581
- settings: settings,
28582
- openSettingsModal: openSettingsModal,
28583
- onSettingsModalOpened: onSettingsModalOpened,
28584
- onSettingsModalClosed: onSettingsModalClosed,
28585
- editMode: editMode,
28586
28329
  WidgetView: WidgetView,
28587
28330
  SettingsFormContent: SettingsFormContent,
28588
- version: LIBRARY_VERSION
28589
- });
28331
+ version: LIBRARY_VERSION,
28332
+ "data-testid": "prometheus-widget"
28333
+ }, widgetProps));
28590
28334
  };
28591
28335
 
28592
28336
  var getDisplayName = function getDisplayName(lang) {