@bigbinary/neeto-message-templates-frontend 0.3.5 → 0.3.6

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.cjs.js CHANGED
@@ -3,14 +3,16 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
- var pure = require('@bigbinary/neeto-commons-frontend/pure');
6
+ var neetoCist = require('@bigbinary/neeto-cist');
7
7
  var neetoFiltersFrontend = require('@bigbinary/neeto-filters-frontend');
8
8
  var Container = require('@bigbinary/neeto-molecules/Container');
9
9
  var NeetoHeader = require('@bigbinary/neeto-molecules/Header');
10
10
  var SubHeader = require('@bigbinary/neeto-molecules/SubHeader');
11
11
  var neetoui = require('@bigbinary/neetoui');
12
12
  var ramda = require('ramda');
13
+ var i18next = require('i18next');
13
14
  var neetoIcons = require('@bigbinary/neeto-icons');
15
+ var reactI18next = require('react-i18next');
14
16
  var constants = require('@bigbinary/neeto-commons-frontend/constants');
15
17
  var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
16
18
  var reactQuery = require('react-query');
@@ -61,3489 +63,39 @@ function _typeof$1(obj) {
61
63
  }, _typeof$1(obj);
62
64
  }
63
65
 
64
- function _classCallCheck(instance, Constructor) {
65
- if (!(instance instanceof Constructor)) {
66
- throw new TypeError("Cannot call a class as a function");
67
- }
68
- }
69
-
70
- function _toPrimitive(input, hint) {
71
- if (_typeof$1(input) !== "object" || input === null) return input;
72
- var prim = input[Symbol.toPrimitive];
73
- if (prim !== undefined) {
74
- var res = prim.call(input, hint || "default");
75
- if (_typeof$1(res) !== "object") return res;
76
- throw new TypeError("@@toPrimitive must return a primitive value.");
77
- }
78
- return (hint === "string" ? String : Number)(input);
79
- }
80
-
81
- function _toPropertyKey(arg) {
82
- var key = _toPrimitive(arg, "string");
83
- return _typeof$1(key) === "symbol" ? key : String(key);
84
- }
85
-
86
- function _defineProperties(target, props) {
87
- for (var i = 0; i < props.length; i++) {
88
- var descriptor = props[i];
89
- descriptor.enumerable = descriptor.enumerable || false;
90
- descriptor.configurable = true;
91
- if ("value" in descriptor) descriptor.writable = true;
92
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
93
- }
94
- }
95
- function _createClass(Constructor, protoProps, staticProps) {
96
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
97
- if (staticProps) _defineProperties(Constructor, staticProps);
98
- Object.defineProperty(Constructor, "prototype", {
99
- writable: false
100
- });
101
- return Constructor;
102
- }
103
-
104
- function _assertThisInitialized(self) {
105
- if (self === void 0) {
106
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
107
- }
108
- return self;
109
- }
110
-
111
- function _setPrototypeOf(o, p) {
112
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
113
- o.__proto__ = p;
114
- return o;
115
- };
116
- return _setPrototypeOf(o, p);
117
- }
118
-
119
- function _inherits(subClass, superClass) {
120
- if (typeof superClass !== "function" && superClass !== null) {
121
- throw new TypeError("Super expression must either be null or a function");
122
- }
123
- subClass.prototype = Object.create(superClass && superClass.prototype, {
124
- constructor: {
125
- value: subClass,
126
- writable: true,
127
- configurable: true
128
- }
129
- });
130
- Object.defineProperty(subClass, "prototype", {
131
- writable: false
132
- });
133
- if (superClass) _setPrototypeOf(subClass, superClass);
134
- }
135
-
136
- function _possibleConstructorReturn(self, call) {
137
- if (call && (_typeof$1(call) === "object" || typeof call === "function")) {
138
- return call;
139
- } else if (call !== void 0) {
140
- throw new TypeError("Derived constructors may only return object or undefined");
141
- }
142
- return _assertThisInitialized(self);
143
- }
144
-
145
- function _getPrototypeOf(o) {
146
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
147
- return o.__proto__ || Object.getPrototypeOf(o);
148
- };
149
- return _getPrototypeOf(o);
150
- }
151
-
152
- function _defineProperty(obj, key, value) {
153
- key = _toPropertyKey(key);
154
- if (key in obj) {
155
- Object.defineProperty(obj, key, {
156
- value: value,
157
- enumerable: true,
158
- configurable: true,
159
- writable: true
160
- });
161
- } else {
162
- obj[key] = value;
163
- }
164
- return obj;
165
- }
166
-
167
- function _arrayWithHoles(arr) {
168
- if (Array.isArray(arr)) return arr;
169
- }
170
-
171
- function _iterableToArray(iter) {
172
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
173
- }
174
-
175
- function _arrayLikeToArray(arr, len) {
176
- if (len == null || len > arr.length) len = arr.length;
177
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
178
- return arr2;
179
- }
180
-
181
- function _unsupportedIterableToArray(o, minLen) {
182
- if (!o) return;
183
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
184
- var n = Object.prototype.toString.call(o).slice(8, -1);
185
- if (n === "Object" && o.constructor) n = o.constructor.name;
186
- if (n === "Map" || n === "Set") return Array.from(o);
187
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
188
- }
189
-
190
- function _nonIterableRest() {
191
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
192
- }
193
-
194
- function _toArray(arr) {
195
- return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
196
- }
197
-
198
- function ownKeys$6$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; }
199
- function _objectSpread$6$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
200
- var consoleLogger = {
201
- type: 'logger',
202
- log: function log(args) {
203
- this.output('log', args);
204
- },
205
- warn: function warn(args) {
206
- this.output('warn', args);
207
- },
208
- error: function error(args) {
209
- this.output('error', args);
210
- },
211
- output: function output(type, args) {
212
- if (console && console[type]) console[type].apply(console, args);
213
- }
214
- };
215
- var Logger = function () {
216
- function Logger(concreteLogger) {
217
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
218
- _classCallCheck(this, Logger);
219
- this.init(concreteLogger, options);
220
- }
221
- _createClass(Logger, [{
222
- key: "init",
223
- value: function init(concreteLogger) {
224
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
225
- this.prefix = options.prefix || 'i18next:';
226
- this.logger = concreteLogger || consoleLogger;
227
- this.options = options;
228
- this.debug = options.debug;
229
- }
230
- }, {
231
- key: "setDebug",
232
- value: function setDebug(bool) {
233
- this.debug = bool;
234
- }
235
- }, {
236
- key: "log",
237
- value: function log() {
238
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
239
- args[_key] = arguments[_key];
240
- }
241
- return this.forward(args, 'log', '', true);
242
- }
243
- }, {
244
- key: "warn",
245
- value: function warn() {
246
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
247
- args[_key2] = arguments[_key2];
248
- }
249
- return this.forward(args, 'warn', '', true);
250
- }
251
- }, {
252
- key: "error",
253
- value: function error() {
254
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
255
- args[_key3] = arguments[_key3];
256
- }
257
- return this.forward(args, 'error', '');
258
- }
259
- }, {
260
- key: "deprecate",
261
- value: function deprecate() {
262
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
263
- args[_key4] = arguments[_key4];
264
- }
265
- return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
266
- }
267
- }, {
268
- key: "forward",
269
- value: function forward(args, lvl, prefix, debugOnly) {
270
- if (debugOnly && !this.debug) return null;
271
- if (typeof args[0] === 'string') args[0] = "".concat(prefix).concat(this.prefix, " ").concat(args[0]);
272
- return this.logger[lvl](args);
273
- }
274
- }, {
275
- key: "create",
276
- value: function create(moduleName) {
277
- return new Logger(this.logger, _objectSpread$6$1(_objectSpread$6$1({}, {
278
- prefix: "".concat(this.prefix, ":").concat(moduleName, ":")
279
- }), this.options));
280
- }
281
- }, {
282
- key: "clone",
283
- value: function clone(options) {
284
- options = options || this.options;
285
- options.prefix = options.prefix || this.prefix;
286
- return new Logger(this.logger, options);
287
- }
288
- }]);
289
- return Logger;
290
- }();
291
- var baseLogger = new Logger();
292
-
293
- var EventEmitter = function () {
294
- function EventEmitter() {
295
- _classCallCheck(this, EventEmitter);
296
- this.observers = {};
297
- }
298
- _createClass(EventEmitter, [{
299
- key: "on",
300
- value: function on(events, listener) {
301
- var _this = this;
302
- events.split(' ').forEach(function (event) {
303
- _this.observers[event] = _this.observers[event] || [];
304
- _this.observers[event].push(listener);
305
- });
306
- return this;
307
- }
308
- }, {
309
- key: "off",
310
- value: function off(event, listener) {
311
- if (!this.observers[event]) return;
312
- if (!listener) {
313
- delete this.observers[event];
314
- return;
315
- }
316
- this.observers[event] = this.observers[event].filter(function (l) {
317
- return l !== listener;
318
- });
319
- }
320
- }, {
321
- key: "emit",
322
- value: function emit(event) {
323
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
324
- args[_key - 1] = arguments[_key];
325
- }
326
- if (this.observers[event]) {
327
- var cloned = [].concat(this.observers[event]);
328
- cloned.forEach(function (observer) {
329
- observer.apply(void 0, args);
330
- });
331
- }
332
- if (this.observers['*']) {
333
- var _cloned = [].concat(this.observers['*']);
334
- _cloned.forEach(function (observer) {
335
- observer.apply(observer, [event].concat(args));
336
- });
337
- }
338
- }
339
- }]);
340
- return EventEmitter;
341
- }();
342
-
343
- function defer() {
344
- var res;
345
- var rej;
346
- var promise = new Promise(function (resolve, reject) {
347
- res = resolve;
348
- rej = reject;
349
- });
350
- promise.resolve = res;
351
- promise.reject = rej;
352
- return promise;
353
- }
354
- function makeString(object) {
355
- if (object == null) return '';
356
- return '' + object;
357
- }
358
- function copy(a, s, t) {
359
- a.forEach(function (m) {
360
- if (s[m]) t[m] = s[m];
361
- });
362
- }
363
- function getLastOfPath(object, path, Empty) {
364
- function cleanKey(key) {
365
- return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
366
- }
367
- function canNotTraverseDeeper() {
368
- return !object || typeof object === 'string';
369
- }
370
- var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
371
- while (stack.length > 1) {
372
- if (canNotTraverseDeeper()) return {};
373
- var key = cleanKey(stack.shift());
374
- if (!object[key] && Empty) object[key] = new Empty();
375
- if (Object.prototype.hasOwnProperty.call(object, key)) {
376
- object = object[key];
377
- } else {
378
- object = {};
379
- }
380
- }
381
- if (canNotTraverseDeeper()) return {};
382
- return {
383
- obj: object,
384
- k: cleanKey(stack.shift())
385
- };
386
- }
387
- function setPath(object, path, newValue) {
388
- var _getLastOfPath = getLastOfPath(object, path, Object),
389
- obj = _getLastOfPath.obj,
390
- k = _getLastOfPath.k;
391
- obj[k] = newValue;
392
- }
393
- function pushPath(object, path, newValue, concat) {
394
- var _getLastOfPath2 = getLastOfPath(object, path, Object),
395
- obj = _getLastOfPath2.obj,
396
- k = _getLastOfPath2.k;
397
- obj[k] = obj[k] || [];
398
- if (concat) obj[k] = obj[k].concat(newValue);
399
- if (!concat) obj[k].push(newValue);
400
- }
401
- function getPath(object, path) {
402
- var _getLastOfPath3 = getLastOfPath(object, path),
403
- obj = _getLastOfPath3.obj,
404
- k = _getLastOfPath3.k;
405
- if (!obj) return undefined;
406
- return obj[k];
407
- }
408
- function getPathWithDefaults(data, defaultData, key) {
409
- var value = getPath(data, key);
410
- if (value !== undefined) {
411
- return value;
412
- }
413
- return getPath(defaultData, key);
414
- }
415
- function deepExtend(target, source, overwrite) {
416
- for (var prop in source) {
417
- if (prop !== '__proto__' && prop !== 'constructor') {
418
- if (prop in target) {
419
- if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
420
- if (overwrite) target[prop] = source[prop];
421
- } else {
422
- deepExtend(target[prop], source[prop], overwrite);
423
- }
424
- } else {
425
- target[prop] = source[prop];
426
- }
427
- }
428
- }
429
- return target;
430
- }
431
- function regexEscape(str) {
432
- return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
433
- }
434
- var _entityMap = {
435
- '&': '&amp;',
436
- '<': '&lt;',
437
- '>': '&gt;',
438
- '"': '&quot;',
439
- "'": '&#39;',
440
- '/': '&#x2F;'
441
- };
442
- function escape(data) {
443
- if (typeof data === 'string') {
444
- return data.replace(/[&<>"'\/]/g, function (s) {
445
- return _entityMap[s];
446
- });
447
- }
448
- return data;
449
- }
450
- var isIE10 = typeof window !== 'undefined' && window.navigator && typeof window.navigator.userAgentData === 'undefined' && window.navigator.userAgent && window.navigator.userAgent.indexOf('MSIE') > -1;
451
- var chars = [' ', ',', '?', '!', ';'];
452
- function looksLikeObjectPath(key, nsSeparator, keySeparator) {
453
- nsSeparator = nsSeparator || '';
454
- keySeparator = keySeparator || '';
455
- var possibleChars = chars.filter(function (c) {
456
- return nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0;
457
- });
458
- if (possibleChars.length === 0) return true;
459
- var r = new RegExp("(".concat(possibleChars.map(function (c) {
460
- return c === '?' ? '\\?' : c;
461
- }).join('|'), ")"));
462
- var matched = !r.test(key);
463
- if (!matched) {
464
- var ki = key.indexOf(keySeparator);
465
- if (ki > 0 && !r.test(key.substring(0, ki))) {
466
- matched = true;
467
- }
468
- }
469
- return matched;
470
- }
471
-
472
- function ownKeys$5$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; }
473
- function _objectSpread$5$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
474
- 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); }; }
475
- 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; } }
476
- function deepFind(obj, path) {
477
- var keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
478
- if (!obj) return undefined;
479
- if (obj[path]) return obj[path];
480
- var paths = path.split(keySeparator);
481
- var current = obj;
482
- for (var i = 0; i < paths.length; ++i) {
483
- if (!current) return undefined;
484
- if (typeof current[paths[i]] === 'string' && i + 1 < paths.length) {
485
- return undefined;
486
- }
487
- if (current[paths[i]] === undefined) {
488
- var j = 2;
489
- var p = paths.slice(i, i + j).join(keySeparator);
490
- var mix = current[p];
491
- while (mix === undefined && paths.length > i + j) {
492
- j++;
493
- p = paths.slice(i, i + j).join(keySeparator);
494
- mix = current[p];
495
- }
496
- if (mix === undefined) return undefined;
497
- if (mix === null) return null;
498
- if (path.endsWith(p)) {
499
- if (typeof mix === 'string') return mix;
500
- if (p && typeof mix[p] === 'string') return mix[p];
501
- }
502
- var joinedPath = paths.slice(i + j).join(keySeparator);
503
- if (joinedPath) return deepFind(mix, joinedPath, keySeparator);
504
- return undefined;
505
- }
506
- current = current[paths[i]];
507
- }
508
- return current;
509
- }
510
- var ResourceStore = function (_EventEmitter) {
511
- _inherits(ResourceStore, _EventEmitter);
512
- var _super = _createSuper$3(ResourceStore);
513
- function ResourceStore(data) {
514
- var _this;
515
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
516
- ns: ['translation'],
517
- defaultNS: 'translation'
518
- };
519
- _classCallCheck(this, ResourceStore);
520
- _this = _super.call(this);
521
- if (isIE10) {
522
- EventEmitter.call(_assertThisInitialized(_this));
523
- }
524
- _this.data = data || {};
525
- _this.options = options;
526
- if (_this.options.keySeparator === undefined) {
527
- _this.options.keySeparator = '.';
528
- }
529
- if (_this.options.ignoreJSONStructure === undefined) {
530
- _this.options.ignoreJSONStructure = true;
531
- }
532
- return _this;
533
- }
534
- _createClass(ResourceStore, [{
535
- key: "addNamespaces",
536
- value: function addNamespaces(ns) {
537
- if (this.options.ns.indexOf(ns) < 0) {
538
- this.options.ns.push(ns);
539
- }
540
- }
541
- }, {
542
- key: "removeNamespaces",
543
- value: function removeNamespaces(ns) {
544
- var index = this.options.ns.indexOf(ns);
545
- if (index > -1) {
546
- this.options.ns.splice(index, 1);
547
- }
548
- }
549
- }, {
550
- key: "getResource",
551
- value: function getResource(lng, ns, key) {
552
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
553
- var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
554
- var ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
555
- var path = [lng, ns];
556
- if (key && typeof key !== 'string') path = path.concat(key);
557
- if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
558
- if (lng.indexOf('.') > -1) {
559
- path = lng.split('.');
560
- }
561
- var result = getPath(this.data, path);
562
- if (result || !ignoreJSONStructure || typeof key !== 'string') return result;
563
- return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
564
- }
565
- }, {
566
- key: "addResource",
567
- value: function addResource(lng, ns, key, value) {
568
- var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
569
- silent: false
570
- };
571
- var keySeparator = this.options.keySeparator;
572
- if (keySeparator === undefined) keySeparator = '.';
573
- var path = [lng, ns];
574
- if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
575
- if (lng.indexOf('.') > -1) {
576
- path = lng.split('.');
577
- value = ns;
578
- ns = path[1];
579
- }
580
- this.addNamespaces(ns);
581
- setPath(this.data, path, value);
582
- if (!options.silent) this.emit('added', lng, ns, key, value);
583
- }
584
- }, {
585
- key: "addResources",
586
- value: function addResources(lng, ns, resources) {
587
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
588
- silent: false
589
- };
590
- for (var m in resources) {
591
- if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
592
- silent: true
593
- });
594
- }
595
- if (!options.silent) this.emit('added', lng, ns, resources);
596
- }
597
- }, {
598
- key: "addResourceBundle",
599
- value: function addResourceBundle(lng, ns, resources, deep, overwrite) {
600
- var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
601
- silent: false
602
- };
603
- var path = [lng, ns];
604
- if (lng.indexOf('.') > -1) {
605
- path = lng.split('.');
606
- deep = resources;
607
- resources = ns;
608
- ns = path[1];
609
- }
610
- this.addNamespaces(ns);
611
- var pack = getPath(this.data, path) || {};
612
- if (deep) {
613
- deepExtend(pack, resources, overwrite);
614
- } else {
615
- pack = _objectSpread$5$1(_objectSpread$5$1({}, pack), resources);
616
- }
617
- setPath(this.data, path, pack);
618
- if (!options.silent) this.emit('added', lng, ns, resources);
619
- }
620
- }, {
621
- key: "removeResourceBundle",
622
- value: function removeResourceBundle(lng, ns) {
623
- if (this.hasResourceBundle(lng, ns)) {
624
- delete this.data[lng][ns];
625
- }
626
- this.removeNamespaces(ns);
627
- this.emit('removed', lng, ns);
628
- }
629
- }, {
630
- key: "hasResourceBundle",
631
- value: function hasResourceBundle(lng, ns) {
632
- return this.getResource(lng, ns) !== undefined;
633
- }
634
- }, {
635
- key: "getResourceBundle",
636
- value: function getResourceBundle(lng, ns) {
637
- if (!ns) ns = this.options.defaultNS;
638
- if (this.options.compatibilityAPI === 'v1') return _objectSpread$5$1(_objectSpread$5$1({}, {}), this.getResource(lng, ns));
639
- return this.getResource(lng, ns);
640
- }
641
- }, {
642
- key: "getDataByLanguage",
643
- value: function getDataByLanguage(lng) {
644
- return this.data[lng];
645
- }
646
- }, {
647
- key: "hasLanguageSomeTranslations",
648
- value: function hasLanguageSomeTranslations(lng) {
649
- var data = this.getDataByLanguage(lng);
650
- var n = data && Object.keys(data) || [];
651
- return !!n.find(function (v) {
652
- return data[v] && Object.keys(data[v]).length > 0;
653
- });
654
- }
655
- }, {
656
- key: "toJSON",
657
- value: function toJSON() {
658
- return this.data;
659
- }
660
- }]);
661
- return ResourceStore;
662
- }(EventEmitter);
663
-
664
- var postProcessor = {
665
- processors: {},
666
- addPostProcessor: function addPostProcessor(module) {
667
- this.processors[module.name] = module;
668
- },
669
- handle: function handle(processors, value, key, options, translator) {
670
- var _this = this;
671
- processors.forEach(function (processor) {
672
- if (_this.processors[processor]) value = _this.processors[processor].process(value, key, options, translator);
673
- });
674
- return value;
675
- }
676
- };
677
-
678
- function ownKeys$4$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; }
679
- function _objectSpread$4$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
680
- 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); }; }
681
- 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; } }
682
- var checkedLoadedFor = {};
683
- var Translator = function (_EventEmitter) {
684
- _inherits(Translator, _EventEmitter);
685
- var _super = _createSuper$2(Translator);
686
- function Translator(services) {
687
- var _this;
688
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
689
- _classCallCheck(this, Translator);
690
- _this = _super.call(this);
691
- if (isIE10) {
692
- EventEmitter.call(_assertThisInitialized(_this));
693
- }
694
- copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, _assertThisInitialized(_this));
695
- _this.options = options;
696
- if (_this.options.keySeparator === undefined) {
697
- _this.options.keySeparator = '.';
698
- }
699
- _this.logger = baseLogger.create('translator');
700
- return _this;
701
- }
702
- _createClass(Translator, [{
703
- key: "changeLanguage",
704
- value: function changeLanguage(lng) {
705
- if (lng) this.language = lng;
706
- }
707
- }, {
708
- key: "exists",
709
- value: function exists(key) {
710
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
711
- interpolation: {}
712
- };
713
- if (key === undefined || key === null) {
714
- return false;
715
- }
716
- var resolved = this.resolve(key, options);
717
- return resolved && resolved.res !== undefined;
718
- }
719
- }, {
720
- key: "extractFromKey",
721
- value: function extractFromKey(key, options) {
722
- var nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
723
- if (nsSeparator === undefined) nsSeparator = ':';
724
- var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
725
- var namespaces = options.ns || this.options.defaultNS || [];
726
- var wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
727
- var seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
728
- if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
729
- var m = key.match(this.interpolator.nestingRegexp);
730
- if (m && m.length > 0) {
731
- return {
732
- key: key,
733
- namespaces: namespaces
734
- };
735
- }
736
- var parts = key.split(nsSeparator);
737
- if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
738
- key = parts.join(keySeparator);
739
- }
740
- if (typeof namespaces === 'string') namespaces = [namespaces];
741
- return {
742
- key: key,
743
- namespaces: namespaces
744
- };
745
- }
746
- }, {
747
- key: "translate",
748
- value: function translate(keys, options, lastKey) {
749
- var _this2 = this;
750
- if (_typeof$1(options) !== 'object' && this.options.overloadTranslationOptionHandler) {
751
- options = this.options.overloadTranslationOptionHandler(arguments);
752
- }
753
- if (!options) options = {};
754
- if (keys === undefined || keys === null) return '';
755
- if (!Array.isArray(keys)) keys = [String(keys)];
756
- var returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
757
- var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
758
- var _this$extractFromKey = this.extractFromKey(keys[keys.length - 1], options),
759
- key = _this$extractFromKey.key,
760
- namespaces = _this$extractFromKey.namespaces;
761
- var namespace = namespaces[namespaces.length - 1];
762
- var lng = options.lng || this.language;
763
- var appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
764
- if (lng && lng.toLowerCase() === 'cimode') {
765
- if (appendNamespaceToCIMode) {
766
- var nsSeparator = options.nsSeparator || this.options.nsSeparator;
767
- if (returnDetails) {
768
- return {
769
- res: "".concat(namespace).concat(nsSeparator).concat(key),
770
- usedKey: key,
771
- exactUsedKey: key,
772
- usedLng: lng,
773
- usedNS: namespace
774
- };
775
- }
776
- return "".concat(namespace).concat(nsSeparator).concat(key);
777
- }
778
- if (returnDetails) {
779
- return {
780
- res: key,
781
- usedKey: key,
782
- exactUsedKey: key,
783
- usedLng: lng,
784
- usedNS: namespace
785
- };
786
- }
787
- return key;
788
- }
789
- var resolved = this.resolve(keys, options);
790
- var res = resolved && resolved.res;
791
- var resUsedKey = resolved && resolved.usedKey || key;
792
- var resExactUsedKey = resolved && resolved.exactUsedKey || key;
793
- var resType = Object.prototype.toString.apply(res);
794
- var noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
795
- var joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
796
- var handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
797
- var handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
798
- if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
799
- if (!options.returnObjects && !this.options.returnObjects) {
800
- if (!this.options.returnedObjectHandler) {
801
- this.logger.warn('accessing an object - but returnObjects options is not enabled!');
802
- }
803
- var r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread$4$1(_objectSpread$4$1({}, options), {}, {
804
- ns: namespaces
805
- })) : "key '".concat(key, " (").concat(this.language, ")' returned an object instead of string.");
806
- if (returnDetails) {
807
- resolved.res = r;
808
- return resolved;
809
- }
810
- return r;
811
- }
812
- if (keySeparator) {
813
- var resTypeIsArray = resType === '[object Array]';
814
- var copy = resTypeIsArray ? [] : {};
815
- var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
816
- for (var m in res) {
817
- if (Object.prototype.hasOwnProperty.call(res, m)) {
818
- var deepKey = "".concat(newKeyToUse).concat(keySeparator).concat(m);
819
- copy[m] = this.translate(deepKey, _objectSpread$4$1(_objectSpread$4$1({}, options), {
820
- joinArrays: false,
821
- ns: namespaces
822
- }));
823
- if (copy[m] === deepKey) copy[m] = res[m];
824
- }
825
- }
826
- res = copy;
827
- }
828
- } else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
829
- res = res.join(joinArrays);
830
- if (res) res = this.extendTranslation(res, keys, options, lastKey);
831
- } else {
832
- var usedDefault = false;
833
- var usedKey = false;
834
- var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
835
- var hasDefaultValue = Translator.hasDefaultValue(options);
836
- var defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
837
- var defaultValue = options["defaultValue".concat(defaultValueSuffix)] || options.defaultValue;
838
- if (!this.isValidLookup(res) && hasDefaultValue) {
839
- usedDefault = true;
840
- res = defaultValue;
841
- }
842
- if (!this.isValidLookup(res)) {
843
- usedKey = true;
844
- res = key;
845
- }
846
- var missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
847
- var resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
848
- var updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
849
- if (usedKey || usedDefault || updateMissing) {
850
- this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
851
- if (keySeparator) {
852
- var fk = this.resolve(key, _objectSpread$4$1(_objectSpread$4$1({}, options), {}, {
853
- keySeparator: false
854
- }));
855
- 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.');
856
- }
857
- var lngs = [];
858
- var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
859
- if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
860
- for (var i = 0; i < fallbackLngs.length; i++) {
861
- lngs.push(fallbackLngs[i]);
862
- }
863
- } else if (this.options.saveMissingTo === 'all') {
864
- lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
865
- } else {
866
- lngs.push(options.lng || this.language);
867
- }
868
- var send = function send(l, k, specificDefaultValue) {
869
- var defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
870
- if (_this2.options.missingKeyHandler) {
871
- _this2.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
872
- } else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {
873
- _this2.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
874
- }
875
- _this2.emit('missingKey', l, namespace, k, res);
876
- };
877
- if (this.options.saveMissing) {
878
- if (this.options.saveMissingPlurals && needsPluralHandling) {
879
- lngs.forEach(function (language) {
880
- _this2.pluralResolver.getSuffixes(language, options).forEach(function (suffix) {
881
- send([language], key + suffix, options["defaultValue".concat(suffix)] || defaultValue);
882
- });
883
- });
884
- } else {
885
- send(lngs, key, defaultValue);
886
- }
887
- }
888
- }
889
- res = this.extendTranslation(res, keys, options, resolved, lastKey);
890
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = "".concat(namespace, ":").concat(key);
891
- if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
892
- if (this.options.compatibilityAPI !== 'v1') {
893
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? "".concat(namespace, ":").concat(key) : key, usedDefault ? res : undefined);
894
- } else {
895
- res = this.options.parseMissingKeyHandler(res);
896
- }
897
- }
898
- }
899
- if (returnDetails) {
900
- resolved.res = res;
901
- return resolved;
902
- }
903
- return res;
904
- }
905
- }, {
906
- key: "extendTranslation",
907
- value: function extendTranslation(res, key, options, resolved, lastKey) {
908
- var _this3 = this;
909
- if (this.i18nFormat && this.i18nFormat.parse) {
910
- res = this.i18nFormat.parse(res, _objectSpread$4$1(_objectSpread$4$1({}, this.options.interpolation.defaultVariables), options), resolved.usedLng, resolved.usedNS, resolved.usedKey, {
911
- resolved: resolved
912
- });
913
- } else if (!options.skipInterpolation) {
914
- if (options.interpolation) this.interpolator.init(_objectSpread$4$1(_objectSpread$4$1({}, options), {
915
- interpolation: _objectSpread$4$1(_objectSpread$4$1({}, this.options.interpolation), options.interpolation)
916
- }));
917
- var skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
918
- var nestBef;
919
- if (skipOnVariables) {
920
- var nb = res.match(this.interpolator.nestingRegexp);
921
- nestBef = nb && nb.length;
922
- }
923
- var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
924
- if (this.options.interpolation.defaultVariables) data = _objectSpread$4$1(_objectSpread$4$1({}, this.options.interpolation.defaultVariables), data);
925
- res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
926
- if (skipOnVariables) {
927
- var na = res.match(this.interpolator.nestingRegexp);
928
- var nestAft = na && na.length;
929
- if (nestBef < nestAft) options.nest = false;
930
- }
931
- if (options.nest !== false) res = this.interpolator.nest(res, function () {
932
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
933
- args[_key] = arguments[_key];
934
- }
935
- if (lastKey && lastKey[0] === args[0] && !options.context) {
936
- _this3.logger.warn("It seems you are nesting recursively key: ".concat(args[0], " in key: ").concat(key[0]));
937
- return null;
938
- }
939
- return _this3.translate.apply(_this3, args.concat([key]));
940
- }, options);
941
- if (options.interpolation) this.interpolator.reset();
942
- }
943
- var postProcess = options.postProcess || this.options.postProcess;
944
- var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
945
- if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
946
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread$4$1({
947
- i18nResolved: resolved
948
- }, options) : options, this);
949
- }
950
- return res;
951
- }
952
- }, {
953
- key: "resolve",
954
- value: function resolve(keys) {
955
- var _this4 = this;
956
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
957
- var found;
958
- var usedKey;
959
- var exactUsedKey;
960
- var usedLng;
961
- var usedNS;
962
- if (typeof keys === 'string') keys = [keys];
963
- keys.forEach(function (k) {
964
- if (_this4.isValidLookup(found)) return;
965
- var extracted = _this4.extractFromKey(k, options);
966
- var key = extracted.key;
967
- usedKey = key;
968
- var namespaces = extracted.namespaces;
969
- if (_this4.options.fallbackNS) namespaces = namespaces.concat(_this4.options.fallbackNS);
970
- var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
971
- var needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && _this4.pluralResolver.shouldUseIntlApi();
972
- var needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';
973
- var codes = options.lngs ? options.lngs : _this4.languageUtils.toResolveHierarchy(options.lng || _this4.language, options.fallbackLng);
974
- namespaces.forEach(function (ns) {
975
- if (_this4.isValidLookup(found)) return;
976
- usedNS = ns;
977
- if (!checkedLoadedFor["".concat(codes[0], "-").concat(ns)] && _this4.utils && _this4.utils.hasLoadedNamespace && !_this4.utils.hasLoadedNamespace(usedNS)) {
978
- checkedLoadedFor["".concat(codes[0], "-").concat(ns)] = true;
979
- _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!!!');
980
- }
981
- codes.forEach(function (code) {
982
- if (_this4.isValidLookup(found)) return;
983
- usedLng = code;
984
- var finalKeys = [key];
985
- if (_this4.i18nFormat && _this4.i18nFormat.addLookupKeys) {
986
- _this4.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
987
- } else {
988
- var pluralSuffix;
989
- if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count, options);
990
- var zeroSuffix = "".concat(_this4.options.pluralSeparator, "zero");
991
- if (needsPluralHandling) {
992
- finalKeys.push(key + pluralSuffix);
993
- if (needsZeroSuffixLookup) {
994
- finalKeys.push(key + zeroSuffix);
995
- }
996
- }
997
- if (needsContextHandling) {
998
- var contextKey = "".concat(key).concat(_this4.options.contextSeparator).concat(options.context);
999
- finalKeys.push(contextKey);
1000
- if (needsPluralHandling) {
1001
- finalKeys.push(contextKey + pluralSuffix);
1002
- if (needsZeroSuffixLookup) {
1003
- finalKeys.push(contextKey + zeroSuffix);
1004
- }
1005
- }
1006
- }
1007
- }
1008
- var possibleKey;
1009
- while (possibleKey = finalKeys.pop()) {
1010
- if (!_this4.isValidLookup(found)) {
1011
- exactUsedKey = possibleKey;
1012
- found = _this4.getResource(code, ns, possibleKey, options);
1013
- }
1014
- }
1015
- });
1016
- });
1017
- });
1018
- return {
1019
- res: found,
1020
- usedKey: usedKey,
1021
- exactUsedKey: exactUsedKey,
1022
- usedLng: usedLng,
1023
- usedNS: usedNS
1024
- };
1025
- }
1026
- }, {
1027
- key: "isValidLookup",
1028
- value: function isValidLookup(res) {
1029
- return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
1030
- }
1031
- }, {
1032
- key: "getResource",
1033
- value: function getResource(code, ns, key) {
1034
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1035
- if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
1036
- return this.resourceStore.getResource(code, ns, key, options);
1037
- }
1038
- }], [{
1039
- key: "hasDefaultValue",
1040
- value: function hasDefaultValue(options) {
1041
- var prefix = 'defaultValue';
1042
- for (var option in options) {
1043
- if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
1044
- return true;
1045
- }
1046
- }
1047
- return false;
1048
- }
1049
- }]);
1050
- return Translator;
1051
- }(EventEmitter);
1052
-
1053
- function capitalize(string) {
1054
- return string.charAt(0).toUpperCase() + string.slice(1);
1055
- }
1056
- var LanguageUtil = function () {
1057
- function LanguageUtil(options) {
1058
- _classCallCheck(this, LanguageUtil);
1059
- this.options = options;
1060
- this.supportedLngs = this.options.supportedLngs || false;
1061
- this.logger = baseLogger.create('languageUtils');
1062
- }
1063
- _createClass(LanguageUtil, [{
1064
- key: "getScriptPartFromCode",
1065
- value: function getScriptPartFromCode(code) {
1066
- if (!code || code.indexOf('-') < 0) return null;
1067
- var p = code.split('-');
1068
- if (p.length === 2) return null;
1069
- p.pop();
1070
- if (p[p.length - 1].toLowerCase() === 'x') return null;
1071
- return this.formatLanguageCode(p.join('-'));
1072
- }
1073
- }, {
1074
- key: "getLanguagePartFromCode",
1075
- value: function getLanguagePartFromCode(code) {
1076
- if (!code || code.indexOf('-') < 0) return code;
1077
- var p = code.split('-');
1078
- return this.formatLanguageCode(p[0]);
1079
- }
1080
- }, {
1081
- key: "formatLanguageCode",
1082
- value: function formatLanguageCode(code) {
1083
- if (typeof code === 'string' && code.indexOf('-') > -1) {
1084
- var specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
1085
- var p = code.split('-');
1086
- if (this.options.lowerCaseLng) {
1087
- p = p.map(function (part) {
1088
- return part.toLowerCase();
1089
- });
1090
- } else if (p.length === 2) {
1091
- p[0] = p[0].toLowerCase();
1092
- p[1] = p[1].toUpperCase();
1093
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
1094
- } else if (p.length === 3) {
1095
- p[0] = p[0].toLowerCase();
1096
- if (p[1].length === 2) p[1] = p[1].toUpperCase();
1097
- if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
1098
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
1099
- if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
1100
- }
1101
- return p.join('-');
1102
- }
1103
- return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
1104
- }
1105
- }, {
1106
- key: "isSupportedCode",
1107
- value: function isSupportedCode(code) {
1108
- if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
1109
- code = this.getLanguagePartFromCode(code);
1110
- }
1111
- return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
1112
- }
1113
- }, {
1114
- key: "getBestMatchFromCodes",
1115
- value: function getBestMatchFromCodes(codes) {
1116
- var _this = this;
1117
- if (!codes) return null;
1118
- var found;
1119
- codes.forEach(function (code) {
1120
- if (found) return;
1121
- var cleanedLng = _this.formatLanguageCode(code);
1122
- if (!_this.options.supportedLngs || _this.isSupportedCode(cleanedLng)) found = cleanedLng;
1123
- });
1124
- if (!found && this.options.supportedLngs) {
1125
- codes.forEach(function (code) {
1126
- if (found) return;
1127
- var lngOnly = _this.getLanguagePartFromCode(code);
1128
- if (_this.isSupportedCode(lngOnly)) return found = lngOnly;
1129
- found = _this.options.supportedLngs.find(function (supportedLng) {
1130
- if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;
1131
- });
1132
- });
1133
- }
1134
- if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
1135
- return found;
1136
- }
1137
- }, {
1138
- key: "getFallbackCodes",
1139
- value: function getFallbackCodes(fallbacks, code) {
1140
- if (!fallbacks) return [];
1141
- if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
1142
- if (typeof fallbacks === 'string') fallbacks = [fallbacks];
1143
- if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;
1144
- if (!code) return fallbacks["default"] || [];
1145
- var found = fallbacks[code];
1146
- if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
1147
- if (!found) found = fallbacks[this.formatLanguageCode(code)];
1148
- if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
1149
- if (!found) found = fallbacks["default"];
1150
- return found || [];
1151
- }
1152
- }, {
1153
- key: "toResolveHierarchy",
1154
- value: function toResolveHierarchy(code, fallbackCode) {
1155
- var _this2 = this;
1156
- var fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
1157
- var codes = [];
1158
- var addCode = function addCode(c) {
1159
- if (!c) return;
1160
- if (_this2.isSupportedCode(c)) {
1161
- codes.push(c);
1162
- } else {
1163
- _this2.logger.warn("rejecting language code not found in supportedLngs: ".concat(c));
1164
- }
1165
- };
1166
- if (typeof code === 'string' && code.indexOf('-') > -1) {
1167
- if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
1168
- if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
1169
- if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
1170
- } else if (typeof code === 'string') {
1171
- addCode(this.formatLanguageCode(code));
1172
- }
1173
- fallbackCodes.forEach(function (fc) {
1174
- if (codes.indexOf(fc) < 0) addCode(_this2.formatLanguageCode(fc));
1175
- });
1176
- return codes;
1177
- }
1178
- }]);
1179
- return LanguageUtil;
1180
- }();
1181
-
1182
- var sets = [{
1183
- lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
1184
- nr: [1, 2],
1185
- fc: 1
1186
- }, {
1187
- lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'hi', 'hu', 'hy', 'ia', 'it', 'kk', 'kn', 'ku', 'lb', 'mai', 'ml', 'mn', 'mr', 'nah', 'nap', 'nb', 'ne', 'nl', 'nn', 'no', 'nso', 'pa', 'pap', 'pms', 'ps', 'pt-PT', 'rm', 'sco', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw', 'ta', 'te', 'tk', 'ur', 'yo'],
1188
- nr: [1, 2],
1189
- fc: 2
1190
- }, {
1191
- lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
1192
- nr: [1],
1193
- fc: 3
1194
- }, {
1195
- lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
1196
- nr: [1, 2, 5],
1197
- fc: 4
1198
- }, {
1199
- lngs: ['ar'],
1200
- nr: [0, 1, 2, 3, 11, 100],
1201
- fc: 5
1202
- }, {
1203
- lngs: ['cs', 'sk'],
1204
- nr: [1, 2, 5],
1205
- fc: 6
1206
- }, {
1207
- lngs: ['csb', 'pl'],
1208
- nr: [1, 2, 5],
1209
- fc: 7
1210
- }, {
1211
- lngs: ['cy'],
1212
- nr: [1, 2, 3, 8],
1213
- fc: 8
1214
- }, {
1215
- lngs: ['fr'],
1216
- nr: [1, 2],
1217
- fc: 9
1218
- }, {
1219
- lngs: ['ga'],
1220
- nr: [1, 2, 3, 7, 11],
1221
- fc: 10
1222
- }, {
1223
- lngs: ['gd'],
1224
- nr: [1, 2, 3, 20],
1225
- fc: 11
1226
- }, {
1227
- lngs: ['is'],
1228
- nr: [1, 2],
1229
- fc: 12
1230
- }, {
1231
- lngs: ['jv'],
1232
- nr: [0, 1],
1233
- fc: 13
1234
- }, {
1235
- lngs: ['kw'],
1236
- nr: [1, 2, 3, 4],
1237
- fc: 14
1238
- }, {
1239
- lngs: ['lt'],
1240
- nr: [1, 2, 10],
1241
- fc: 15
1242
- }, {
1243
- lngs: ['lv'],
1244
- nr: [1, 2, 0],
1245
- fc: 16
1246
- }, {
1247
- lngs: ['mk'],
1248
- nr: [1, 2],
1249
- fc: 17
1250
- }, {
1251
- lngs: ['mnk'],
1252
- nr: [0, 1, 2],
1253
- fc: 18
1254
- }, {
1255
- lngs: ['mt'],
1256
- nr: [1, 2, 11, 20],
1257
- fc: 19
1258
- }, {
1259
- lngs: ['or'],
1260
- nr: [2, 1],
1261
- fc: 2
1262
- }, {
1263
- lngs: ['ro'],
1264
- nr: [1, 2, 20],
1265
- fc: 20
1266
- }, {
1267
- lngs: ['sl'],
1268
- nr: [5, 1, 2, 3],
1269
- fc: 21
1270
- }, {
1271
- lngs: ['he', 'iw'],
1272
- nr: [1, 2, 20, 21],
1273
- fc: 22
1274
- }];
1275
- var _rulesPluralsTypes = {
1276
- 1: function _(n) {
1277
- return Number(n > 1);
1278
- },
1279
- 2: function _(n) {
1280
- return Number(n != 1);
1281
- },
1282
- 3: function _(n) {
1283
- return 0;
1284
- },
1285
- 4: function _(n) {
1286
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1287
- },
1288
- 5: function _(n) {
1289
- return Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
1290
- },
1291
- 6: function _(n) {
1292
- return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
1293
- },
1294
- 7: function _(n) {
1295
- return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1296
- },
1297
- 8: function _(n) {
1298
- return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
1299
- },
1300
- 9: function _(n) {
1301
- return Number(n >= 2);
1302
- },
1303
- 10: function _(n) {
1304
- return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
1305
- },
1306
- 11: function _(n) {
1307
- return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
1308
- },
1309
- 12: function _(n) {
1310
- return Number(n % 10 != 1 || n % 100 == 11);
1311
- },
1312
- 13: function _(n) {
1313
- return Number(n !== 0);
1314
- },
1315
- 14: function _(n) {
1316
- return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
1317
- },
1318
- 15: function _(n) {
1319
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1320
- },
1321
- 16: function _(n) {
1322
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
1323
- },
1324
- 17: function _(n) {
1325
- return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);
1326
- },
1327
- 18: function _(n) {
1328
- return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
1329
- },
1330
- 19: function _(n) {
1331
- return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
1332
- },
1333
- 20: function _(n) {
1334
- return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
1335
- },
1336
- 21: function _(n) {
1337
- return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
1338
- },
1339
- 22: function _(n) {
1340
- return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
1341
- }
1342
- };
1343
- var deprecatedJsonVersions = ['v1', 'v2', 'v3'];
1344
- var suffixesOrder = {
1345
- zero: 0,
1346
- one: 1,
1347
- two: 2,
1348
- few: 3,
1349
- many: 4,
1350
- other: 5
1351
- };
1352
- function createRules() {
1353
- var rules = {};
1354
- sets.forEach(function (set) {
1355
- set.lngs.forEach(function (l) {
1356
- rules[l] = {
1357
- numbers: set.nr,
1358
- plurals: _rulesPluralsTypes[set.fc]
1359
- };
1360
- });
1361
- });
1362
- return rules;
1363
- }
1364
- var PluralResolver = function () {
1365
- function PluralResolver(languageUtils) {
1366
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1367
- _classCallCheck(this, PluralResolver);
1368
- this.languageUtils = languageUtils;
1369
- this.options = options;
1370
- this.logger = baseLogger.create('pluralResolver');
1371
- if ((!this.options.compatibilityJSON || this.options.compatibilityJSON === 'v4') && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
1372
- this.options.compatibilityJSON = 'v3';
1373
- 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.');
1374
- }
1375
- this.rules = createRules();
1376
- }
1377
- _createClass(PluralResolver, [{
1378
- key: "addRule",
1379
- value: function addRule(lng, obj) {
1380
- this.rules[lng] = obj;
1381
- }
1382
- }, {
1383
- key: "getRule",
1384
- value: function getRule(code) {
1385
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1386
- if (this.shouldUseIntlApi()) {
1387
- try {
1388
- return new Intl.PluralRules(code, {
1389
- type: options.ordinal ? 'ordinal' : 'cardinal'
1390
- });
1391
- } catch (_unused) {
1392
- return;
1393
- }
1394
- }
1395
- return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
1396
- }
1397
- }, {
1398
- key: "needsPlural",
1399
- value: function needsPlural(code) {
1400
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1401
- var rule = this.getRule(code, options);
1402
- if (this.shouldUseIntlApi()) {
1403
- return rule && rule.resolvedOptions().pluralCategories.length > 1;
1404
- }
1405
- return rule && rule.numbers.length > 1;
1406
- }
1407
- }, {
1408
- key: "getPluralFormsOfKey",
1409
- value: function getPluralFormsOfKey(code, key) {
1410
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1411
- return this.getSuffixes(code, options).map(function (suffix) {
1412
- return "".concat(key).concat(suffix);
1413
- });
1414
- }
1415
- }, {
1416
- key: "getSuffixes",
1417
- value: function getSuffixes(code) {
1418
- var _this = this;
1419
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1420
- var rule = this.getRule(code, options);
1421
- if (!rule) {
1422
- return [];
1423
- }
1424
- if (this.shouldUseIntlApi()) {
1425
- return rule.resolvedOptions().pluralCategories.sort(function (pluralCategory1, pluralCategory2) {
1426
- return suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2];
1427
- }).map(function (pluralCategory) {
1428
- return "".concat(_this.options.prepend).concat(pluralCategory);
1429
- });
1430
- }
1431
- return rule.numbers.map(function (number) {
1432
- return _this.getSuffix(code, number, options);
1433
- });
1434
- }
1435
- }, {
1436
- key: "getSuffix",
1437
- value: function getSuffix(code, count) {
1438
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1439
- var rule = this.getRule(code, options);
1440
- if (rule) {
1441
- if (this.shouldUseIntlApi()) {
1442
- return "".concat(this.options.prepend).concat(rule.select(count));
1443
- }
1444
- return this.getSuffixRetroCompatible(rule, count);
1445
- }
1446
- this.logger.warn("no plural rule found for: ".concat(code));
1447
- return '';
1448
- }
1449
- }, {
1450
- key: "getSuffixRetroCompatible",
1451
- value: function getSuffixRetroCompatible(rule, count) {
1452
- var _this2 = this;
1453
- var idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
1454
- var suffix = rule.numbers[idx];
1455
- if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1456
- if (suffix === 2) {
1457
- suffix = 'plural';
1458
- } else if (suffix === 1) {
1459
- suffix = '';
1460
- }
1461
- }
1462
- var returnSuffix = function returnSuffix() {
1463
- return _this2.options.prepend && suffix.toString() ? _this2.options.prepend + suffix.toString() : suffix.toString();
1464
- };
1465
- if (this.options.compatibilityJSON === 'v1') {
1466
- if (suffix === 1) return '';
1467
- if (typeof suffix === 'number') return "_plural_".concat(suffix.toString());
1468
- return returnSuffix();
1469
- } else if (this.options.compatibilityJSON === 'v2') {
1470
- return returnSuffix();
1471
- } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1472
- return returnSuffix();
1473
- }
1474
- return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
1475
- }
1476
- }, {
1477
- key: "shouldUseIntlApi",
1478
- value: function shouldUseIntlApi() {
1479
- return !deprecatedJsonVersions.includes(this.options.compatibilityJSON);
1480
- }
1481
- }]);
1482
- return PluralResolver;
1483
- }();
1484
-
1485
- function ownKeys$3$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; }
1486
- function _objectSpread$3$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1487
- var Interpolator = function () {
1488
- function Interpolator() {
1489
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1490
- _classCallCheck(this, Interpolator);
1491
- this.logger = baseLogger.create('interpolator');
1492
- this.options = options;
1493
- this.format = options.interpolation && options.interpolation.format || function (value) {
1494
- return value;
1495
- };
1496
- this.init(options);
1497
- }
1498
- _createClass(Interpolator, [{
1499
- key: "init",
1500
- value: function init() {
1501
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1502
- if (!options.interpolation) options.interpolation = {
1503
- escapeValue: true
1504
- };
1505
- var iOpts = options.interpolation;
1506
- this.escape = iOpts.escape !== undefined ? iOpts.escape : escape;
1507
- this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;
1508
- this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;
1509
- this.prefix = iOpts.prefix ? regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';
1510
- this.suffix = iOpts.suffix ? regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';
1511
- this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
1512
- this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';
1513
- this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';
1514
- this.nestingPrefix = iOpts.nestingPrefix ? regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || regexEscape('$t(');
1515
- this.nestingSuffix = iOpts.nestingSuffix ? regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || regexEscape(')');
1516
- this.nestingOptionsSeparator = iOpts.nestingOptionsSeparator ? iOpts.nestingOptionsSeparator : iOpts.nestingOptionsSeparator || ',';
1517
- this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000;
1518
- this.alwaysFormat = iOpts.alwaysFormat !== undefined ? iOpts.alwaysFormat : false;
1519
- this.resetRegExp();
1520
- }
1521
- }, {
1522
- key: "reset",
1523
- value: function reset() {
1524
- if (this.options) this.init(this.options);
1525
- }
1526
- }, {
1527
- key: "resetRegExp",
1528
- value: function resetRegExp() {
1529
- var regexpStr = "".concat(this.prefix, "(.+?)").concat(this.suffix);
1530
- this.regexp = new RegExp(regexpStr, 'g');
1531
- var regexpUnescapeStr = "".concat(this.prefix).concat(this.unescapePrefix, "(.+?)").concat(this.unescapeSuffix).concat(this.suffix);
1532
- this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');
1533
- var nestingRegexpStr = "".concat(this.nestingPrefix, "(.+?)").concat(this.nestingSuffix);
1534
- this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
1535
- }
1536
- }, {
1537
- key: "interpolate",
1538
- value: function interpolate(str, data, lng, options) {
1539
- var _this = this;
1540
- var match;
1541
- var value;
1542
- var replaces;
1543
- var defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
1544
- function regexSafe(val) {
1545
- return val.replace(/\$/g, '$$$$');
1546
- }
1547
- var handleFormat = function handleFormat(key) {
1548
- if (key.indexOf(_this.formatSeparator) < 0) {
1549
- var path = getPathWithDefaults(data, defaultData, key);
1550
- return _this.alwaysFormat ? _this.format(path, undefined, lng, _objectSpread$3$1(_objectSpread$3$1(_objectSpread$3$1({}, options), data), {}, {
1551
- interpolationkey: key
1552
- })) : path;
1553
- }
1554
- var p = key.split(_this.formatSeparator);
1555
- var k = p.shift().trim();
1556
- var f = p.join(_this.formatSeparator).trim();
1557
- return _this.format(getPathWithDefaults(data, defaultData, k), f, lng, _objectSpread$3$1(_objectSpread$3$1(_objectSpread$3$1({}, options), data), {}, {
1558
- interpolationkey: k
1559
- }));
1560
- };
1561
- this.resetRegExp();
1562
- var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
1563
- var skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1564
- var todos = [{
1565
- regex: this.regexpUnescape,
1566
- safeValue: function safeValue(val) {
1567
- return regexSafe(val);
1568
- }
1569
- }, {
1570
- regex: this.regexp,
1571
- safeValue: function safeValue(val) {
1572
- return _this.escapeValue ? regexSafe(_this.escape(val)) : regexSafe(val);
1573
- }
1574
- }];
1575
- todos.forEach(function (todo) {
1576
- replaces = 0;
1577
- while (match = todo.regex.exec(str)) {
1578
- var matchedVar = match[1].trim();
1579
- value = handleFormat(matchedVar);
1580
- if (value === undefined) {
1581
- if (typeof missingInterpolationHandler === 'function') {
1582
- var temp = missingInterpolationHandler(str, match, options);
1583
- value = typeof temp === 'string' ? temp : '';
1584
- } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
1585
- value = '';
1586
- } else if (skipOnVariables) {
1587
- value = match[0];
1588
- continue;
1589
- } else {
1590
- _this.logger.warn("missed to pass in variable ".concat(matchedVar, " for interpolating ").concat(str));
1591
- value = '';
1592
- }
1593
- } else if (typeof value !== 'string' && !_this.useRawValueToEscape) {
1594
- value = makeString(value);
1595
- }
1596
- var safeValue = todo.safeValue(value);
1597
- str = str.replace(match[0], safeValue);
1598
- if (skipOnVariables) {
1599
- todo.regex.lastIndex += value.length;
1600
- todo.regex.lastIndex -= match[0].length;
1601
- } else {
1602
- todo.regex.lastIndex = 0;
1603
- }
1604
- replaces++;
1605
- if (replaces >= _this.maxReplaces) {
1606
- break;
1607
- }
1608
- }
1609
- });
1610
- return str;
1611
- }
1612
- }, {
1613
- key: "nest",
1614
- value: function nest(str, fc) {
1615
- var _this2 = this;
1616
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1617
- var match;
1618
- var value;
1619
- var clonedOptions;
1620
- function handleHasOptions(key, inheritedOptions) {
1621
- var sep = this.nestingOptionsSeparator;
1622
- if (key.indexOf(sep) < 0) return key;
1623
- var c = key.split(new RegExp("".concat(sep, "[ ]*{")));
1624
- var optionsString = "{".concat(c[1]);
1625
- key = c[0];
1626
- optionsString = this.interpolate(optionsString, clonedOptions);
1627
- var matchedSingleQuotes = optionsString.match(/'/g);
1628
- var matchedDoubleQuotes = optionsString.match(/"/g);
1629
- if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
1630
- optionsString = optionsString.replace(/'/g, '"');
1631
- }
1632
- try {
1633
- clonedOptions = JSON.parse(optionsString);
1634
- if (inheritedOptions) clonedOptions = _objectSpread$3$1(_objectSpread$3$1({}, inheritedOptions), clonedOptions);
1635
- } catch (e) {
1636
- this.logger.warn("failed parsing options string in nesting for key ".concat(key), e);
1637
- return "".concat(key).concat(sep).concat(optionsString);
1638
- }
1639
- delete clonedOptions.defaultValue;
1640
- return key;
1641
- }
1642
- while (match = this.nestingRegexp.exec(str)) {
1643
- var formatters = [];
1644
- clonedOptions = _objectSpread$3$1({}, options);
1645
- clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;
1646
- clonedOptions.applyPostProcessor = false;
1647
- delete clonedOptions.defaultValue;
1648
- var doReduce = false;
1649
- if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
1650
- var r = match[1].split(this.formatSeparator).map(function (elem) {
1651
- return elem.trim();
1652
- });
1653
- match[1] = r.shift();
1654
- formatters = r;
1655
- doReduce = true;
1656
- }
1657
- value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1658
- if (value && match[0] === str && typeof value !== 'string') return value;
1659
- if (typeof value !== 'string') value = makeString(value);
1660
- if (!value) {
1661
- this.logger.warn("missed to resolve ".concat(match[1], " for nesting ").concat(str));
1662
- value = '';
1663
- }
1664
- if (doReduce) {
1665
- value = formatters.reduce(function (v, f) {
1666
- return _this2.format(v, f, options.lng, _objectSpread$3$1(_objectSpread$3$1({}, options), {}, {
1667
- interpolationkey: match[1].trim()
1668
- }));
1669
- }, value.trim());
1670
- }
1671
- str = str.replace(match[0], value);
1672
- this.regexp.lastIndex = 0;
1673
- }
1674
- return str;
1675
- }
1676
- }]);
1677
- return Interpolator;
1678
- }();
1679
-
1680
- function ownKeys$2$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; }
1681
- function _objectSpread$2$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1682
- function parseFormatStr(formatStr) {
1683
- var formatName = formatStr.toLowerCase().trim();
1684
- var formatOptions = {};
1685
- if (formatStr.indexOf('(') > -1) {
1686
- var p = formatStr.split('(');
1687
- formatName = p[0].toLowerCase().trim();
1688
- var optStr = p[1].substring(0, p[1].length - 1);
1689
- if (formatName === 'currency' && optStr.indexOf(':') < 0) {
1690
- if (!formatOptions.currency) formatOptions.currency = optStr.trim();
1691
- } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
1692
- if (!formatOptions.range) formatOptions.range = optStr.trim();
1693
- } else {
1694
- var opts = optStr.split(';');
1695
- opts.forEach(function (opt) {
1696
- if (!opt) return;
1697
- var _opt$split = opt.split(':'),
1698
- _opt$split2 = _toArray(_opt$split),
1699
- key = _opt$split2[0],
1700
- rest = _opt$split2.slice(1);
1701
- var val = rest.join(':').trim().replace(/^'+|'+$/g, '');
1702
- if (!formatOptions[key.trim()]) formatOptions[key.trim()] = val;
1703
- if (val === 'false') formatOptions[key.trim()] = false;
1704
- if (val === 'true') formatOptions[key.trim()] = true;
1705
- if (!isNaN(val)) formatOptions[key.trim()] = parseInt(val, 10);
1706
- });
1707
- }
1708
- }
1709
- return {
1710
- formatName: formatName,
1711
- formatOptions: formatOptions
1712
- };
1713
- }
1714
- function createCachedFormatter(fn) {
1715
- var cache = {};
1716
- return function invokeFormatter(val, lng, options) {
1717
- var key = lng + JSON.stringify(options);
1718
- var formatter = cache[key];
1719
- if (!formatter) {
1720
- formatter = fn(lng, options);
1721
- cache[key] = formatter;
1722
- }
1723
- return formatter(val);
1724
- };
1725
- }
1726
- var Formatter = function () {
1727
- function Formatter() {
1728
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1729
- _classCallCheck(this, Formatter);
1730
- this.logger = baseLogger.create('formatter');
1731
- this.options = options;
1732
- this.formats = {
1733
- number: createCachedFormatter(function (lng, opt) {
1734
- var formatter = new Intl.NumberFormat(lng, _objectSpread$2$1({}, opt));
1735
- return function (val) {
1736
- return formatter.format(val);
1737
- };
1738
- }),
1739
- currency: createCachedFormatter(function (lng, opt) {
1740
- var formatter = new Intl.NumberFormat(lng, _objectSpread$2$1(_objectSpread$2$1({}, opt), {}, {
1741
- style: 'currency'
1742
- }));
1743
- return function (val) {
1744
- return formatter.format(val);
1745
- };
1746
- }),
1747
- datetime: createCachedFormatter(function (lng, opt) {
1748
- var formatter = new Intl.DateTimeFormat(lng, _objectSpread$2$1({}, opt));
1749
- return function (val) {
1750
- return formatter.format(val);
1751
- };
1752
- }),
1753
- relativetime: createCachedFormatter(function (lng, opt) {
1754
- var formatter = new Intl.RelativeTimeFormat(lng, _objectSpread$2$1({}, opt));
1755
- return function (val) {
1756
- return formatter.format(val, opt.range || 'day');
1757
- };
1758
- }),
1759
- list: createCachedFormatter(function (lng, opt) {
1760
- var formatter = new Intl.ListFormat(lng, _objectSpread$2$1({}, opt));
1761
- return function (val) {
1762
- return formatter.format(val);
1763
- };
1764
- })
1765
- };
1766
- this.init(options);
1767
- }
1768
- _createClass(Formatter, [{
1769
- key: "init",
1770
- value: function init(services) {
1771
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1772
- interpolation: {}
1773
- };
1774
- var iOpts = options.interpolation;
1775
- this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
1776
- }
1777
- }, {
1778
- key: "add",
1779
- value: function add(name, fc) {
1780
- this.formats[name.toLowerCase().trim()] = fc;
1781
- }
1782
- }, {
1783
- key: "addCached",
1784
- value: function addCached(name, fc) {
1785
- this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1786
- }
1787
- }, {
1788
- key: "format",
1789
- value: function format(value, _format, lng) {
1790
- var _this = this;
1791
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1792
- var formats = _format.split(this.formatSeparator);
1793
- var result = formats.reduce(function (mem, f) {
1794
- var _parseFormatStr = parseFormatStr(f),
1795
- formatName = _parseFormatStr.formatName,
1796
- formatOptions = _parseFormatStr.formatOptions;
1797
- if (_this.formats[formatName]) {
1798
- var formatted = mem;
1799
- try {
1800
- var valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
1801
- var l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1802
- formatted = _this.formats[formatName](mem, l, _objectSpread$2$1(_objectSpread$2$1(_objectSpread$2$1({}, formatOptions), options), valOptions));
1803
- } catch (error) {
1804
- _this.logger.warn(error);
1805
- }
1806
- return formatted;
1807
- } else {
1808
- _this.logger.warn("there was no format function for ".concat(formatName));
1809
- }
1810
- return mem;
1811
- }, value);
1812
- return result;
1813
- }
1814
- }]);
1815
- return Formatter;
1816
- }();
1817
-
1818
- function ownKeys$1$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; }
1819
- function _objectSpread$1$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1820
- 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); }; }
1821
- 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; } }
1822
- function removePending(q, name) {
1823
- if (q.pending[name] !== undefined) {
1824
- delete q.pending[name];
1825
- q.pendingCount--;
1826
- }
1827
- }
1828
- var Connector = function (_EventEmitter) {
1829
- _inherits(Connector, _EventEmitter);
1830
- var _super = _createSuper$1(Connector);
1831
- function Connector(backend, store, services) {
1832
- var _this;
1833
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1834
- _classCallCheck(this, Connector);
1835
- _this = _super.call(this);
1836
- if (isIE10) {
1837
- EventEmitter.call(_assertThisInitialized(_this));
1838
- }
1839
- _this.backend = backend;
1840
- _this.store = store;
1841
- _this.services = services;
1842
- _this.languageUtils = services.languageUtils;
1843
- _this.options = options;
1844
- _this.logger = baseLogger.create('backendConnector');
1845
- _this.waitingReads = [];
1846
- _this.maxParallelReads = options.maxParallelReads || 10;
1847
- _this.readingCalls = 0;
1848
- _this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
1849
- _this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
1850
- _this.state = {};
1851
- _this.queue = [];
1852
- if (_this.backend && _this.backend.init) {
1853
- _this.backend.init(services, options.backend, options);
1854
- }
1855
- return _this;
1856
- }
1857
- _createClass(Connector, [{
1858
- key: "queueLoad",
1859
- value: function queueLoad(languages, namespaces, options, callback) {
1860
- var _this2 = this;
1861
- var toLoad = {};
1862
- var pending = {};
1863
- var toLoadLanguages = {};
1864
- var toLoadNamespaces = {};
1865
- languages.forEach(function (lng) {
1866
- var hasAllNamespaces = true;
1867
- namespaces.forEach(function (ns) {
1868
- var name = "".concat(lng, "|").concat(ns);
1869
- if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
1870
- _this2.state[name] = 2;
1871
- } else if (_this2.state[name] < 0) ; else if (_this2.state[name] === 1) {
1872
- if (pending[name] === undefined) pending[name] = true;
1873
- } else {
1874
- _this2.state[name] = 1;
1875
- hasAllNamespaces = false;
1876
- if (pending[name] === undefined) pending[name] = true;
1877
- if (toLoad[name] === undefined) toLoad[name] = true;
1878
- if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
1879
- }
1880
- });
1881
- if (!hasAllNamespaces) toLoadLanguages[lng] = true;
1882
- });
1883
- if (Object.keys(toLoad).length || Object.keys(pending).length) {
1884
- this.queue.push({
1885
- pending: pending,
1886
- pendingCount: Object.keys(pending).length,
1887
- loaded: {},
1888
- errors: [],
1889
- callback: callback
1890
- });
1891
- }
1892
- return {
1893
- toLoad: Object.keys(toLoad),
1894
- pending: Object.keys(pending),
1895
- toLoadLanguages: Object.keys(toLoadLanguages),
1896
- toLoadNamespaces: Object.keys(toLoadNamespaces)
1897
- };
1898
- }
1899
- }, {
1900
- key: "loaded",
1901
- value: function loaded(name, err, data) {
1902
- var s = name.split('|');
1903
- var lng = s[0];
1904
- var ns = s[1];
1905
- if (err) this.emit('failedLoading', lng, ns, err);
1906
- if (data) {
1907
- this.store.addResourceBundle(lng, ns, data);
1908
- }
1909
- this.state[name] = err ? -1 : 2;
1910
- var loaded = {};
1911
- this.queue.forEach(function (q) {
1912
- pushPath(q.loaded, [lng], ns);
1913
- removePending(q, name);
1914
- if (err) q.errors.push(err);
1915
- if (q.pendingCount === 0 && !q.done) {
1916
- Object.keys(q.loaded).forEach(function (l) {
1917
- if (!loaded[l]) loaded[l] = {};
1918
- var loadedKeys = q.loaded[l];
1919
- if (loadedKeys.length) {
1920
- loadedKeys.forEach(function (n) {
1921
- if (loaded[l][n] === undefined) loaded[l][n] = true;
1922
- });
1923
- }
1924
- });
1925
- q.done = true;
1926
- if (q.errors.length) {
1927
- q.callback(q.errors);
1928
- } else {
1929
- q.callback();
1930
- }
1931
- }
1932
- });
1933
- this.emit('loaded', loaded);
1934
- this.queue = this.queue.filter(function (q) {
1935
- return !q.done;
1936
- });
1937
- }
1938
- }, {
1939
- key: "read",
1940
- value: function read(lng, ns, fcName) {
1941
- var _this3 = this;
1942
- var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1943
- var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
1944
- var callback = arguments.length > 5 ? arguments[5] : undefined;
1945
- if (!lng.length) return callback(null, {});
1946
- if (this.readingCalls >= this.maxParallelReads) {
1947
- this.waitingReads.push({
1948
- lng: lng,
1949
- ns: ns,
1950
- fcName: fcName,
1951
- tried: tried,
1952
- wait: wait,
1953
- callback: callback
1954
- });
1955
- return;
1956
- }
1957
- this.readingCalls++;
1958
- var resolver = function resolver(err, data) {
1959
- _this3.readingCalls--;
1960
- if (_this3.waitingReads.length > 0) {
1961
- var next = _this3.waitingReads.shift();
1962
- _this3.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
1963
- }
1964
- if (err && data && tried < _this3.maxRetries) {
1965
- setTimeout(function () {
1966
- _this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
1967
- }, wait);
1968
- return;
1969
- }
1970
- callback(err, data);
1971
- };
1972
- var fc = this.backend[fcName].bind(this.backend);
1973
- if (fc.length === 2) {
1974
- try {
1975
- var r = fc(lng, ns);
1976
- if (r && typeof r.then === 'function') {
1977
- r.then(function (data) {
1978
- return resolver(null, data);
1979
- })["catch"](resolver);
1980
- } else {
1981
- resolver(null, r);
1982
- }
1983
- } catch (err) {
1984
- resolver(err);
1985
- }
1986
- return;
1987
- }
1988
- return fc(lng, ns, resolver);
1989
- }
1990
- }, {
1991
- key: "prepareLoading",
1992
- value: function prepareLoading(languages, namespaces) {
1993
- var _this4 = this;
1994
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1995
- var callback = arguments.length > 3 ? arguments[3] : undefined;
1996
- if (!this.backend) {
1997
- this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1998
- return callback && callback();
1999
- }
2000
- if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
2001
- if (typeof namespaces === 'string') namespaces = [namespaces];
2002
- var toLoad = this.queueLoad(languages, namespaces, options, callback);
2003
- if (!toLoad.toLoad.length) {
2004
- if (!toLoad.pending.length) callback();
2005
- return null;
2006
- }
2007
- toLoad.toLoad.forEach(function (name) {
2008
- _this4.loadOne(name);
2009
- });
2010
- }
2011
- }, {
2012
- key: "load",
2013
- value: function load(languages, namespaces, callback) {
2014
- this.prepareLoading(languages, namespaces, {}, callback);
2015
- }
2016
- }, {
2017
- key: "reload",
2018
- value: function reload(languages, namespaces, callback) {
2019
- this.prepareLoading(languages, namespaces, {
2020
- reload: true
2021
- }, callback);
2022
- }
2023
- }, {
2024
- key: "loadOne",
2025
- value: function loadOne(name) {
2026
- var _this5 = this;
2027
- var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2028
- var s = name.split('|');
2029
- var lng = s[0];
2030
- var ns = s[1];
2031
- this.read(lng, ns, 'read', undefined, undefined, function (err, data) {
2032
- if (err) _this5.logger.warn("".concat(prefix, "loading namespace ").concat(ns, " for language ").concat(lng, " failed"), err);
2033
- if (!err && data) _this5.logger.log("".concat(prefix, "loaded namespace ").concat(ns, " for language ").concat(lng), data);
2034
- _this5.loaded(name, err, data);
2035
- });
2036
- }
2037
- }, {
2038
- key: "saveMissing",
2039
- value: function saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
2040
- var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
2041
- var clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : function () {};
2042
- if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
2043
- 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!!!');
2044
- return;
2045
- }
2046
- if (key === undefined || key === null || key === '') return;
2047
- if (this.backend && this.backend.create) {
2048
- var opts = _objectSpread$1$1(_objectSpread$1$1({}, options), {}, {
2049
- isUpdate: isUpdate
2050
- });
2051
- var fc = this.backend.create.bind(this.backend);
2052
- if (fc.length < 6) {
2053
- try {
2054
- var r;
2055
- if (fc.length === 5) {
2056
- r = fc(languages, namespace, key, fallbackValue, opts);
2057
- } else {
2058
- r = fc(languages, namespace, key, fallbackValue);
2059
- }
2060
- if (r && typeof r.then === 'function') {
2061
- r.then(function (data) {
2062
- return clb(null, data);
2063
- })["catch"](clb);
2064
- } else {
2065
- clb(null, r);
2066
- }
2067
- } catch (err) {
2068
- clb(err);
2069
- }
2070
- } else {
2071
- fc(languages, namespace, key, fallbackValue, clb, opts);
2072
- }
2073
- }
2074
- if (!languages || !languages[0]) return;
2075
- this.store.addResource(languages[0], namespace, key, fallbackValue);
2076
- }
2077
- }]);
2078
- return Connector;
2079
- }(EventEmitter);
2080
-
2081
- function get() {
2082
- return {
2083
- debug: false,
2084
- initImmediate: true,
2085
- ns: ['translation'],
2086
- defaultNS: ['translation'],
2087
- fallbackLng: ['dev'],
2088
- fallbackNS: false,
2089
- supportedLngs: false,
2090
- nonExplicitSupportedLngs: false,
2091
- load: 'all',
2092
- preload: false,
2093
- simplifyPluralSuffix: true,
2094
- keySeparator: '.',
2095
- nsSeparator: ':',
2096
- pluralSeparator: '_',
2097
- contextSeparator: '_',
2098
- partialBundledLanguages: false,
2099
- saveMissing: false,
2100
- updateMissing: false,
2101
- saveMissingTo: 'fallback',
2102
- saveMissingPlurals: true,
2103
- missingKeyHandler: false,
2104
- missingInterpolationHandler: false,
2105
- postProcess: false,
2106
- postProcessPassResolved: false,
2107
- returnNull: true,
2108
- returnEmptyString: true,
2109
- returnObjects: false,
2110
- joinArrays: false,
2111
- returnedObjectHandler: false,
2112
- parseMissingKeyHandler: false,
2113
- appendNamespaceToMissingKey: false,
2114
- appendNamespaceToCIMode: false,
2115
- overloadTranslationOptionHandler: function handle(args) {
2116
- var ret = {};
2117
- if (_typeof$1(args[1]) === 'object') ret = args[1];
2118
- if (typeof args[1] === 'string') ret.defaultValue = args[1];
2119
- if (typeof args[2] === 'string') ret.tDescription = args[2];
2120
- if (_typeof$1(args[2]) === 'object' || _typeof$1(args[3]) === 'object') {
2121
- var options = args[3] || args[2];
2122
- Object.keys(options).forEach(function (key) {
2123
- ret[key] = options[key];
2124
- });
2125
- }
2126
- return ret;
2127
- },
2128
- interpolation: {
2129
- escapeValue: true,
2130
- format: function format(value, _format, lng, options) {
2131
- return value;
2132
- },
2133
- prefix: '{{',
2134
- suffix: '}}',
2135
- formatSeparator: ',',
2136
- unescapePrefix: '-',
2137
- nestingPrefix: '$t(',
2138
- nestingSuffix: ')',
2139
- nestingOptionsSeparator: ',',
2140
- maxReplaces: 1000,
2141
- skipOnVariables: true
2142
- }
2143
- };
2144
- }
2145
- function transformOptions(options) {
2146
- if (typeof options.ns === 'string') options.ns = [options.ns];
2147
- if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
2148
- if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
2149
- if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
2150
- options.supportedLngs = options.supportedLngs.concat(['cimode']);
2151
- }
2152
- return options;
2153
- }
2154
-
2155
- function ownKeys$8(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; }
2156
- function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2157
- 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); }; }
2158
- 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; } }
2159
- function noop() {}
2160
- function bindMemberFunctions(inst) {
2161
- var mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
2162
- mems.forEach(function (mem) {
2163
- if (typeof inst[mem] === 'function') {
2164
- inst[mem] = inst[mem].bind(inst);
2165
- }
2166
- });
2167
- }
2168
- var I18n = function (_EventEmitter) {
2169
- _inherits(I18n, _EventEmitter);
2170
- var _super = _createSuper(I18n);
2171
- function I18n() {
2172
- var _this;
2173
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2174
- var callback = arguments.length > 1 ? arguments[1] : undefined;
2175
- _classCallCheck(this, I18n);
2176
- _this = _super.call(this);
2177
- if (isIE10) {
2178
- EventEmitter.call(_assertThisInitialized(_this));
2179
- }
2180
- _this.options = transformOptions(options);
2181
- _this.services = {};
2182
- _this.logger = baseLogger;
2183
- _this.modules = {
2184
- external: []
2185
- };
2186
- bindMemberFunctions(_assertThisInitialized(_this));
2187
- if (callback && !_this.isInitialized && !options.isClone) {
2188
- if (!_this.options.initImmediate) {
2189
- _this.init(options, callback);
2190
- return _possibleConstructorReturn(_this, _assertThisInitialized(_this));
2191
- }
2192
- setTimeout(function () {
2193
- _this.init(options, callback);
2194
- }, 0);
2195
- }
2196
- return _this;
2197
- }
2198
- _createClass(I18n, [{
2199
- key: "init",
2200
- value: function init() {
2201
- var _this2 = this;
2202
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2203
- var callback = arguments.length > 1 ? arguments[1] : undefined;
2204
- if (typeof options === 'function') {
2205
- callback = options;
2206
- options = {};
2207
- }
2208
- if (!options.defaultNS && options.defaultNS !== false && options.ns) {
2209
- if (typeof options.ns === 'string') {
2210
- options.defaultNS = options.ns;
2211
- } else if (options.ns.indexOf('translation') < 0) {
2212
- options.defaultNS = options.ns[0];
2213
- }
2214
- }
2215
- var defOpts = get();
2216
- this.options = _objectSpread$8(_objectSpread$8(_objectSpread$8({}, defOpts), this.options), transformOptions(options));
2217
- if (this.options.compatibilityAPI !== 'v1') {
2218
- this.options.interpolation = _objectSpread$8(_objectSpread$8({}, defOpts.interpolation), this.options.interpolation);
2219
- }
2220
- if (options.keySeparator !== undefined) {
2221
- this.options.userDefinedKeySeparator = options.keySeparator;
2222
- }
2223
- if (options.nsSeparator !== undefined) {
2224
- this.options.userDefinedNsSeparator = options.nsSeparator;
2225
- }
2226
- function createClassOnDemand(ClassOrObject) {
2227
- if (!ClassOrObject) return null;
2228
- if (typeof ClassOrObject === 'function') return new ClassOrObject();
2229
- return ClassOrObject;
2230
- }
2231
- if (!this.options.isClone) {
2232
- if (this.modules.logger) {
2233
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
2234
- } else {
2235
- baseLogger.init(null, this.options);
2236
- }
2237
- var formatter;
2238
- if (this.modules.formatter) {
2239
- formatter = this.modules.formatter;
2240
- } else if (typeof Intl !== 'undefined') {
2241
- formatter = Formatter;
2242
- }
2243
- var lu = new LanguageUtil(this.options);
2244
- this.store = new ResourceStore(this.options.resources, this.options);
2245
- var s = this.services;
2246
- s.logger = baseLogger;
2247
- s.resourceStore = this.store;
2248
- s.languageUtils = lu;
2249
- s.pluralResolver = new PluralResolver(lu, {
2250
- prepend: this.options.pluralSeparator,
2251
- compatibilityJSON: this.options.compatibilityJSON,
2252
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
2253
- });
2254
- if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
2255
- s.formatter = createClassOnDemand(formatter);
2256
- s.formatter.init(s, this.options);
2257
- this.options.interpolation.format = s.formatter.format.bind(s.formatter);
2258
- }
2259
- s.interpolator = new Interpolator(this.options);
2260
- s.utils = {
2261
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
2262
- };
2263
- s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
2264
- s.backendConnector.on('*', function (event) {
2265
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2266
- args[_key - 1] = arguments[_key];
2267
- }
2268
- _this2.emit.apply(_this2, [event].concat(args));
2269
- });
2270
- if (this.modules.languageDetector) {
2271
- s.languageDetector = createClassOnDemand(this.modules.languageDetector);
2272
- if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
2273
- }
2274
- if (this.modules.i18nFormat) {
2275
- s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
2276
- if (s.i18nFormat.init) s.i18nFormat.init(this);
2277
- }
2278
- this.translator = new Translator(this.services, this.options);
2279
- this.translator.on('*', function (event) {
2280
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
2281
- args[_key2 - 1] = arguments[_key2];
2282
- }
2283
- _this2.emit.apply(_this2, [event].concat(args));
2284
- });
2285
- this.modules.external.forEach(function (m) {
2286
- if (m.init) m.init(_this2);
2287
- });
2288
- }
2289
- this.format = this.options.interpolation.format;
2290
- if (!callback) callback = noop;
2291
- if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
2292
- var codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
2293
- if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
2294
- }
2295
- if (!this.services.languageDetector && !this.options.lng) {
2296
- this.logger.warn('init: no languageDetector is used and no lng is defined');
2297
- }
2298
- var storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
2299
- storeApi.forEach(function (fcName) {
2300
- _this2[fcName] = function () {
2301
- var _this2$store;
2302
- return (_this2$store = _this2.store)[fcName].apply(_this2$store, arguments);
2303
- };
2304
- });
2305
- var storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
2306
- storeApiChained.forEach(function (fcName) {
2307
- _this2[fcName] = function () {
2308
- var _this2$store2;
2309
- (_this2$store2 = _this2.store)[fcName].apply(_this2$store2, arguments);
2310
- return _this2;
2311
- };
2312
- });
2313
- var deferred = defer();
2314
- var load = function load() {
2315
- var finish = function finish(err, t) {
2316
- if (_this2.isInitialized && !_this2.initializedStoreOnce) _this2.logger.warn('init: i18next is already initialized. You should call init just once!');
2317
- _this2.isInitialized = true;
2318
- if (!_this2.options.isClone) _this2.logger.log('initialized', _this2.options);
2319
- _this2.emit('initialized', _this2.options);
2320
- deferred.resolve(t);
2321
- callback(err, t);
2322
- };
2323
- if (_this2.languages && _this2.options.compatibilityAPI !== 'v1' && !_this2.isInitialized) return finish(null, _this2.t.bind(_this2));
2324
- _this2.changeLanguage(_this2.options.lng, finish);
2325
- };
2326
- if (this.options.resources || !this.options.initImmediate) {
2327
- load();
2328
- } else {
2329
- setTimeout(load, 0);
2330
- }
2331
- return deferred;
2332
- }
2333
- }, {
2334
- key: "loadResources",
2335
- value: function loadResources(language) {
2336
- var _this3 = this;
2337
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2338
- var usedCallback = callback;
2339
- var usedLng = typeof language === 'string' ? language : this.language;
2340
- if (typeof language === 'function') usedCallback = language;
2341
- if (!this.options.resources || this.options.partialBundledLanguages) {
2342
- if (usedLng && usedLng.toLowerCase() === 'cimode') return usedCallback();
2343
- var toLoad = [];
2344
- var append = function append(lng) {
2345
- if (!lng) return;
2346
- var lngs = _this3.services.languageUtils.toResolveHierarchy(lng);
2347
- lngs.forEach(function (l) {
2348
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
2349
- });
2350
- };
2351
- if (!usedLng) {
2352
- var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
2353
- fallbacks.forEach(function (l) {
2354
- return append(l);
2355
- });
2356
- } else {
2357
- append(usedLng);
2358
- }
2359
- if (this.options.preload) {
2360
- this.options.preload.forEach(function (l) {
2361
- return append(l);
2362
- });
2363
- }
2364
- this.services.backendConnector.load(toLoad, this.options.ns, function (e) {
2365
- if (!e && !_this3.resolvedLanguage && _this3.language) _this3.setResolvedLanguage(_this3.language);
2366
- usedCallback(e);
2367
- });
2368
- } else {
2369
- usedCallback(null);
2370
- }
2371
- }
2372
- }, {
2373
- key: "reloadResources",
2374
- value: function reloadResources(lngs, ns, callback) {
2375
- var deferred = defer();
2376
- if (!lngs) lngs = this.languages;
2377
- if (!ns) ns = this.options.ns;
2378
- if (!callback) callback = noop;
2379
- this.services.backendConnector.reload(lngs, ns, function (err) {
2380
- deferred.resolve();
2381
- callback(err);
2382
- });
2383
- return deferred;
2384
- }
2385
- }, {
2386
- key: "use",
2387
- value: function use(module) {
2388
- if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
2389
- if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
2390
- if (module.type === 'backend') {
2391
- this.modules.backend = module;
2392
- }
2393
- if (module.type === 'logger' || module.log && module.warn && module.error) {
2394
- this.modules.logger = module;
2395
- }
2396
- if (module.type === 'languageDetector') {
2397
- this.modules.languageDetector = module;
2398
- }
2399
- if (module.type === 'i18nFormat') {
2400
- this.modules.i18nFormat = module;
2401
- }
2402
- if (module.type === 'postProcessor') {
2403
- postProcessor.addPostProcessor(module);
2404
- }
2405
- if (module.type === 'formatter') {
2406
- this.modules.formatter = module;
2407
- }
2408
- if (module.type === '3rdParty') {
2409
- this.modules.external.push(module);
2410
- }
2411
- return this;
2412
- }
2413
- }, {
2414
- key: "setResolvedLanguage",
2415
- value: function setResolvedLanguage(l) {
2416
- if (!l || !this.languages) return;
2417
- if (['cimode', 'dev'].indexOf(l) > -1) return;
2418
- for (var li = 0; li < this.languages.length; li++) {
2419
- var lngInLngs = this.languages[li];
2420
- if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
2421
- if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
2422
- this.resolvedLanguage = lngInLngs;
2423
- break;
2424
- }
2425
- }
2426
- }
2427
- }, {
2428
- key: "changeLanguage",
2429
- value: function changeLanguage(lng, callback) {
2430
- var _this4 = this;
2431
- this.isLanguageChangingTo = lng;
2432
- var deferred = defer();
2433
- this.emit('languageChanging', lng);
2434
- var setLngProps = function setLngProps(l) {
2435
- _this4.language = l;
2436
- _this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);
2437
- _this4.resolvedLanguage = undefined;
2438
- _this4.setResolvedLanguage(l);
2439
- };
2440
- var done = function done(err, l) {
2441
- if (l) {
2442
- setLngProps(l);
2443
- _this4.translator.changeLanguage(l);
2444
- _this4.isLanguageChangingTo = undefined;
2445
- _this4.emit('languageChanged', l);
2446
- _this4.logger.log('languageChanged', l);
2447
- } else {
2448
- _this4.isLanguageChangingTo = undefined;
2449
- }
2450
- deferred.resolve(function () {
2451
- return _this4.t.apply(_this4, arguments);
2452
- });
2453
- if (callback) callback(err, function () {
2454
- return _this4.t.apply(_this4, arguments);
2455
- });
2456
- };
2457
- var setLng = function setLng(lngs) {
2458
- if (!lng && !lngs && _this4.services.languageDetector) lngs = [];
2459
- var l = typeof lngs === 'string' ? lngs : _this4.services.languageUtils.getBestMatchFromCodes(lngs);
2460
- if (l) {
2461
- if (!_this4.language) {
2462
- setLngProps(l);
2463
- }
2464
- if (!_this4.translator.language) _this4.translator.changeLanguage(l);
2465
- if (_this4.services.languageDetector && _this4.services.languageDetector.cacheUserLanguage) _this4.services.languageDetector.cacheUserLanguage(l);
2466
- }
2467
- _this4.loadResources(l, function (err) {
2468
- done(err, l);
2469
- });
2470
- };
2471
- if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
2472
- setLng(this.services.languageDetector.detect());
2473
- } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
2474
- if (this.services.languageDetector.detect.length === 0) {
2475
- this.services.languageDetector.detect().then(setLng);
2476
- } else {
2477
- this.services.languageDetector.detect(setLng);
2478
- }
2479
- } else {
2480
- setLng(lng);
2481
- }
2482
- return deferred;
2483
- }
2484
- }, {
2485
- key: "getFixedT",
2486
- value: function getFixedT(lng, ns, keyPrefix) {
2487
- var _this5 = this;
2488
- var fixedT = function fixedT(key, opts) {
2489
- var options;
2490
- if (_typeof$1(opts) !== 'object') {
2491
- for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
2492
- rest[_key3 - 2] = arguments[_key3];
2493
- }
2494
- options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2495
- } else {
2496
- options = _objectSpread$8({}, opts);
2497
- }
2498
- options.lng = options.lng || fixedT.lng;
2499
- options.lngs = options.lngs || fixedT.lngs;
2500
- options.ns = options.ns || fixedT.ns;
2501
- options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
2502
- var keySeparator = _this5.options.keySeparator || '.';
2503
- var resultKey;
2504
- if (options.keyPrefix && Array.isArray(key)) {
2505
- resultKey = key.map(function (k) {
2506
- return "".concat(options.keyPrefix).concat(keySeparator).concat(k);
2507
- });
2508
- } else {
2509
- resultKey = options.keyPrefix ? "".concat(options.keyPrefix).concat(keySeparator).concat(key) : key;
2510
- }
2511
- return _this5.t(resultKey, options);
2512
- };
2513
- if (typeof lng === 'string') {
2514
- fixedT.lng = lng;
2515
- } else {
2516
- fixedT.lngs = lng;
2517
- }
2518
- fixedT.ns = ns;
2519
- fixedT.keyPrefix = keyPrefix;
2520
- return fixedT;
2521
- }
2522
- }, {
2523
- key: "t",
2524
- value: function t() {
2525
- var _this$translator;
2526
- return this.translator && (_this$translator = this.translator).translate.apply(_this$translator, arguments);
2527
- }
2528
- }, {
2529
- key: "exists",
2530
- value: function exists() {
2531
- var _this$translator2;
2532
- return this.translator && (_this$translator2 = this.translator).exists.apply(_this$translator2, arguments);
2533
- }
2534
- }, {
2535
- key: "setDefaultNamespace",
2536
- value: function setDefaultNamespace(ns) {
2537
- this.options.defaultNS = ns;
2538
- }
2539
- }, {
2540
- key: "hasLoadedNamespace",
2541
- value: function hasLoadedNamespace(ns) {
2542
- var _this6 = this;
2543
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2544
- if (!this.isInitialized) {
2545
- this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
2546
- return false;
2547
- }
2548
- if (!this.languages || !this.languages.length) {
2549
- this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
2550
- return false;
2551
- }
2552
- var lng = this.resolvedLanguage || this.languages[0];
2553
- var fallbackLng = this.options ? this.options.fallbackLng : false;
2554
- var lastLng = this.languages[this.languages.length - 1];
2555
- if (lng.toLowerCase() === 'cimode') return true;
2556
- var loadNotPending = function loadNotPending(l, n) {
2557
- var loadState = _this6.services.backendConnector.state["".concat(l, "|").concat(n)];
2558
- return loadState === -1 || loadState === 2;
2559
- };
2560
- if (options.precheck) {
2561
- var preResult = options.precheck(this, loadNotPending);
2562
- if (preResult !== undefined) return preResult;
2563
- }
2564
- if (this.hasResourceBundle(lng, ns)) return true;
2565
- if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
2566
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2567
- return false;
2568
- }
2569
- }, {
2570
- key: "loadNamespaces",
2571
- value: function loadNamespaces(ns, callback) {
2572
- var _this7 = this;
2573
- var deferred = defer();
2574
- if (!this.options.ns) {
2575
- if (callback) callback();
2576
- return Promise.resolve();
2577
- }
2578
- if (typeof ns === 'string') ns = [ns];
2579
- ns.forEach(function (n) {
2580
- if (_this7.options.ns.indexOf(n) < 0) _this7.options.ns.push(n);
2581
- });
2582
- this.loadResources(function (err) {
2583
- deferred.resolve();
2584
- if (callback) callback(err);
2585
- });
2586
- return deferred;
2587
- }
2588
- }, {
2589
- key: "loadLanguages",
2590
- value: function loadLanguages(lngs, callback) {
2591
- var deferred = defer();
2592
- if (typeof lngs === 'string') lngs = [lngs];
2593
- var preloaded = this.options.preload || [];
2594
- var newLngs = lngs.filter(function (lng) {
2595
- return preloaded.indexOf(lng) < 0;
2596
- });
2597
- if (!newLngs.length) {
2598
- if (callback) callback();
2599
- return Promise.resolve();
2600
- }
2601
- this.options.preload = preloaded.concat(newLngs);
2602
- this.loadResources(function (err) {
2603
- deferred.resolve();
2604
- if (callback) callback(err);
2605
- });
2606
- return deferred;
2607
- }
2608
- }, {
2609
- key: "dir",
2610
- value: function dir(lng) {
2611
- if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
2612
- if (!lng) return 'rtl';
2613
- 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'];
2614
- var languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
2615
- return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2616
- }
2617
- }, {
2618
- key: "cloneInstance",
2619
- value: function cloneInstance() {
2620
- var _this8 = this;
2621
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2622
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2623
- var mergedOptions = _objectSpread$8(_objectSpread$8(_objectSpread$8({}, this.options), options), {
2624
- isClone: true
2625
- });
2626
- var clone = new I18n(mergedOptions);
2627
- if (options.debug !== undefined || options.prefix !== undefined) {
2628
- clone.logger = clone.logger.clone(options);
2629
- }
2630
- var membersToCopy = ['store', 'services', 'language'];
2631
- membersToCopy.forEach(function (m) {
2632
- clone[m] = _this8[m];
2633
- });
2634
- clone.services = _objectSpread$8({}, this.services);
2635
- clone.services.utils = {
2636
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2637
- };
2638
- clone.translator = new Translator(clone.services, clone.options);
2639
- clone.translator.on('*', function (event) {
2640
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
2641
- args[_key4 - 1] = arguments[_key4];
2642
- }
2643
- clone.emit.apply(clone, [event].concat(args));
2644
- });
2645
- clone.init(mergedOptions, callback);
2646
- clone.translator.options = clone.options;
2647
- clone.translator.backendConnector.services.utils = {
2648
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2649
- };
2650
- return clone;
2651
- }
2652
- }, {
2653
- key: "toJSON",
2654
- value: function toJSON() {
2655
- return {
2656
- options: this.options,
2657
- store: this.store,
2658
- language: this.language,
2659
- languages: this.languages,
2660
- resolvedLanguage: this.resolvedLanguage
2661
- };
2662
- }
2663
- }]);
2664
- return I18n;
2665
- }(EventEmitter);
2666
- _defineProperty(I18n, "createInstance", function () {
2667
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2668
- var callback = arguments.length > 1 ? arguments[1] : undefined;
2669
- return new I18n(options, callback);
2670
- });
2671
- var instance = I18n.createInstance();
2672
- instance.createInstance = I18n.createInstance;
2673
-
2674
- instance.createInstance;
2675
- instance.dir;
2676
- instance.init;
2677
- instance.loadResources;
2678
- instance.reloadResources;
2679
- instance.use;
2680
- instance.changeLanguage;
2681
- instance.getFixedT;
2682
- var t$1 = instance.t;
2683
- instance.exists;
2684
- instance.setDefaultNamespace;
2685
- instance.hasLoadedNamespace;
2686
- instance.loadNamespaces;
2687
- instance.loadLanguages;
2688
-
2689
- var arr = [];
2690
- var each = arr.forEach;
2691
- var slice = arr.slice;
2692
- function defaults(obj) {
2693
- each.call(slice.call(arguments, 1), function (source) {
2694
- if (source) {
2695
- for (var prop in source) {
2696
- if (obj[prop] === undefined) obj[prop] = source[prop];
2697
- }
2698
- }
2699
- });
2700
- return obj;
2701
- }
2702
-
2703
- // eslint-disable-next-line no-control-regex
2704
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
2705
- var serializeCookie = function serializeCookie(name, val, options) {
2706
- var opt = options || {};
2707
- opt.path = opt.path || '/';
2708
- var value = encodeURIComponent(val);
2709
- var str = "".concat(name, "=").concat(value);
2710
- if (opt.maxAge > 0) {
2711
- var maxAge = opt.maxAge - 0;
2712
- if (Number.isNaN(maxAge)) throw new Error('maxAge should be a Number');
2713
- str += "; Max-Age=".concat(Math.floor(maxAge));
2714
- }
2715
- if (opt.domain) {
2716
- if (!fieldContentRegExp.test(opt.domain)) {
2717
- throw new TypeError('option domain is invalid');
2718
- }
2719
- str += "; Domain=".concat(opt.domain);
2720
- }
2721
- if (opt.path) {
2722
- if (!fieldContentRegExp.test(opt.path)) {
2723
- throw new TypeError('option path is invalid');
2724
- }
2725
- str += "; Path=".concat(opt.path);
2726
- }
2727
- if (opt.expires) {
2728
- if (typeof opt.expires.toUTCString !== 'function') {
2729
- throw new TypeError('option expires is invalid');
2730
- }
2731
- str += "; Expires=".concat(opt.expires.toUTCString());
2732
- }
2733
- if (opt.httpOnly) str += '; HttpOnly';
2734
- if (opt.secure) str += '; Secure';
2735
- if (opt.sameSite) {
2736
- var sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;
2737
- switch (sameSite) {
2738
- case true:
2739
- str += '; SameSite=Strict';
2740
- break;
2741
- case 'lax':
2742
- str += '; SameSite=Lax';
2743
- break;
2744
- case 'strict':
2745
- str += '; SameSite=Strict';
2746
- break;
2747
- case 'none':
2748
- str += '; SameSite=None';
2749
- break;
2750
- default:
2751
- throw new TypeError('option sameSite is invalid');
2752
- }
2753
- }
2754
- return str;
2755
- };
2756
- var cookie = {
2757
- create: function create(name, value, minutes, domain) {
2758
- var cookieOptions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
2759
- path: '/',
2760
- sameSite: 'strict'
2761
- };
2762
- if (minutes) {
2763
- cookieOptions.expires = new Date();
2764
- cookieOptions.expires.setTime(cookieOptions.expires.getTime() + minutes * 60 * 1000);
2765
- }
2766
- if (domain) cookieOptions.domain = domain;
2767
- document.cookie = serializeCookie(name, encodeURIComponent(value), cookieOptions);
2768
- },
2769
- read: function read(name) {
2770
- var nameEQ = "".concat(name, "=");
2771
- var ca = document.cookie.split(';');
2772
- for (var i = 0; i < ca.length; i++) {
2773
- var c = ca[i];
2774
- while (c.charAt(0) === ' ') {
2775
- c = c.substring(1, c.length);
2776
- }
2777
- if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
2778
- }
2779
- return null;
2780
- },
2781
- remove: function remove(name) {
2782
- this.create(name, '', -1);
2783
- }
2784
- };
2785
- var cookie$1 = {
2786
- name: 'cookie',
2787
- lookup: function lookup(options) {
2788
- var found;
2789
- if (options.lookupCookie && typeof document !== 'undefined') {
2790
- var c = cookie.read(options.lookupCookie);
2791
- if (c) found = c;
2792
- }
2793
- return found;
2794
- },
2795
- cacheUserLanguage: function cacheUserLanguage(lng, options) {
2796
- if (options.lookupCookie && typeof document !== 'undefined') {
2797
- cookie.create(options.lookupCookie, lng, options.cookieMinutes, options.cookieDomain, options.cookieOptions);
2798
- }
2799
- }
2800
- };
2801
-
2802
- var querystring = {
2803
- name: 'querystring',
2804
- lookup: function lookup(options) {
2805
- var found;
2806
- if (typeof window !== 'undefined') {
2807
- var search = window.location.search;
2808
- if (!window.location.search && window.location.hash && window.location.hash.indexOf('?') > -1) {
2809
- search = window.location.hash.substring(window.location.hash.indexOf('?'));
2810
- }
2811
- var query = search.substring(1);
2812
- var params = query.split('&');
2813
- for (var i = 0; i < params.length; i++) {
2814
- var pos = params[i].indexOf('=');
2815
- if (pos > 0) {
2816
- var key = params[i].substring(0, pos);
2817
- if (key === options.lookupQuerystring) {
2818
- found = params[i].substring(pos + 1);
2819
- }
2820
- }
2821
- }
2822
- }
2823
- return found;
2824
- }
2825
- };
2826
-
2827
- var hasLocalStorageSupport = null;
2828
- var localStorageAvailable = function localStorageAvailable() {
2829
- if (hasLocalStorageSupport !== null) return hasLocalStorageSupport;
2830
- try {
2831
- hasLocalStorageSupport = window !== 'undefined' && window.localStorage !== null;
2832
- var testKey = 'i18next.translate.boo';
2833
- window.localStorage.setItem(testKey, 'foo');
2834
- window.localStorage.removeItem(testKey);
2835
- } catch (e) {
2836
- hasLocalStorageSupport = false;
2837
- }
2838
- return hasLocalStorageSupport;
2839
- };
2840
- var localStorage = {
2841
- name: 'localStorage',
2842
- lookup: function lookup(options) {
2843
- var found;
2844
- if (options.lookupLocalStorage && localStorageAvailable()) {
2845
- var lng = window.localStorage.getItem(options.lookupLocalStorage);
2846
- if (lng) found = lng;
2847
- }
2848
- return found;
2849
- },
2850
- cacheUserLanguage: function cacheUserLanguage(lng, options) {
2851
- if (options.lookupLocalStorage && localStorageAvailable()) {
2852
- window.localStorage.setItem(options.lookupLocalStorage, lng);
2853
- }
2854
- }
2855
- };
2856
-
2857
- var hasSessionStorageSupport = null;
2858
- var sessionStorageAvailable = function sessionStorageAvailable() {
2859
- if (hasSessionStorageSupport !== null) return hasSessionStorageSupport;
2860
- try {
2861
- hasSessionStorageSupport = window !== 'undefined' && window.sessionStorage !== null;
2862
- var testKey = 'i18next.translate.boo';
2863
- window.sessionStorage.setItem(testKey, 'foo');
2864
- window.sessionStorage.removeItem(testKey);
2865
- } catch (e) {
2866
- hasSessionStorageSupport = false;
2867
- }
2868
- return hasSessionStorageSupport;
2869
- };
2870
- var sessionStorage = {
2871
- name: 'sessionStorage',
2872
- lookup: function lookup(options) {
2873
- var found;
2874
- if (options.lookupSessionStorage && sessionStorageAvailable()) {
2875
- var lng = window.sessionStorage.getItem(options.lookupSessionStorage);
2876
- if (lng) found = lng;
2877
- }
2878
- return found;
2879
- },
2880
- cacheUserLanguage: function cacheUserLanguage(lng, options) {
2881
- if (options.lookupSessionStorage && sessionStorageAvailable()) {
2882
- window.sessionStorage.setItem(options.lookupSessionStorage, lng);
2883
- }
2884
- }
2885
- };
2886
-
2887
- var navigator$1 = {
2888
- name: 'navigator',
2889
- lookup: function lookup(options) {
2890
- var found = [];
2891
- if (typeof navigator !== 'undefined') {
2892
- if (navigator.languages) {
2893
- // chrome only; not an array, so can't use .push.apply instead of iterating
2894
- for (var i = 0; i < navigator.languages.length; i++) {
2895
- found.push(navigator.languages[i]);
2896
- }
2897
- }
2898
- if (navigator.userLanguage) {
2899
- found.push(navigator.userLanguage);
2900
- }
2901
- if (navigator.language) {
2902
- found.push(navigator.language);
2903
- }
2904
- }
2905
- return found.length > 0 ? found : undefined;
2906
- }
2907
- };
2908
-
2909
- var htmlTag = {
2910
- name: 'htmlTag',
2911
- lookup: function lookup(options) {
2912
- var found;
2913
- var htmlTag = options.htmlTag || (typeof document !== 'undefined' ? document.documentElement : null);
2914
- if (htmlTag && typeof htmlTag.getAttribute === 'function') {
2915
- found = htmlTag.getAttribute('lang');
2916
- }
2917
- return found;
2918
- }
2919
- };
2920
-
2921
- var path = {
2922
- name: 'path',
2923
- lookup: function lookup(options) {
2924
- var found;
2925
- if (typeof window !== 'undefined') {
2926
- var language = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
2927
- if (language instanceof Array) {
2928
- if (typeof options.lookupFromPathIndex === 'number') {
2929
- if (typeof language[options.lookupFromPathIndex] !== 'string') {
2930
- return undefined;
2931
- }
2932
- found = language[options.lookupFromPathIndex].replace('/', '');
2933
- } else {
2934
- found = language[0].replace('/', '');
2935
- }
2936
- }
2937
- }
2938
- return found;
2939
- }
2940
- };
2941
-
2942
- var subdomain = {
2943
- name: 'subdomain',
2944
- lookup: function lookup(options) {
2945
- // If given get the subdomain index else 1
2946
- var lookupFromSubdomainIndex = typeof options.lookupFromSubdomainIndex === 'number' ? options.lookupFromSubdomainIndex + 1 : 1;
2947
- // get all matches if window.location. is existing
2948
- // first item of match is the match itself and the second is the first group macht which sould be the first subdomain match
2949
- // is the hostname no public domain get the or option of localhost
2950
- var language = typeof window !== 'undefined' && window.location && window.location.hostname && window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);
2951
-
2952
- // if there is no match (null) return undefined
2953
- if (!language) return undefined;
2954
- // return the given group match
2955
- return language[lookupFromSubdomainIndex];
2956
- }
2957
- };
2958
-
2959
- function getDefaults$1() {
2960
- return {
2961
- order: ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'htmlTag'],
2962
- lookupQuerystring: 'lng',
2963
- lookupCookie: 'i18next',
2964
- lookupLocalStorage: 'i18nextLng',
2965
- lookupSessionStorage: 'i18nextLng',
2966
- // cache user language
2967
- caches: ['localStorage'],
2968
- excludeCacheFor: ['cimode']
2969
- // cookieMinutes: 10,
2970
- // cookieDomain: 'myDomain'
2971
- };
2972
- }
2973
- var Browser = /*#__PURE__*/function () {
2974
- function Browser(services) {
2975
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2976
- _classCallCheck(this, Browser);
2977
- this.type = 'languageDetector';
2978
- this.detectors = {};
2979
- this.init(services, options);
2980
- }
2981
- _createClass(Browser, [{
2982
- key: "init",
2983
- value: function init(services) {
2984
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2985
- var i18nOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2986
- this.services = services;
2987
- this.options = defaults(options, this.options || {}, getDefaults$1());
2988
-
2989
- // backwards compatibility
2990
- if (this.options.lookupFromUrlIndex) this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex;
2991
- this.i18nOptions = i18nOptions;
2992
- this.addDetector(cookie$1);
2993
- this.addDetector(querystring);
2994
- this.addDetector(localStorage);
2995
- this.addDetector(sessionStorage);
2996
- this.addDetector(navigator$1);
2997
- this.addDetector(htmlTag);
2998
- this.addDetector(path);
2999
- this.addDetector(subdomain);
3000
- }
3001
- }, {
3002
- key: "addDetector",
3003
- value: function addDetector(detector) {
3004
- this.detectors[detector.name] = detector;
3005
- }
3006
- }, {
3007
- key: "detect",
3008
- value: function detect(detectionOrder) {
3009
- var _this = this;
3010
- if (!detectionOrder) detectionOrder = this.options.order;
3011
- var detected = [];
3012
- detectionOrder.forEach(function (detectorName) {
3013
- if (_this.detectors[detectorName]) {
3014
- var lookup = _this.detectors[detectorName].lookup(_this.options);
3015
- if (lookup && typeof lookup === 'string') lookup = [lookup];
3016
- if (lookup) detected = detected.concat(lookup);
3017
- }
3018
- });
3019
- if (this.services.languageUtils.getBestMatchFromCodes) return detected; // new i18next v19.5.0
3020
- return detected.length > 0 ? detected[0] : null; // a little backward compatibility
3021
- }
3022
- }, {
3023
- key: "cacheUserLanguage",
3024
- value: function cacheUserLanguage(lng, caches) {
3025
- var _this2 = this;
3026
- if (!caches) caches = this.options.caches;
3027
- if (!caches) return;
3028
- if (this.options.excludeCacheFor && this.options.excludeCacheFor.indexOf(lng) > -1) return;
3029
- caches.forEach(function (cacheName) {
3030
- if (_this2.detectors[cacheName]) _this2.detectors[cacheName].cacheUserLanguage(lng, _this2.options);
3031
- });
3032
- }
3033
- }]);
3034
- return Browser;
3035
- }();
3036
- Browser.type = 'languageDetector';
3037
-
3038
- function _objectWithoutPropertiesLoose(source, excluded) {
3039
- if (source == null) return {};
3040
- var target = {};
3041
- var sourceKeys = Object.keys(source);
3042
- var key, i;
3043
- for (i = 0; i < sourceKeys.length; i++) {
3044
- key = sourceKeys[i];
3045
- if (excluded.indexOf(key) >= 0) continue;
3046
- target[key] = source[key];
3047
- }
3048
- return target;
3049
- }
3050
-
3051
- function _objectWithoutProperties(source, excluded) {
3052
- if (source == null) return {};
3053
- var target = _objectWithoutPropertiesLoose(source, excluded);
3054
- var key, i;
3055
- if (Object.getOwnPropertySymbols) {
3056
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
3057
- for (i = 0; i < sourceSymbolKeys.length; i++) {
3058
- key = sourceSymbolKeys[i];
3059
- if (excluded.indexOf(key) >= 0) continue;
3060
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
3061
- target[key] = source[key];
3062
- }
3063
- }
3064
- return target;
3065
- }
3066
-
3067
- function getDefaultExportFromCjs (x) {
3068
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
3069
- }
3070
-
3071
- /**
3072
- * This file automatically generated from `pre-publish.js`.
3073
- * Do not manually edit.
3074
- */
3075
-
3076
- var voidElements = {
3077
- "area": true,
3078
- "base": true,
3079
- "br": true,
3080
- "col": true,
3081
- "embed": true,
3082
- "hr": true,
3083
- "img": true,
3084
- "input": true,
3085
- "link": true,
3086
- "meta": true,
3087
- "param": true,
3088
- "source": true,
3089
- "track": true,
3090
- "wbr": true
3091
- };
3092
-
3093
- var e = /*@__PURE__*/getDefaultExportFromCjs(voidElements);
3094
-
3095
- 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],(e[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)},"")}};
3096
-
3097
- /**
3098
- * Copyright (C) 2017-present by Andrea Giammarchi - @WebReflection
3099
- *
3100
- * Permission is hereby granted, free of charge, to any person obtaining a copy
3101
- * of this software and associated documentation files (the "Software"), to deal
3102
- * in the Software without restriction, including without limitation the rights
3103
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3104
- * copies of the Software, and to permit persons to whom the Software is
3105
- * furnished to do so, subject to the following conditions:
3106
- *
3107
- * The above copyright notice and this permission notice shall be included in
3108
- * all copies or substantial portions of the Software.
3109
- *
3110
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3111
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3112
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3113
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3114
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3115
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3116
- * THE SOFTWARE.
3117
- */
3118
-
3119
- var replace = ''.replace;
3120
- var es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
3121
- var unes = {
3122
- '&amp;': '&',
3123
- '&#38;': '&',
3124
- '&lt;': '<',
3125
- '&#60;': '<',
3126
- '&gt;': '>',
3127
- '&#62;': '>',
3128
- '&apos;': "'",
3129
- '&#39;': "'",
3130
- '&quot;': '"',
3131
- '&#34;': '"'
3132
- };
3133
-
3134
- function unescape(un) {
3135
- return replace.call(un, es, cape);
3136
- }
3137
- function cape(m) {
3138
- return unes[m];
3139
- }
3140
-
3141
- function ownKeys$7(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; }
3142
-
3143
- function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
3144
- var defaultOptions = {
3145
- bindI18n: 'languageChanged',
3146
- bindI18nStore: '',
3147
- transEmptyNodeValue: '',
3148
- transSupportBasicHtmlNodes: true,
3149
- transWrapTextNodes: '',
3150
- transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
3151
- useSuspense: true
3152
- };
3153
- var i18nInstance;
3154
- var I18nContext = React__default["default"].createContext();
3155
- function setDefaults() {
3156
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3157
- defaultOptions = _objectSpread$7(_objectSpread$7({}, defaultOptions), options);
3158
- }
3159
- function getDefaults() {
3160
- return defaultOptions;
3161
- }
3162
- var ReportNamespaces = function () {
3163
- function ReportNamespaces() {
3164
- _classCallCheck(this, ReportNamespaces);
3165
-
3166
- this.usedNamespaces = {};
3167
- }
3168
-
3169
- _createClass(ReportNamespaces, [{
3170
- key: "addUsedNamespaces",
3171
- value: function addUsedNamespaces(namespaces) {
3172
- var _this = this;
3173
-
3174
- namespaces.forEach(function (ns) {
3175
- if (!_this.usedNamespaces[ns]) _this.usedNamespaces[ns] = true;
3176
- });
3177
- }
3178
- }, {
3179
- key: "getUsedNamespaces",
3180
- value: function getUsedNamespaces() {
3181
- return Object.keys(this.usedNamespaces);
3182
- }
3183
- }]);
3184
-
3185
- return ReportNamespaces;
3186
- }();
3187
- function setI18n(instance) {
3188
- i18nInstance = instance;
3189
- }
3190
- function getI18n() {
3191
- return i18nInstance;
3192
- }
3193
- var initReactI18next = {
3194
- type: '3rdParty',
3195
- init: function init(instance) {
3196
- setDefaults(instance.options.react);
3197
- setI18n(instance);
3198
- }
3199
- };
3200
-
3201
- function warn() {
3202
- if (console && console.warn) {
3203
- var _console;
3204
-
3205
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3206
- args[_key] = arguments[_key];
3207
- }
3208
-
3209
- if (typeof args[0] === 'string') args[0] = "react-i18next:: ".concat(args[0]);
3210
-
3211
- (_console = console).warn.apply(_console, args);
3212
- }
3213
- }
3214
- var alreadyWarned = {};
3215
- function warnOnce() {
3216
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3217
- args[_key2] = arguments[_key2];
3218
- }
3219
-
3220
- if (typeof args[0] === 'string' && alreadyWarned[args[0]]) return;
3221
- if (typeof args[0] === 'string') alreadyWarned[args[0]] = new Date();
3222
- warn.apply(void 0, args);
3223
- }
3224
- function loadNamespaces(i18n, ns, cb) {
3225
- i18n.loadNamespaces(ns, function () {
3226
- if (i18n.isInitialized) {
3227
- cb();
3228
- } else {
3229
- var initialized = function initialized() {
3230
- setTimeout(function () {
3231
- i18n.off('initialized', initialized);
3232
- }, 0);
3233
- cb();
3234
- };
3235
-
3236
- i18n.on('initialized', initialized);
3237
- }
3238
- });
3239
- }
3240
-
3241
- function oldI18nextHasLoadedNamespace(ns, i18n) {
3242
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3243
- var lng = i18n.languages[0];
3244
- var fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
3245
- var lastLng = i18n.languages[i18n.languages.length - 1];
3246
- if (lng.toLowerCase() === 'cimode') return true;
3247
-
3248
- var loadNotPending = function loadNotPending(l, n) {
3249
- var loadState = i18n.services.backendConnector.state["".concat(l, "|").concat(n)];
3250
- return loadState === -1 || loadState === 2;
3251
- };
3252
-
3253
- if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false;
3254
- if (i18n.hasResourceBundle(lng, ns)) return true;
3255
- if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
3256
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
3257
- return false;
3258
- }
3259
-
3260
- function hasLoadedNamespace(ns, i18n) {
3261
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3262
-
3263
- if (!i18n.languages || !i18n.languages.length) {
3264
- warnOnce('i18n.languages were undefined or empty', i18n.languages);
3265
- return true;
3266
- }
3267
-
3268
- var isNewerI18next = i18n.options.ignoreJSONStructure !== undefined;
3269
-
3270
- if (!isNewerI18next) {
3271
- return oldI18nextHasLoadedNamespace(ns, i18n, options);
66
+ function _toPrimitive(input, hint) {
67
+ if (_typeof$1(input) !== "object" || input === null) return input;
68
+ var prim = input[Symbol.toPrimitive];
69
+ if (prim !== undefined) {
70
+ var res = prim.call(input, hint || "default");
71
+ if (_typeof$1(res) !== "object") return res;
72
+ throw new TypeError("@@toPrimitive must return a primitive value.");
3272
73
  }
3273
-
3274
- return i18n.hasLoadedNamespace(ns, {
3275
- precheck: function precheck(i18nInstance, loadNotPending) {
3276
- if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
3277
- }
3278
- });
3279
- }
3280
-
3281
- var _excluded = ["format"],
3282
- _excluded2 = ["children", "count", "parent", "i18nKey", "context", "tOptions", "values", "defaults", "components", "ns", "i18n", "t", "shouldUnescape"];
3283
-
3284
- 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; }
3285
-
3286
- 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; }
3287
-
3288
- function hasChildren(node, checkLength) {
3289
- if (!node) return false;
3290
- var base = node.props ? node.props.children : node.children;
3291
- if (checkLength) return base.length > 0;
3292
- return !!base;
3293
- }
3294
-
3295
- function getChildren(node) {
3296
- if (!node) return [];
3297
- return node && node.children ? node.children : node.props && node.props.children;
3298
- }
3299
-
3300
- function hasValidReactChildren(children) {
3301
- if (Object.prototype.toString.call(children) !== '[object Array]') return false;
3302
- return children.every(function (child) {
3303
- return React__default["default"].isValidElement(child);
3304
- });
3305
- }
3306
-
3307
- function getAsArray(data) {
3308
- return Array.isArray(data) ? data : [data];
3309
- }
3310
-
3311
- function mergeProps(source, target) {
3312
- var newTarget = _objectSpread$6({}, target);
3313
-
3314
- newTarget.props = Object.assign(source.props, target.props);
3315
- return newTarget;
74
+ return (hint === "string" ? String : Number)(input);
3316
75
  }
3317
76
 
3318
- function nodesToString(children, i18nOptions) {
3319
- if (!children) return '';
3320
- var stringNode = '';
3321
- var childrenArray = getAsArray(children);
3322
- var keepArray = i18nOptions.transSupportBasicHtmlNodes && i18nOptions.transKeepBasicHtmlNodesFor ? i18nOptions.transKeepBasicHtmlNodesFor : [];
3323
- childrenArray.forEach(function (child, childIndex) {
3324
- if (typeof child === 'string') {
3325
- stringNode += "".concat(child);
3326
- } else if (React__default["default"].isValidElement(child)) {
3327
- var childPropsCount = Object.keys(child.props).length;
3328
- var shouldKeepChild = keepArray.indexOf(child.type) > -1;
3329
- var childChildren = child.props.children;
3330
-
3331
- if (!childChildren && shouldKeepChild && childPropsCount === 0) {
3332
- stringNode += "<".concat(child.type, "/>");
3333
- } else if (!childChildren && (!shouldKeepChild || childPropsCount !== 0)) {
3334
- stringNode += "<".concat(childIndex, "></").concat(childIndex, ">");
3335
- } else if (child.props.i18nIsDynamicList) {
3336
- stringNode += "<".concat(childIndex, "></").concat(childIndex, ">");
3337
- } else if (shouldKeepChild && childPropsCount === 1 && typeof childChildren === 'string') {
3338
- stringNode += "<".concat(child.type, ">").concat(childChildren, "</").concat(child.type, ">");
3339
- } else {
3340
- var content = nodesToString(childChildren, i18nOptions);
3341
- stringNode += "<".concat(childIndex, ">").concat(content, "</").concat(childIndex, ">");
3342
- }
3343
- } else if (child === null) {
3344
- warn("Trans: the passed in value is invalid - seems you passed in a null child.");
3345
- } else if (_typeof$1(child) === 'object') {
3346
- var format = child.format,
3347
- clone = _objectWithoutProperties(child, _excluded);
3348
-
3349
- var keys = Object.keys(clone);
3350
-
3351
- if (keys.length === 1) {
3352
- var value = format ? "".concat(keys[0], ", ").concat(format) : keys[0];
3353
- stringNode += "{{".concat(value, "}}");
3354
- } else {
3355
- warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.", child);
3356
- }
3357
- } else {
3358
- warn("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.", child);
3359
- }
3360
- });
3361
- return stringNode;
77
+ function _toPropertyKey(arg) {
78
+ var key = _toPrimitive(arg, "string");
79
+ return _typeof$1(key) === "symbol" ? key : String(key);
3362
80
  }
3363
81
 
3364
- function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) {
3365
- if (targetString === '') return [];
3366
- var keepArray = i18nOptions.transKeepBasicHtmlNodesFor || [];
3367
- var emptyChildrenButNeedsHandling = targetString && new RegExp(keepArray.join('|')).test(targetString);
3368
- if (!children && !emptyChildrenButNeedsHandling) return [targetString];
3369
- var data = {};
3370
-
3371
- function getData(childs) {
3372
- var childrenArray = getAsArray(childs);
3373
- childrenArray.forEach(function (child) {
3374
- if (typeof child === 'string') return;
3375
- if (hasChildren(child)) getData(getChildren(child));else if (_typeof$1(child) === 'object' && !React__default["default"].isValidElement(child)) Object.assign(data, child);
82
+ function _defineProperty(obj, key, value) {
83
+ key = _toPropertyKey(key);
84
+ if (key in obj) {
85
+ Object.defineProperty(obj, key, {
86
+ value: value,
87
+ enumerable: true,
88
+ configurable: true,
89
+ writable: true
3376
90
  });
91
+ } else {
92
+ obj[key] = value;
3377
93
  }
3378
-
3379
- getData(children);
3380
- var ast = c.parse("<0>".concat(targetString, "</0>"));
3381
-
3382
- var opts = _objectSpread$6(_objectSpread$6({}, data), combinedTOpts);
3383
-
3384
- function renderInner(child, node, rootReactNode) {
3385
- var childs = getChildren(child);
3386
- var mappedChildren = mapAST(childs, node.children, rootReactNode);
3387
- return hasValidReactChildren(childs) && mappedChildren.length === 0 ? childs : mappedChildren;
3388
- }
3389
-
3390
- function pushTranslatedJSX(child, inner, mem, i, isVoid) {
3391
- if (child.dummy) child.children = inner;
3392
- mem.push(React__default["default"].cloneElement(child, _objectSpread$6(_objectSpread$6({}, child.props), {}, {
3393
- key: i
3394
- }), isVoid ? undefined : inner));
3395
- }
3396
-
3397
- function mapAST(reactNode, astNode, rootReactNode) {
3398
- var reactNodes = getAsArray(reactNode);
3399
- var astNodes = getAsArray(astNode);
3400
- return astNodes.reduce(function (mem, node, i) {
3401
- var translationContent = node.children && node.children[0] && node.children[0].content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
3402
-
3403
- if (node.type === 'tag') {
3404
- var tmp = reactNodes[parseInt(node.name, 10)];
3405
- if (!tmp && rootReactNode.length === 1 && rootReactNode[0][node.name]) tmp = rootReactNode[0][node.name];
3406
- if (!tmp) tmp = {};
3407
- var child = Object.keys(node.attrs).length !== 0 ? mergeProps({
3408
- props: node.attrs
3409
- }, tmp) : tmp;
3410
- var isElement = React__default["default"].isValidElement(child);
3411
- var isValidTranslationWithChildren = isElement && hasChildren(node, true) && !node.voidElement;
3412
- var isEmptyTransWithHTML = emptyChildrenButNeedsHandling && _typeof$1(child) === 'object' && child.dummy && !isElement;
3413
- var isKnownComponent = _typeof$1(children) === 'object' && children !== null && Object.hasOwnProperty.call(children, node.name);
3414
-
3415
- if (typeof child === 'string') {
3416
- var value = i18n.services.interpolator.interpolate(child, opts, i18n.language);
3417
- mem.push(value);
3418
- } else if (hasChildren(child) || isValidTranslationWithChildren) {
3419
- var inner = renderInner(child, node, rootReactNode);
3420
- pushTranslatedJSX(child, inner, mem, i);
3421
- } else if (isEmptyTransWithHTML) {
3422
- var _inner = mapAST(reactNodes, node.children, rootReactNode);
3423
-
3424
- mem.push(React__default["default"].cloneElement(child, _objectSpread$6(_objectSpread$6({}, child.props), {}, {
3425
- key: i
3426
- }), _inner));
3427
- } else if (Number.isNaN(parseFloat(node.name))) {
3428
- if (isKnownComponent) {
3429
- var _inner2 = renderInner(child, node, rootReactNode);
3430
-
3431
- pushTranslatedJSX(child, _inner2, mem, i, node.voidElement);
3432
- } else if (i18nOptions.transSupportBasicHtmlNodes && keepArray.indexOf(node.name) > -1) {
3433
- if (node.voidElement) {
3434
- mem.push(React__default["default"].createElement(node.name, {
3435
- key: "".concat(node.name, "-").concat(i)
3436
- }));
3437
- } else {
3438
- var _inner3 = mapAST(reactNodes, node.children, rootReactNode);
3439
-
3440
- mem.push(React__default["default"].createElement(node.name, {
3441
- key: "".concat(node.name, "-").concat(i)
3442
- }, _inner3));
3443
- }
3444
- } else if (node.voidElement) {
3445
- mem.push("<".concat(node.name, " />"));
3446
- } else {
3447
- var _inner4 = mapAST(reactNodes, node.children, rootReactNode);
3448
-
3449
- mem.push("<".concat(node.name, ">").concat(_inner4, "</").concat(node.name, ">"));
3450
- }
3451
- } else if (_typeof$1(child) === 'object' && !isElement) {
3452
- var content = node.children[0] ? translationContent : null;
3453
- if (content) mem.push(content);
3454
- } else if (node.children.length === 1 && translationContent) {
3455
- mem.push(React__default["default"].cloneElement(child, _objectSpread$6(_objectSpread$6({}, child.props), {}, {
3456
- key: i
3457
- }), translationContent));
3458
- } else {
3459
- mem.push(React__default["default"].cloneElement(child, _objectSpread$6(_objectSpread$6({}, child.props), {}, {
3460
- key: i
3461
- })));
3462
- }
3463
- } else if (node.type === 'text') {
3464
- var wrapTextNodes = i18nOptions.transWrapTextNodes;
3465
-
3466
- var _content = shouldUnescape ? unescape(i18n.services.interpolator.interpolate(node.content, opts, i18n.language)) : i18n.services.interpolator.interpolate(node.content, opts, i18n.language);
3467
-
3468
- if (wrapTextNodes) {
3469
- mem.push(React__default["default"].createElement(wrapTextNodes, {
3470
- key: "".concat(node.name, "-").concat(i)
3471
- }, _content));
3472
- } else {
3473
- mem.push(_content);
3474
- }
3475
- }
3476
-
3477
- return mem;
3478
- }, []);
3479
- }
3480
-
3481
- var result = mapAST([{
3482
- dummy: true,
3483
- children: children || []
3484
- }], ast, getAsArray(children || []));
3485
- return getChildren(result[0]);
94
+ return obj;
3486
95
  }
3487
96
 
3488
- function Trans(_ref) {
3489
- var children = _ref.children,
3490
- count = _ref.count,
3491
- parent = _ref.parent,
3492
- i18nKey = _ref.i18nKey,
3493
- context = _ref.context,
3494
- _ref$tOptions = _ref.tOptions,
3495
- tOptions = _ref$tOptions === void 0 ? {} : _ref$tOptions,
3496
- values = _ref.values,
3497
- defaults = _ref.defaults,
3498
- components = _ref.components,
3499
- ns = _ref.ns,
3500
- i18nFromProps = _ref.i18n,
3501
- tFromProps = _ref.t,
3502
- shouldUnescape = _ref.shouldUnescape,
3503
- additionalProps = _objectWithoutProperties(_ref, _excluded2);
3504
-
3505
- var _ref2 = React.useContext(I18nContext) || {},
3506
- i18nFromContext = _ref2.i18n,
3507
- defaultNSFromContext = _ref2.defaultNS;
3508
-
3509
- var i18n = i18nFromProps || i18nFromContext || getI18n();
3510
-
3511
- if (!i18n) {
3512
- warnOnce('You will need to pass in an i18next instance by using i18nextReactModule');
3513
- return children;
3514
- }
3515
-
3516
- var t = tFromProps || i18n.t.bind(i18n) || function (k) {
3517
- return k;
3518
- };
3519
-
3520
- if (context) tOptions.context = context;
3521
-
3522
- var reactI18nextOptions = _objectSpread$6(_objectSpread$6({}, getDefaults()), i18n.options && i18n.options.react);
3523
-
3524
- var namespaces = ns || t.ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
3525
- namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
3526
- var defaultValue = defaults || nodesToString(children, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue || i18nKey;
3527
- var hashTransKey = reactI18nextOptions.hashTransKey;
3528
- var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
3529
- var interpolationOverride = values ? tOptions.interpolation : {
3530
- interpolation: _objectSpread$6(_objectSpread$6({}, tOptions.interpolation), {}, {
3531
- prefix: '#$?',
3532
- suffix: '?$#'
3533
- })
3534
- };
3535
-
3536
- var combinedTOpts = _objectSpread$6(_objectSpread$6(_objectSpread$6(_objectSpread$6({}, tOptions), {}, {
3537
- count: count
3538
- }, values), interpolationOverride), {}, {
3539
- defaultValue: defaultValue,
3540
- ns: namespaces
3541
- });
3542
-
3543
- var translation = key ? t(key, combinedTOpts) : defaultValue;
3544
- var content = renderNodes(components || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
3545
- var useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
3546
- return useAsParent ? React__default["default"].createElement(useAsParent, additionalProps, content) : content;
97
+ function _arrayWithHoles(arr) {
98
+ if (Array.isArray(arr)) return arr;
3547
99
  }
3548
100
 
3549
101
  function _iterableToArrayLimit(arr, i) {
@@ -3574,204 +126,50 @@ function _iterableToArrayLimit(arr, i) {
3574
126
  }
3575
127
  }
3576
128
 
3577
- function _slicedToArray(arr, i) {
3578
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
129
+ function _arrayLikeToArray(arr, len) {
130
+ if (len == null || len > arr.length) len = arr.length;
131
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
132
+ return arr2;
3579
133
  }
3580
134
 
3581
- 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; }
3582
-
3583
- 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; }
3584
- function useTranslation(ns) {
3585
- var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3586
- var i18nFromProps = props.i18n;
3587
-
3588
- var _ref = React.useContext(I18nContext) || {},
3589
- i18nFromContext = _ref.i18n,
3590
- defaultNSFromContext = _ref.defaultNS;
3591
-
3592
- var i18n = i18nFromProps || i18nFromContext || getI18n();
3593
- if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
3594
-
3595
- if (!i18n) {
3596
- warnOnce('You will need to pass in an i18next instance by using initReactI18next');
3597
-
3598
- var notReadyT = function notReadyT(k) {
3599
- return Array.isArray(k) ? k[k.length - 1] : k;
3600
- };
3601
-
3602
- var retNotReady = [notReadyT, {}, false];
3603
- retNotReady.t = notReadyT;
3604
- retNotReady.i18n = {};
3605
- retNotReady.ready = false;
3606
- return retNotReady;
3607
- }
3608
-
3609
- if (i18n.options.react && i18n.options.react.wait !== undefined) warnOnce('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
3610
-
3611
- var i18nOptions = _objectSpread$5(_objectSpread$5(_objectSpread$5({}, getDefaults()), i18n.options.react), props);
3612
-
3613
- var useSuspense = i18nOptions.useSuspense,
3614
- keyPrefix = i18nOptions.keyPrefix;
3615
- var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
3616
- namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
3617
- if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
3618
- var ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(function (n) {
3619
- return hasLoadedNamespace(n, i18n, i18nOptions);
3620
- });
3621
-
3622
- function getT() {
3623
- return i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
3624
- }
3625
-
3626
- var _useState = React.useState(getT),
3627
- _useState2 = _slicedToArray(_useState, 2),
3628
- t = _useState2[0],
3629
- setT = _useState2[1];
3630
-
3631
- var isMounted = React.useRef(true);
3632
- React.useEffect(function () {
3633
- var bindI18n = i18nOptions.bindI18n,
3634
- bindI18nStore = i18nOptions.bindI18nStore;
3635
- isMounted.current = true;
3636
-
3637
- if (!ready && !useSuspense) {
3638
- loadNamespaces(i18n, namespaces, function () {
3639
- if (isMounted.current) setT(getT);
3640
- });
3641
- }
3642
-
3643
- function boundReset() {
3644
- if (isMounted.current) setT(getT);
3645
- }
3646
-
3647
- if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
3648
- if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
3649
- return function () {
3650
- isMounted.current = false;
3651
- if (bindI18n && i18n) bindI18n.split(' ').forEach(function (e) {
3652
- return i18n.off(e, boundReset);
3653
- });
3654
- if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(function (e) {
3655
- return i18n.store.off(e, boundReset);
3656
- });
3657
- };
3658
- }, [i18n, namespaces.join()]);
3659
- var isInitial = React.useRef(true);
3660
- React.useEffect(function () {
3661
- if (isMounted.current && !isInitial.current) {
3662
- setT(getT);
3663
- }
3664
-
3665
- isInitial.current = false;
3666
- }, [i18n]);
3667
- var ret = [t, i18n, ready];
3668
- ret.t = t;
3669
- ret.i18n = i18n;
3670
- ret.ready = ready;
3671
- if (ready) return ret;
3672
- if (!ready && !useSuspense) return ret;
3673
- throw new Promise(function (resolve) {
3674
- loadNamespaces(i18n, namespaces, function () {
3675
- resolve();
3676
- });
3677
- });
135
+ function _unsupportedIterableToArray(o, minLen) {
136
+ if (!o) return;
137
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
138
+ var n = Object.prototype.toString.call(o).slice(8, -1);
139
+ if (n === "Object" && o.constructor) n = o.constructor.name;
140
+ if (n === "Map" || n === "Set") return Array.from(o);
141
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
3678
142
  }
3679
143
 
3680
- var neetoMessageTemplate = {
3681
- template: {
3682
- addEmailTemplate: "Add new email template",
3683
- addSmsTemplate: "Add new sms template",
3684
- addWhatsappTemplate: "Add new whatsapp template",
3685
- editEmailTemplate: "Edit email template",
3686
- editSmsTemplate: "Edit sms template",
3687
- editWhatsappTemplate: "Edit whatsapp template",
3688
- search: "Search {{what}}",
3689
- markAsActive: "Mark as active",
3690
- markAsInactive: "Mark as inactive",
3691
- close: "Close",
3692
- "delete": "Delete",
3693
- edit: "Edit",
3694
- saveChanges: "Save changes",
3695
- send: "Send",
3696
- cancel: "Cancel",
3697
- emailAddress: "Email address",
3698
- phoneNumber: "Phone number",
3699
- name: "Name",
3700
- body: "Body",
3701
- subject: "Subject",
3702
- title: "Template",
3703
- active: "Active",
3704
- templateDeleteConfirmation: "Are you sure want to delete <strong>{{name}}</strong>. This action cannot be undone.",
3705
- deleteTemplate: "Delete {{label}}",
3706
- emailTemplates: "Email Templates",
3707
- emailTemplate: "Email Template",
3708
- smsTemplates: "Sms Templates",
3709
- smsTemplate: "Sms Template",
3710
- whatsappTemplates: "Whatsapp Templates",
3711
- whatsappTemplate: "Whatsapp Template",
3712
- emptyState: "There are no {{type}} to show.",
3713
- sendTestEmail: "Send test email",
3714
- sendTestSms: "Send test sms",
3715
- filtersEmptyState: "There are no {{type}} to show for applied filters.",
3716
- preview: "Template Preview",
3717
- resolveVariable: "Resolve {{type}} variables",
3718
- validation: {
3719
- namePresence: "Name is required",
3720
- subjectPresence: "Subject is required",
3721
- bodyPresence: "Body is required",
3722
- emailAddressPresence: "Email address is required",
3723
- emailAddressFormatValidation: "Invalid email address",
3724
- validPhoneNumber: "Enter valid phone number",
3725
- variablePresence: "Variable should not be empty"
3726
- }
3727
- },
3728
- sendMessage: {
3729
- email: "Send email",
3730
- sms: "Send sms",
3731
- selectTemplate: "Select a template",
3732
- testSmsNote: "Note: Variable values will be empty for test sms."
3733
- },
3734
- common: {
3735
- send: "Send"
3736
- }
3737
- };
3738
- var en = {
3739
- neetoMessageTemplate: neetoMessageTemplate
3740
- };
144
+ function _nonIterableRest() {
145
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
146
+ }
3741
147
 
3742
- instance.use(Browser).use(initReactI18next).init({
3743
- resources: {
3744
- en: {
3745
- translation: en
3746
- }
3747
- },
3748
- fallbackLng: "en",
3749
- detection: {
3750
- order: ["navigator"]
3751
- }
3752
- });
148
+ function _slicedToArray(arr, i) {
149
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
150
+ }
3753
151
 
3754
152
  var MESSAGE_TEMPLATES = {
3755
153
  email: {
3756
- label: t$1("neetoMessageTemplate.template.emailTemplates"),
154
+ label: i18next.t("neetoMessageTemplate.template.emailTemplates"),
3757
155
  value: "email_template",
3758
- addText: t$1("neetoMessageTemplate.template.addEmailTemplate"),
3759
- labelSingular: t$1("neetoMessageTemplate.template.emailTemplate"),
3760
- editText: t$1("neetoMessageTemplate.template.editEmailTemplate")
156
+ addText: i18next.t("neetoMessageTemplate.template.addEmailTemplate"),
157
+ labelSingular: i18next.t("neetoMessageTemplate.template.emailTemplate"),
158
+ editText: i18next.t("neetoMessageTemplate.template.editEmailTemplate")
3761
159
  },
3762
160
  sms: {
3763
- label: t$1("neetoMessageTemplate.template.smsTemplates"),
161
+ label: i18next.t("neetoMessageTemplate.template.smsTemplates"),
3764
162
  value: "sms_template",
3765
- addText: t$1("neetoMessageTemplate.template.addSmsTemplate"),
3766
- labelSingular: t$1("neetoMessageTemplate.template.smsTemplate"),
3767
- editText: t$1("neetoMessageTemplate.template.editSmsTemplate")
163
+ addText: i18next.t("neetoMessageTemplate.template.addSmsTemplate"),
164
+ labelSingular: i18next.t("neetoMessageTemplate.template.smsTemplate"),
165
+ editText: i18next.t("neetoMessageTemplate.template.editSmsTemplate")
3768
166
  },
3769
167
  whatsapp: {
3770
- label: t$1("neetoMessageTemplate.template.whatsappTemplates"),
168
+ label: i18next.t("neetoMessageTemplate.template.whatsappTemplates"),
3771
169
  value: "whatsapp_template",
3772
- addText: t$1("neetoMessageTemplate.template.addWhatsappTemplate"),
3773
- labelSingular: t$1("neetoMessageTemplate.template.whatsappTemplate"),
3774
- editText: t$1("neetoMessageTemplate.template.editWhatsappTemplate")
170
+ addText: i18next.t("neetoMessageTemplate.template.addWhatsappTemplate"),
171
+ labelSingular: i18next.t("neetoMessageTemplate.template.whatsappTemplate"),
172
+ editText: i18next.t("neetoMessageTemplate.template.editWhatsappTemplate")
3775
173
  }
3776
174
  };
3777
175
  var DEFAULT_EDITOR_ROW_COUNT = 15;
@@ -3782,9 +180,8 @@ var MESSAGE_TEMPLATE_INITIAL_STATE = {
3782
180
  isDelete: false,
3783
181
  template: {}
3784
182
  };
3785
- var DEFAULT_PAGE_SIZE = 10;
3786
183
  var DEFAULT_PAGE_PROPERTIES = {
3787
- size: DEFAULT_PAGE_SIZE,
184
+ size: constants.DEFAULT_PAGE_SIZE,
3788
185
  index: constants.DEFAULT_PAGE_INDEX
3789
186
  };
3790
187
 
@@ -3890,7 +287,7 @@ var RowActions = function RowActions(_ref) {
3890
287
  var template = _ref.template,
3891
288
  setManageTemplatePane = _ref.setManageTemplatePane,
3892
289
  ownerId = _ref.ownerId;
3893
- var _useTranslation = useTranslation(),
290
+ var _useTranslation = reactI18next.useTranslation(),
3894
291
  t = _useTranslation.t;
3895
292
  var _useUpdateTemplate = useUpdateTemplate(ownerId),
3896
293
  update = _useUpdateTemplate.mutate;
@@ -3940,7 +337,7 @@ var RowActions = function RowActions(_ref) {
3940
337
 
3941
338
  var renderSearchProps = function renderSearchProps(label, setSearchTerm, searchTerm) {
3942
339
  return {
3943
- placeholder: t$1("neetoMessageTemplate.template.search", {
340
+ placeholder: i18next.t("neetoMessageTemplate.template.search", {
3944
341
  what: label.toLowerCase()
3945
342
  }),
3946
343
  onChange: function onChange(_ref) {
@@ -3955,8 +352,8 @@ var buildTableColumnData = function buildTableColumnData(setManageTemplatePane,
3955
352
  dataIndex: "name",
3956
353
  key: "name",
3957
354
  node: "name",
3958
- title: t$1("neetoMessageTemplate.template.name"),
3959
- label: t$1("neetoMessageTemplate.template.name"),
355
+ title: i18next.t("neetoMessageTemplate.template.name"),
356
+ label: i18next.t("neetoMessageTemplate.template.name"),
3960
357
  type: "text",
3961
358
  render: function render(name, template) {
3962
359
  return /*#__PURE__*/React__default["default"].createElement("div", {
@@ -3973,8 +370,8 @@ var buildTableColumnData = function buildTableColumnData(setManageTemplatePane,
3973
370
  dataIndex: "status",
3974
371
  key: "status",
3975
372
  node: "status",
3976
- title: t$1("neetoMessageTemplate.template.active"),
3977
- label: t$1("neetoMessageTemplate.template.active"),
373
+ title: i18next.t("neetoMessageTemplate.template.active"),
374
+ label: i18next.t("neetoMessageTemplate.template.active"),
3978
375
  type: "single_option",
3979
376
  values: [{
3980
377
  label: "Yes",
@@ -4006,20 +403,20 @@ var SMS_TEMPLATE_INITIAL_VALUES = {
4006
403
  testPhoneNumber: ""
4007
404
  };
4008
405
  var EMAIL_TEMPLATE_FORM_SCHEMA = yup__namespace.object({
4009
- name: yup__namespace.string().trim().required(t$1("neetoMessageTemplate.template.validation.namePresence")),
4010
- subject: yup__namespace.string().trim().required(t$1("neetoMessageTemplate.template.validation.subjectPresence")),
4011
- body: yup__namespace.string().test("name", t$1("neetoMessageTemplate.template.validation.bodyPresence"), function (value) {
406
+ name: yup__namespace.string().trim().required(i18next.t("neetoMessageTemplate.template.validation.namePresence")),
407
+ subject: yup__namespace.string().trim().required(i18next.t("neetoMessageTemplate.template.validation.subjectPresence")),
408
+ body: yup__namespace.string().test("name", i18next.t("neetoMessageTemplate.template.validation.bodyPresence"), function (value) {
4012
409
  return !!formatEditorContent$1(value);
4013
410
  })
4014
411
  });
4015
412
  var SMS_TEMPLATE_FORM_VALIDATION_SCHEMA = yup__namespace.object({
4016
- name: yup__namespace.string().trim().required(t$1("neetoMessageTemplate.template.validation.namePresence")),
4017
- body: yup__namespace.string().test("body", t$1("neetoMessageTemplate.template.validation.bodyPresence"), function (value) {
413
+ name: yup__namespace.string().trim().required(i18next.t("neetoMessageTemplate.template.validation.namePresence")),
414
+ body: yup__namespace.string().test("body", i18next.t("neetoMessageTemplate.template.validation.bodyPresence"), function (value) {
4018
415
  return !!formatEditorContent$1(value);
4019
416
  })
4020
417
  });
4021
- var SEND_TEST_EMAIL_SCHEMA = yup__namespace.string().trim().required(t$1("neetoMessageTemplate.template.validation.emailAddressPresence")).email(t$1("neetoMessageTemplate.template.validation.emailAddressFormatValidation"));
4022
- var PHONE_NUMBER_VALIDATION_SCHEMA = yup__namespace.string().test("testPhoneNumber", t$1("neetoMessageTemplate.template.validation.validPhoneNumber"), function (value) {
418
+ var SEND_TEST_EMAIL_SCHEMA = yup__namespace.string().trim().required(i18next.t("neetoMessageTemplate.template.validation.emailAddressPresence")).email(i18next.t("neetoMessageTemplate.template.validation.emailAddressFormatValidation"));
419
+ var PHONE_NUMBER_VALIDATION_SCHEMA = yup__namespace.string().test("testPhoneNumber", i18next.t("neetoMessageTemplate.template.validation.validPhoneNumber"), function (value) {
4023
420
  return PhoneNumber.isPhoneNumberValid(value);
4024
421
  });
4025
422
 
@@ -4054,6 +451,10 @@ function _asyncToGenerator(fn) {
4054
451
  };
4055
452
  }
4056
453
 
454
+ function getDefaultExportFromCjs (x) {
455
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
456
+ }
457
+
4057
458
  var regeneratorRuntime$1 = {exports: {}};
4058
459
 
4059
460
  var _typeof = {exports: {}};
@@ -4413,7 +814,7 @@ var TestMessage = function TestMessage(_ref) {
4413
814
  setIsTestingTemplateRestricted = _useState2[1];
4414
815
  var _useFormikContext = formik.useFormikContext(),
4415
816
  values = _useFormikContext.values;
4416
- var _useTranslation = useTranslation(),
817
+ var _useTranslation = reactI18next.useTranslation(),
4417
818
  t = _useTranslation.t;
4418
819
  var handleTestValidation = /*#__PURE__*/function () {
4419
820
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
@@ -4494,7 +895,7 @@ var Form = function Form(_ref) {
4494
895
  isTestMessageLoading = _ref.isTestMessageLoading,
4495
896
  shouldIncludeTestTemplate = _ref.shouldIncludeTestTemplate,
4496
897
  templateVariables = _ref.templateVariables;
4497
- var _useTranslation = useTranslation(),
898
+ var _useTranslation = reactI18next.useTranslation(),
4498
899
  t = _useTranslation.t;
4499
900
  var editorRef = React.useRef(null);
4500
901
  var templateType = useTemplateStore(ramda.prop("templateType"));
@@ -4618,6 +1019,10 @@ function _arrayWithoutHoles(arr) {
4618
1019
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
4619
1020
  }
4620
1021
 
1022
+ function _iterableToArray(iter) {
1023
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1024
+ }
1025
+
4621
1026
  function _nonIterableSpread() {
4622
1027
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4623
1028
  }
@@ -4668,7 +1073,7 @@ var useTemplates = function useTemplates(_ref) {
4668
1073
  var pageIndex = pageProperties.index,
4669
1074
  pageSize = pageProperties.size;
4670
1075
  var templateParams = {
4671
- pageIndex: pageIndex,
1076
+ page: pageIndex,
4672
1077
  pageSize: pageSize,
4673
1078
  filters: JSON.stringify(filters),
4674
1079
  templateType: MESSAGE_TEMPLATES[type].value,
@@ -4713,7 +1118,7 @@ var List = function List(_ref) {
4713
1118
  addText = _ref.addText,
4714
1119
  isFilterApplied = _ref.isFilterApplied,
4715
1120
  ownerId = _ref.ownerId;
4716
- var _useTranslation = useTranslation(),
1121
+ var _useTranslation = reactI18next.useTranslation(),
4717
1122
  t = _useTranslation.t;
4718
1123
  var _useDeleteTemplate = useDeleteTemplate(ownerId),
4719
1124
  deleteTemplate = _useDeleteTemplate.mutate,
@@ -4768,7 +1173,7 @@ var List = function List(_ref) {
4768
1173
  })), /*#__PURE__*/React__default["default"].createElement(neetoui.Alert, {
4769
1174
  isOpen: isDelete,
4770
1175
  isSubmitting: isDeleting,
4771
- message: /*#__PURE__*/React__default["default"].createElement(Trans, {
1176
+ message: /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
4772
1177
  i18nKey: "neetoMessageTemplate.template.templateDeleteConfirmation",
4773
1178
  values: {
4774
1179
  name: template.name
@@ -4792,7 +1197,7 @@ var MessageTemplates = function MessageTemplates(_ref) {
4792
1197
  _ref$type = _ref.type,
4793
1198
  type = _ref$type === void 0 ? "" : _ref$type,
4794
1199
  _ref$handleSubmitTest = _ref.handleSubmitTestTemplate,
4795
- handleSubmitTestTemplate = _ref$handleSubmitTest === void 0 ? pure.noop : _ref$handleSubmitTest,
1200
+ handleSubmitTestTemplate = _ref$handleSubmitTest === void 0 ? neetoCist.noop : _ref$handleSubmitTest,
4796
1201
  _ref$isTestMessageLoa = _ref.isTestMessageLoading,
4797
1202
  isTestMessageLoading = _ref$isTestMessageLoa === void 0 ? false : _ref$isTestMessageLoa,
4798
1203
  _ref$shouldIncludeTes = _ref.shouldIncludeTestTemplate,
@@ -4834,7 +1239,7 @@ var MessageTemplates = function MessageTemplates(_ref) {
4834
1239
  addText = _MESSAGE_TEMPLATES$ty.addText,
4835
1240
  labelSingular = _MESSAGE_TEMPLATES$ty.labelSingular,
4836
1241
  editText = _MESSAGE_TEMPLATES$ty.editText;
4837
- var isFilterApplied = pure.isNotEmpty(filters) || pure.isNotEmpty(searchTerm);
1242
+ var isFilterApplied = neetoCist.isNotEmpty(filters) || neetoCist.isNotEmpty(searchTerm);
4838
1243
  var handleActionClick = function handleActionClick() {
4839
1244
  return setManageTemplatePane(_objectSpread$1(_objectSpread$1({}, MESSAGE_TEMPLATE_INITIAL_STATE), {}, {
4840
1245
  isOpen: true
@@ -4908,19 +1313,19 @@ var SEND_MESSAGE_INITIAL_VALUES = {
4908
1313
  body: ""
4909
1314
  };
4910
1315
  var EMAIL_MESSAGE_FORM_SCHEMA = yup__namespace.object().shape({
4911
- subject: yup__namespace.string().trim().required(t$1("neetoMessageTemplate.template.validation.subjectPresence")),
4912
- body: yup__namespace.string().test("body", t$1("neetoMessageTemplate.template.validation.bodyPresence"), function (value) {
1316
+ subject: yup__namespace.string().trim().required(i18next.t("neetoMessageTemplate.template.validation.subjectPresence")),
1317
+ body: yup__namespace.string().test("body", i18next.t("neetoMessageTemplate.template.validation.bodyPresence"), function (value) {
4913
1318
  return !!formatEditorContent(value);
4914
- }).required(t$1("neetoMessageTemplate.template.validation.bodyPresence"))
1319
+ }).required(i18next.t("neetoMessageTemplate.template.validation.bodyPresence"))
4915
1320
  });
4916
1321
  var SMS_MESSAGE_FORM_VALIDATION_SCHEMA = yup__namespace.object().shape({
4917
- body: yup__namespace.string().required(t$1("neetoMessageTemplate.template.validation.bodyPresence")).test("body", t$1("neetoMessageTemplate.template.validation.bodyPresence"), function (value) {
1322
+ body: yup__namespace.string().required(i18next.t("neetoMessageTemplate.template.validation.bodyPresence")).test("body", i18next.t("neetoMessageTemplate.template.validation.bodyPresence"), function (value) {
4918
1323
  return !!formatEditorContent(value);
4919
1324
  })
4920
1325
  });
4921
1326
  var WHATSAPP_MESSAGE_FORM_VALIDATIONS_SCHEMA = yup__namespace.object().shape({
4922
1327
  variableContents: yup__namespace.object().shape({
4923
- body: yup__namespace.array().of(yup__namespace.string().required(t$1("neetoMessageTemplate.template.validation.variablePresence")))
1328
+ body: yup__namespace.array().of(yup__namespace.string().required(i18next.t("neetoMessageTemplate.template.validation.variablePresence")))
4924
1329
  })
4925
1330
  });
4926
1331
 
@@ -4937,7 +1342,7 @@ var EmailAndSms = function EmailAndSms(_ref) {
4937
1342
  type = _ref.type,
4938
1343
  handleSubmit = _ref.handleSubmit;
4939
1344
  var editorRef = React.useRef(null);
4940
- var _useTranslation = useTranslation(),
1345
+ var _useTranslation = reactI18next.useTranslation(),
4941
1346
  t = _useTranslation.t;
4942
1347
  var isEmailTemplate = type === "email";
4943
1348
  var _ref2 = isEmailTemplate ? [SEND_MESSAGE_INITIAL_VALUES, EMAIL_MESSAGE_FORM_SCHEMA] : [ramda.pick(["body"], SEND_MESSAGE_INITIAL_VALUES), SMS_MESSAGE_FORM_VALIDATION_SCHEMA],
@@ -4964,7 +1369,7 @@ var EmailAndSms = function EmailAndSms(_ref) {
4964
1369
  var handleTemplateChange = function handleTemplateChange(value) {
4965
1370
  if (!value) return;
4966
1371
  var customFieldValues = ramda.omit(initialValueKeys, values);
4967
- var template = pure.findBy({
1372
+ var template = neetoCist.findBy({
4968
1373
  id: value === null || value === void 0 ? void 0 : value.value
4969
1374
  }, templates);
4970
1375
  setValues(_objectSpread(_objectSpread({}, template), customFieldValues));
@@ -4975,7 +1380,7 @@ var EmailAndSms = function EmailAndSms(_ref) {
4975
1380
  isSearchable: true,
4976
1381
  innerRef: setInitialFocusField,
4977
1382
  label: t("neetoMessageTemplate.template.title"),
4978
- options: pure.renameKeys({
1383
+ options: neetoCist.renameKeys({
4979
1384
  name: "label",
4980
1385
  id: "value"
4981
1386
  }, templates),
@@ -5016,7 +1421,7 @@ var Whatsapp = function Whatsapp(_ref) {
5016
1421
  var templates = _ref.templates,
5017
1422
  onClose = _ref.onClose,
5018
1423
  handleSubmit = _ref.handleSubmit;
5019
- var _useTranslation = useTranslation(),
1424
+ var _useTranslation = reactI18next.useTranslation(),
5020
1425
  t = _useTranslation.t;
5021
1426
  var getInitialVariableComponents = function getInitialVariableComponents(variables) {
5022
1427
  var initialComponents = {};
@@ -5028,7 +1433,7 @@ var Whatsapp = function Whatsapp(_ref) {
5028
1433
  return initialComponents;
5029
1434
  };
5030
1435
  var getTemplateMessage = function getTemplateMessage(components) {
5031
- return pure.nullSafe(ramda.pluck)("text", components).join("\n");
1436
+ return neetoCist.nullSafe(ramda.pluck)("text", components).join("\n");
5032
1437
  };
5033
1438
  if (ramda.isEmpty(templates)) {
5034
1439
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, null, t("neetoMessageTemplate.template.emptyState", {
@@ -5064,7 +1469,7 @@ var Whatsapp = function Whatsapp(_ref) {
5064
1469
  setValues = _ref3.setValues;
5065
1470
  var handleTemplateChange = function handleTemplateChange(value) {
5066
1471
  if (!value) return;
5067
- var template = pure.findBy({
1472
+ var template = neetoCist.findBy({
5068
1473
  id: value === null || value === void 0 ? void 0 : value.value
5069
1474
  }, templates);
5070
1475
  setValues({
@@ -5081,7 +1486,7 @@ var Whatsapp = function Whatsapp(_ref) {
5081
1486
  defaultValue: initialFormValues.selectedTemplate,
5082
1487
  label: t("neetoMessageTemplate.template.title"),
5083
1488
  name: "selectedTemplate",
5084
- options: pure.renameKeys({
1489
+ options: neetoCist.renameKeys({
5085
1490
  name: "label",
5086
1491
  id: "value"
5087
1492
  }, templates),
@@ -5091,14 +1496,14 @@ var Whatsapp = function Whatsapp(_ref) {
5091
1496
  nakedTextarea: true,
5092
1497
  label: t("neetoMessageTemplate.template.preview"),
5093
1498
  value: values.templateMessage
5094
- }), pure.isNotEmpty(values.variableContents) && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, Object.keys(values.variableContents).map(function (group) {
1499
+ }), neetoCist.isNotEmpty(values.variableContents) && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, Object.keys(values.variableContents).map(function (group) {
5095
1500
  return /*#__PURE__*/React__default["default"].createElement("div", {
5096
1501
  className: "flex flex-col gap-y-2",
5097
1502
  key: group
5098
1503
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
5099
1504
  style: "h4"
5100
1505
  }, t("neetoMessageTemplate.template.resolveVariable", {
5101
- type: pure.capitalize(group)
1506
+ type: neetoCist.capitalize(group)
5102
1507
  })), values.variableContents[group].map(function (_, index) {
5103
1508
  return /*#__PURE__*/React__default["default"].createElement("div", {
5104
1509
  key: "".concat(group, "-").concat(index)
@@ -5131,9 +1536,9 @@ var SendMessagePane = function SendMessagePane(_ref) {
5131
1536
  _ref$type = _ref.type,
5132
1537
  type = _ref$type === void 0 ? "" : _ref$type,
5133
1538
  _ref$handleSubmit = _ref.handleSubmit,
5134
- handleSubmit = _ref$handleSubmit === void 0 ? pure.noop : _ref$handleSubmit,
1539
+ handleSubmit = _ref$handleSubmit === void 0 ? neetoCist.noop : _ref$handleSubmit,
5135
1540
  _ref$onClose = _ref.onClose,
5136
- onClose = _ref$onClose === void 0 ? pure.noop : _ref$onClose,
1541
+ onClose = _ref$onClose === void 0 ? neetoCist.noop : _ref$onClose,
5137
1542
  _ref$customFields = _ref.customFields,
5138
1543
  customFields = _ref$customFields === void 0 ? null : _ref$customFields,
5139
1544
  _ref$customFieldsInit = _ref.customFieldsInitialValues,
@@ -5144,7 +1549,7 @@ var SendMessagePane = function SendMessagePane(_ref) {
5144
1549
  templateVariables = _ref$templateVariable === void 0 ? {} : _ref$templateVariable,
5145
1550
  _ref$ownerId = _ref.ownerId,
5146
1551
  ownerId = _ref$ownerId === void 0 ? "" : _ref$ownerId;
5147
- var _useTranslation = useTranslation(),
1552
+ var _useTranslation = reactI18next.useTranslation(),
5148
1553
  t = _useTranslation.t;
5149
1554
  var initialFocusField = React.useRef();
5150
1555
  var setInitialFocusField = function setInitialFocusField(fieldRef) {