PageSourceSearch

https://www.jdalmauassessors.com/assets/js/i18next.js

js jdalmauassessors.com collected 2026-10-06 13:05:30 UTC 69,240 bytes, 2,112 lines download raw bytes

vendor: 9,661 bytes, lines 1-409
1(function (global, factory) {
2	typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3	typeof define === 'function' && define.amd ? define(factory) :
4	(global.i18next = factory());
5}(this, (function () { 'use strict';
6
7var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
8  return typeof obj;
9} : function (obj) {
10  return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
11};
12
13
14
15
16
17
18
19
20
21
22
23var classCallCheck = function (instance, Constructor) {
24  if (!(instance instanceof Constructor)) {
25    throw new TypeError("Cannot call a class as a function");
26  }
27};
28
29
30
31
32
33
34
35
36
37var _extends = Object.assign || function (target) {
38  for (var i = 1; i < arguments.length; i++) {
39    var source = arguments[i];
40
41    for (var key in source) {
42      if (Object.prototype.hasOwnProperty.call(source, key)) {
43        target[key] = source[key];
44      }
45    }
46  }
47
48  return target;
49};
50
51
52
53var inherits = function (subClass, superClass) {
54  if (typeof superClass !== "function" && superClass !== null) {
55    throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
56  }
57
58  subClass.prototype = Object.create(superClass && superClass.prototype, {
59    constructor: {
60      value: subClass,
61      enumerable: false,
62      writable: true,
63      configurable: true
64    }
65  });
66  if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
67};
68
69
70
71
72
73
74
75
76
77
78
79var possibleConstructorReturn = function (self, call) {
80  if (!self) {
81    throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
82  }
83
84  return call && (typeof call === "object" || typeof call === "function") ? call : self;
85};
86
87
88
89
90
91var slicedToArray = function () {
92  function sliceIterator(arr, i) {
93    var _arr = [];
94    var _n = true;
95    var _d = false;
96    var _e = undefined;
97
98    try {
99      for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
100        _arr.push(_s.value);
101
102        if (i && _arr.length === i) break;
103      }
104    } catch (err) {
105      _d = true;
106      _e = err;
107    } finally {
108      try {
109        if (!_n && _i["return"]) _i["return"]();
110      } finally {
111        if (_d) throw _e;
112      }
113    }
114
115    return _arr;
116  }
117
118  return function (arr, i) {
119    if (Array.isArray(arr)) {
120      return arr;
121    } else if (Symbol.iterator in Object(arr)) {
122      return sliceIterator(arr, i);
123    } else {
124      throw new TypeError("Invalid attempt to destructure non-iterable instance");
125    }
126  };
127}();
128
129
130
131
132
133
134
135
136
137
138
139
140
141var toConsumableArray = function (arr) {
142  if (Array.isArray(arr)) {
143    for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
144
145    return arr2;
146  } else {
147    return Array.from(arr);
148  }
149};
150
151var consoleLogger = {
152  type: 'logger',
153
154  log: function log(args) {
155    this.output('log', args);
156  },
157  warn: function warn(args) {
158    this.output('warn', args);
159  },
160  error: function error(args) {
161    this.output('error', args);
162  },
163  output: function output(type, args) {
164    var _console;
165
166    /* eslint no-console: 0 */
167    if (console && console[type]) (_console = console)[type].apply(_console, toConsumableArray(args));
168  }
169};
170
171var Logger = function () {
172  function Logger(concreteLogger) {
173    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
174    classCallCheck(this, Logger);
175
176    this.init(concreteLogger, options);
177  }
178
179  Logger.prototype.init = function init(concreteLogger) {
180    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
181
182    this.prefix = options.prefix || 'i18next:';
183    this.logger = concreteLogger || consoleLogger;
184    this.options = options;
185    this.debug = options.debug;
186  };
187
188  Logger.prototype.setDebug = function setDebug(bool) {
189    this.debug = bool;
190  };
191
192  Logger.prototype.log = function log() {
193    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
194      args[_key] = arguments[_key];
195    }
196
197    return this.forward(args, 'log', '', true);
198  };
199
200  Logger.prototype.warn = function warn() {
201    for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
202      args[_key2] = arguments[_key2];
203    }
204
205    return this.forward(args, 'warn', '', true);
206  };
207
208  Logger.prototype.error = function error() {
209    for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
210      args[_key3] = arguments[_key3];
211    }
212
213    return this.forward(args, 'error', '');
214  };
215
216  Logger.prototype.deprecate = function deprecate() {
217    for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
218      args[_key4] = arguments[_key4];
219    }
220
221    return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
222  };
223
224  Logger.prototype.forward = function forward(args, lvl, prefix, debugOnly) {
225    if (debugOnly && !this.debug) return null;
226    if (typeof args[0] === 'string') args[0] = '' + prefix + this.prefix + ' ' + args[0];
227    return this.logger[lvl](args);
228  };
229
230  Logger.prototype.create = function create(moduleName) {
231    return new Logger(this.logger, _extends({ prefix: this.prefix + ':' + moduleName + ':' }, this.options));
232  };
233
234  return Logger;
235}();
236
237var baseLogger = new Logger();
238
239var EventEmitter = function () {
240  function EventEmitter() {
241    classCallCheck(this, EventEmitter);
242
243    this.observers = {};
244  }
245
246  EventEmitter.prototype.on = function on(events, listener) {
247    var _this = this;
248
249    events.split(' ').forEach(function (event) {
250      _this.observers[event] = _this.observers[event] || [];
251      _this.observers[event].push(listener);
252    });
253  };
254
255  EventEmitter.prototype.off = function off(event, listener) {
256    var _this2 = this;
257
258    if (!this.observers[event]) {
259      return;
260    }
261
262    this.observers[event].forEach(function () {
263      if (!listener) {
264        delete _this2.observers[event];
265      } else {
266        var index = _this2.observers[event].indexOf(listener);
267        if (index > -1) {
268          _this2.observers[event].splice(index, 1);
269        }
270      }
271    });
272  };
273
274  EventEmitter.prototype.emit = function emit(event) {
275    for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
276      args[_key - 1] = arguments[_key];
277    }
278
279    if (this.observers[event]) {
280      var cloned = [].concat(this.observers[event]);
281      cloned.forEach(function (observer) {
282        observer.apply(undefined, args);
283      });
284    }
285
286    if (this.observers['*']) {
287      var _cloned = [].concat(this.observers['*']);
288      _cloned.forEach(function (observer) {
289        var _ref;
290
291        observer.apply(observer, (_ref = [event]).concat.apply(_ref, args));
292      });
293    }
294  };
295
296  return EventEmitter;
297}();
298
299function makeString(object) {
300  if (object == null) return '';
301  /* eslint prefer-template: 0 */
302  return '' + object;
303}
304
305function copy(a, s, t) {
306  a.forEach(function (m) {
307    if (s[m]) t[m] = s[m];
308  });
309}
310
311function getLastOfPath(object, path, Empty) {
312  function cleanKey(key) {
313    return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
314  }
315
316  function canNotTraverseDeeper() {
317    return !object || typeof object === 'string';
318  }
319
320  var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
321  while (stack.length > 1) {
322    if (canNotTraverseDeeper()) return {};
323
324    var key = cleanKey(stack.shift());
325    if (!object[key] && Empty) object[key] = new Empty();
326    object = object[key];
327  }
328
329  if (canNotTraverseDeeper()) return {};
330  return {
331    obj: object,
332    k: cleanKey(stack.shift())
333  };
334}
335
336function setPath(object, path, newValue) {
337  var _getLastOfPath = getLastOfPath(object, path, Object),
338      obj = _getLastOfPath.obj,
339      k = _getLastOfPath.k;
340
341  obj[k] = newValue;
342}
343
344function pushPath(object, path, newValue, concat) {
345  var _getLastOfPath2 = getLastOfPath(object, path, Object),
346      obj = _getLastOfPath2.obj,
347      k = _getLastOfPath2.k;
348
349  obj[k] = obj[k] || [];
350  if (concat) obj[k] = obj[k].concat(newValue);
351  if (!concat) obj[k].push(newValue);
352}
353
354function getPath(object, path) {
355  var _getLastOfPath3 = getLastOfPath(object, path),
356      obj = _getLastOfPath3.obj,
357      k = _getLastOfPath3.k;
358
359  if (!obj) return undefined;
360  return obj[k];
361}
362
363function deepExtend(target, source, overwrite) {
364  /* eslint no-restricted-syntax: 0 */
365  for (var prop in source) {
366    if (prop in target) {
367      // If we reached a leaf string in target or source then replace with source or skip depending on the 'overwrite' switch
368      if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
369        if (overwrite) target[prop] = source[prop];
370      } else {
371        deepExtend(target[prop], source[prop], overwrite);
372      }
373    } else {
374      target[prop] = source[prop];
375    }
376  }
377  return target;
378}
379
380function regexEscape(str) {
381  /* eslint no-useless-escape: 0 */
382  return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
383}
384
385/* eslint-disable */
386var _entityMap = {
387  "&": "&amp;",
388  "<": "&lt;",
389  ">": "&gt;",
390  '"': '&quot;',
391  "'": '&#39;',
392  "/": '&#x2F;'
393};
394/* eslint-enable */
395
396function escape(data) {
397  if (typeof data === 'string') {
398    return data.replace(/[&<>"'\/]/g, function (s) {
399      return _entityMap[s];
400    });
401  }
402
403  return data;
404}
405
406var ResourceStore = function (_EventEmitter) {
407  inherits(ResourceStore, _EventEmitter);
408
409  function ResourceStore(
409data) {
410    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { ns: ['translation'], defaultNS: 'translation' };
411    classCallCheck(this, ResourceStore);
412
413    var _this = possibleConstructorReturn(this, _EventEmitter.call(this));
414
415    _this.data = data || {};
416    _this.options = options;
417    return _this;
418  }
419
420  ResourceStore.prototype.addNamespaces = function addNamespaces(ns) {
421    if (this.options.ns.indexOf(ns) < 0) {
422      this.options.ns.push(ns);
423    }
424  };
425
426  ResourceStore.prototype.removeNamespaces = function removeNamespaces(ns) {
427    var index = this.options.ns.indexOf(ns);
428    if (index > -1) {
429      this.options.ns.splice(index, 1);
430    }
431  };
432
433  ResourceStore.prototype.getResource = function getResource(lng, ns, key) {
434    var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
435
436    var keySeparator = options.keySeparator || this.options.keySeparator;
437    if (keySeparator === undefined) keySeparator = '.';
438
439    var path = [lng, ns];
440    if (key && typeof key !== 'string') path = path.concat(key);
441    if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
442
443    if (lng.indexOf('.') > -1) {
444      path = lng.split('.');
445    }
446
447    return getPath(this.data, path);
448  };
449
450  ResourceStore.prototype.addResource = function addResource(lng, ns, key, value) {
451    var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : { silent: false };
452
453    var keySeparator = this.options.keySeparator;
454    if (keySeparator === undefined) keySeparator = '.';
455
456    var path = [lng, ns];
457    if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
458
459    if (lng.indexOf('.') > -1) {
460      path = lng.split('.');
461      value = ns;
462      ns = path[1];
463    }
464
465    this.addNamespaces(ns);
466
467    setPath(this.data, path, value);
468
469    if (!options.silent) this.emit('added', lng, ns, key, value);
470  };
471
472  ResourceStore.prototype.addResources = function addResources(lng, ns, resources) {
473    var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : { silent: false };
474
475    /* eslint no-restricted-syntax: 0 */
476    for (var m in resources) {
477      if (typeof resources[m] === 'string') this.addResource(lng, ns, m, resources[m], { silent: true });
478    }
479    if (!options.silent) this.emit('added', lng, ns, resources);
480  };
481
482  ResourceStore.prototype.addResourceBundle = function addResourceBundle(lng, ns, resources, deep, overwrite) {
483    var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : { silent: false };
484
485    var path = [lng, ns];
486    if (lng.indexOf('.') > -1) {
487      path = lng.split('.');
488      deep = resources;
489      resources = ns;
490      ns = path[1];
491    }
492
493    this.addNamespaces(ns);
494
495    var pack = getPath(this.data, path) || {};
496
497    if (deep) {
498      deepExtend(pack, resources, overwrite);
499    } else {
500      pack = _extends({}, pack, resources);
501    }
502
503    setPath(this.data, path, pack);
504
505    if (!options.silent) this.emit('added', lng, ns, resources);
506  };
507
508  ResourceStore.prototype.removeResourceBundle = function removeResourceBundle(lng, ns) {
509    if (this.hasResourceBundle(lng, ns)) {
510      delete this.data[lng][ns];
511    }
512    this.removeNamespaces(ns);
513
514    this.emit('removed', lng, ns);
515  };
516
517  ResourceStore.prototype.hasResourceBundle = function hasResourceBundle(lng, ns) {
518    return this.getResource(lng, ns) !== undefined;
519  };
520
521  ResourceStore.prototype.getResourceBundle = function getResourceBundle(lng, ns) {
522    if (!ns) ns = this.options.defaultNS;
523
524    // COMPATIBILITY: remove extend in v2.1.0
525    if (this.options.compatibilityAPI === 'v1') return _extends({}, this.getResource(lng, ns));
526
527    return this.getResource(lng, ns);
528  };
529
530  ResourceStore.prototype.toJSON = function toJSON() {
531    return this.data;
532  };
533
534  return ResourceStore;
535}(EventEmitter);
536
537var postProcessor = {
538
539  processors: {},
540
541  addPostProcessor: function addPostProcessor(module) {
542    this.processors[module.name] = module;
543  },
544  handle: function handle(processors, value, key, options, translator) {
545    var _this = this;
546
547    processors.forEach(function (processor) {
548      if (_this.processors[processor]) value = _this.processors[processor].process(value, key, options, translator);
549    });
550
551    return value;
552  }
553};
554
555var Translator = function (_EventEmitter) {
556  inherits(Translator, _EventEmitter);
557
558  function Translator(services) {
559    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
560    classCallCheck(this, Translator);
561
562    var _this = possibleConstructorReturn(this, _EventEmitter.call(this));
563
564    copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector'], services, _this);
565
566    _this.options = options;
567    _this.logger = baseLogger.create('translator');
568    return _this;
569  }
570
571  Translator.prototype.changeLanguage = function changeLanguage(lng) {
572    if (lng) this.language = lng;
573  };
574
575  Translator.prototype.exists = function exists(key) {
576    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { interpolation: {} };
577
578    var resolved = this.resolve(key, options);
579    return resolved && resolved.res !== undefined;
580  };
581
582  Translator.prototype.extractFromKey = function extractFromKey(key, options) {
583    var nsSeparator = options.nsSeparator || this.options.nsSeparator;
584    if (nsSeparator === undefined) nsSeparator = ':';
585    var keySeparator = options.keySeparator || this.options.keySeparator || '.';
586
587    var namespaces = options.ns || this.options.defaultNS;
588    if (nsSeparator && key.indexOf(nsSeparator) > -1) {
589      var parts = key.split(nsSeparator);
590      if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
591      key = parts.join(keySeparator);
592    }
593    if (typeof namespaces === 'string') namespaces = [namespaces];
594
595    return {
596      key: key,
597      namespaces: namespaces
598    };
599  };
600
601  Translator.prototype.translate = function translate(keys, options) {
602    var _this2 = this;
603
604    if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object' && this.options.overloadTranslationOptionHandler) {
605      /* eslint prefer-rest-params: 0 */
606      options = this.options.overloadTranslationOptionHandler(arguments);
607    }
608    if (!options) options = {};
609
610    // non valid keys handling
611    if (keys === undefined || keys === null || keys === '') return '';
612    if (typeof keys === 'number') keys = String(keys);
613    if (typeof keys === 'string') keys = [keys];
614
615    // separators
616    var keySeparator = options.keySeparator || this.options.keySeparator || '.';
617
618    // get namespace(s)
619
620    var _extractFromKey = this.extractFromKey(keys[keys.length - 1], options),
621        key = _extractFromKey.key,
622        namespaces = _extractFromKey.namespaces;
623
624    var namespace = namespaces[namespaces.length - 1];
625
626    // return key on CIMode
627    var lng = options.lng || this.language;
628    var appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
629    if (lng && lng.toLowerCase() === 'cimode') {
630      if (appendNamespaceToCIMode) {
631        var nsSeparator = options.nsSeparator || this.options.nsSeparator;
632        return namespace + nsSeparator + key;
633      }
634
635      return key;
636    }
637
638    // resolve from store
639    var resolved = this.resolve(keys, options);
640    var res = resolved && resolved.res;
641    var resUsedKey = resolved && resolved.usedKey || key;
642
643    var resType = Object.prototype.toString.apply(res);
644    var noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
645    var joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
646
647    // object
648    var handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
649    if (res && handleAsObject && noObject.indexOf(resType) < 0 && !(joinArrays && resType === '[object Array]')) {
650      if (!options.returnObjects && !this.options.returnObjects) {
651        this.logger.warn('accessing an object - but returnObjects options is not enabled!');
652        return this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, options) : 'key \'' + key + ' (' + this.language + ')\' returned an object instead of string.';
653      }
654
655      // if we got a separator we loop over children - else we just return object as is
656      // as having it set to false means no hierarchy so no lookup for nested values
657      if (options.keySeparator || this.options.keySeparator) {
658        var copy$$1 = resType === '[object Array]' ? [] : {}; // apply child translation on a copy
659
660        /* eslint no-restricted-syntax: 0 */
661        for (var m in res) {
662          if (Object.prototype.hasOwnProperty.call(res, m)) {
663            var deepKey = '' + resUsedKey + keySeparator + m;
664            copy$$1[m] = this.translate(deepKey, _extends({}
664, options, { joinArrays: false, ns: namespaces }));
665            if (copy$$1[m] === deepKey) copy$$1[m] = res[m]; // if nothing found use orginal value as fallback
666          }
667        }
668        res = copy$$1;
669      }
670    } else if (joinArrays && resType === '[object Array]') {
671      // array special treatment
672      res = res.join(joinArrays);
673      if (res) res = this.extendTranslation(res, keys, options);
674    } else {
675      // string, empty or null
676      var usedDefault = false;
677      var usedKey = false;
678
679      // fallback value
680      if (!this.isValidLookup(res) && options.defaultValue !== undefined) {
681        usedDefault = true;
682        res = options.defaultValue;
683      }
684      if (!this.isValidLookup(res)) {
685        usedKey = true;
686        res = key;
687      }
688
689      // save missing
690      var updateMissing = options.defaultValue && options.defaultValue !== res && this.options.updateMissing;
691      if (usedKey || usedDefault || updateMissing) {
692        this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? options.defaultValue : res);
693
694        var lngs = [];
695        var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
696        if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
697          for (var i = 0; i < fallbackLngs.length; i++) {
698            lngs.push(fallbackLngs[i]);
699          }
700        } else if (this.options.saveMissingTo === 'all') {
701          lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
702        } else {
703          lngs.push(options.lng || this.language);
704        }
705
706        var send = function send(l, k) {
707          if (_this2.options.missingKeyHandler) {
708            _this2.options.missingKeyHandler(l, namespace, k, updateMissing ? options.defaultValue : res, updateMissing, options);
709          } else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {
710            _this2.backendConnector.saveMissing(l, namespace, k, updateMissing ? options.defaultValue : res, updateMissing, options);
711          }
712          _this2.emit('missingKey', l, namespace, k, res);
713        };
714
715        if (this.options.saveMissing) {
716          if (this.options.saveMissingPlurals && options.count) {
717            lngs.forEach(function (l) {
718              var plurals = _this2.pluralResolver.getPluralFormsOfKey(l, key);
719
720              plurals.forEach(function (p) {
721                return send([l], p);
722              });
723            });
724          } else {
725            send(lngs, key);
726          }
727        }
728      }
729
730      // extend
731      res = this.extendTranslation(res, keys, options);
732
733      // append namespace if still key
734      if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = namespace + ':' + key;
735
736      // parseMissingKeyHandler
737      if (usedKey && this.options.parseMissingKeyHandler) res = this.options.parseMissingKeyHandler(res);
738    }
739
740    // return
741    return res;
742  };
743
744  Translator.prototype.extendTranslation = function extendTranslation(res, key, options) {
745    var _this3 = this;
746
747    if (options.interpolation) this.interpolator.init(_extends({}, options, { interpolation: _extends({}, this.options.interpolation, options.interpolation) }));
748
749    // interpolate
750    var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
751    if (this.options.interpolation.defaultVariables) data = _extends({}, this.options.interpolation.defaultVariables, data);
752    res = this.interpolator.interpolate(res, data, options.lng || this.language);
753
754    // nesting
755    if (options.nest !== false) res = this.interpolator.nest(res, function () {
756      return _this3.translate.apply(_this3, arguments);
757    }, options);
758
759    if (options.interpolation) this.interpolator.reset();
760
761    // post process
762    var postProcess = options.postProcess || this.options.postProcess;
763    var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
764
765    if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
766      res = postProcessor.handle(postProcessorNames, res, key, options, this);
767    }
768
769    return res;
770  };
771
772  Translator.prototype.resolve = function resolve(keys) {
773    var _this4 = this;
774
775    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
776
777    var found = void 0;
778    var usedKey = void 0;
779
780    if (typeof keys === 'string') keys = [keys];
781
782    // forEach possible key
783    keys.forEach(function (k) {
784      if (_this4.isValidLookup(found)) return;
785      var extracted = _this4.extractFromKey(k, options);
786      var key = extracted.key;
787      usedKey = key;
788      var namespaces = extracted.namespaces;
789      if (_this4.options.fallbackNS) namespaces = namespaces.concat(_this4.options.fallbackNS);
790
791      var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
792      var needsContextHandling = options.context !== undefined && typeof options.context === 'string' && options.context !== '';
793
794      var codes = options.lngs ? options.lngs : _this4.languageUtils.toResolveHierarchy(options.lng || _this4.language);
795
vendor: 14,248 bytes, lines 796-1175
796      namespaces.forEach(function (ns) {
797        if (_this4.isValidLookup(found)) return;
798
799        codes.forEach(function (code) {
800          if (_this4.isValidLookup(found)) return;
801
802          var finalKey = key;
803          var finalKeys = [finalKey];
804
805          var pluralSuffix = void 0;
806          if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count);
807
808          // fallback for plural if context not found
809          if (needsPluralHandling && needsContextHandling) finalKeys.push(finalKey + pluralSuffix);
810
811          // get key for context if needed
812          if (needsContextHandling) finalKeys.push(finalKey += '' + _this4.options.contextSeparator + options.context);
813
814          // get key for plural if needed
815          if (needsPluralHandling) finalKeys.push(finalKey += pluralSuffix);
816
817          // iterate over finalKeys starting with most specific pluralkey (-> contextkey only) -> singularkey only
818          var possibleKey = void 0;
819          /* eslint no-cond-assign: 0 */
820          while (possibleKey = finalKeys.pop()) {
821            if (!_this4.isValidLookup(found)) {
822              found = _this4.getResource(code, ns, possibleKey, options);
823            }
824          }
825        });
826      });
827    });
828
829    return { res: found, usedKey: usedKey };
830  };
831
832  Translator.prototype.isValidLookup = function isValidLookup(res) {
833    return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
834  };
835
836  Translator.prototype.getResource = function getResource(code, ns, key) {
837    var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
838
839    return this.resourceStore.getResource(code, ns, key, options);
840  };
841
842  return Translator;
843}(EventEmitter);
844
845function capitalize(string) {
846  return string.charAt(0).toUpperCase() + string.slice(1);
847}
848
849var LanguageUtil = function () {
850  function LanguageUtil(options) {
851    classCallCheck(this, LanguageUtil);
852
853    this.options = options;
854
855    this.whitelist = this.options.whitelist || false;
856    this.logger = baseLogger.create('languageUtils');
857  }
858
859  LanguageUtil.prototype.getScriptPartFromCode = function getScriptPartFromCode(code) {
860    if (!code || code.indexOf('-') < 0) return null;
861
862    var p = code.split('-');
863    if (p.length === 2) return null;
864    p.pop();
865    return this.formatLanguageCode(p.join('-'));
866  };
867
868  LanguageUtil.prototype.getLanguagePartFromCode = function getLanguagePartFromCode(code) {
869    if (!code || code.indexOf('-') < 0) return code;
870
871    var p = code.split('-');
872    return this.formatLanguageCode(p[0]);
873  };
874
875  LanguageUtil.prototype.formatLanguageCode = function formatLanguageCode(code) {
876    // http://www.iana.org/assignments/language-tags/language-tags.xhtml
877    if (typeof code === 'string' && code.indexOf('-') > -1) {
878      var specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
879      var p = code.split('-');
880
881      if (this.options.lowerCaseLng) {
882        p = p.map(function (part) {
883          return part.toLowerCase();
884        });
885      } else if (p.length === 2) {
886        p[0] = p[0].toLowerCase();
887        p[1] = p[1].toUpperCase();
888
889        if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
890      } else if (p.length === 3) {
891        p[0] = p[0].toLowerCase();
892
893        // if lenght 2 guess it's a country
894        if (p[1].length === 2) p[1] = p[1].toUpperCase();
895        if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
896
897        if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
898        if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
899      }
900
901      return p.join('-');
902    }
903
904    return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
905  };
906
907  LanguageUtil.prototype.isWhitelisted = function isWhitelisted(code) {
908    if (this.options.load === 'languageOnly' || this.options.nonExplicitWhitelist) {
909      code = this.getLanguagePartFromCode(code);
910    }
911    return !this.whitelist || !this.whitelist.length || this.whitelist.indexOf(code) > -1;
912  };
913
914  LanguageUtil.prototype.getFallbackCodes = function getFallbackCodes(fallbacks, code) {
915    if (!fallbacks) return [];
916    if (typeof fallbacks === 'string') fallbacks = [fallbacks];
917    if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;
918
919    if (!code) return fallbacks.default || [];
920
921    // asume we have an object defining fallbacks
922    var found = fallbacks[code];
923    if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
924    if (!found) found = fallbacks[this.formatLanguageCode(code)];
925    if (!found) found = fallbacks.default;
926
927    return found || [];
928  };
929
930  LanguageUtil.prototype.toResolveHierarchy = function toResolveHierarchy(code, fallbackCode) {
931    var _this = this;
932
933    var fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
934
935    var codes = [];
936    var addCode = function addCode(c) {
937      if (!c) return;
938      if (_this.isWhitelisted(c)) {
939        codes.push(c);
940      } else {
941        _this.logger.warn('rejecting non-whitelisted language code: ' + c);
942      }
943    };
944
945    if (typeof code === 'string' && code.indexOf('-') > -1) {
946      if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
947      if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
948      if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
949    } else if (typeof code === 'string') {
950      addCode(this.formatLanguageCode(code));
951    }
952
953    fallbackCodes.forEach(function (fc) {
954      if (codes.indexOf(fc) < 0) addCode(_this.formatLanguageCode(fc));
955    });
956
957    return codes;
958  };
959
960  return LanguageUtil;
961}();
962
963// definition http://translate.sourceforge.net/wiki/l10n/pluralforms
964/* eslint-disable */
965var sets = [{ lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'ti', 'tr', 'uz', 'wa'], nr: [1, 2], fc: 1 }, { lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'he', 'hi', 'hu', 'hy', 'ia', 'it', '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'], nr: [1, 2], fc: 2 }, { lngs: ['ay', 'bo', 'cgg', 'fa', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'], nr: [1], fc: 3 }, { lngs: ['be', 'bs', 'dz', 'hr', 'ru', 'sr', 'uk'], nr: [1, 2, 5], fc: 4 }, { lngs: ['ar'], nr: [0, 1, 2, 3, 11, 100], fc: 5 }, { lngs: ['cs', 'sk'], nr: [1, 2, 5], fc: 6 }, { lngs: ['csb', 'pl'], nr: [1, 2, 5], fc: 7 }, { lngs: ['cy'], nr: [1, 2, 3, 8], fc: 8 }, { lngs: ['fr'], nr: [1, 2], fc: 9 }, { lngs: ['ga'], nr: [1, 2, 3, 7, 11], fc: 10 }, { lngs: ['gd'], nr: [1, 2, 3, 20], fc: 11 }, { lngs: ['is'], nr: [1, 2], fc: 12 }, { lngs: ['jv'], nr: [0, 1], fc: 13 }, { lngs: ['kw'], nr: [1, 2, 3, 4], fc: 14 }, { lngs: ['lt'], nr: [1, 2, 10], fc: 15 }, { lngs: ['lv'], nr: [1, 2, 0], fc: 16 }, { lngs: ['mk'], nr: [1, 2], fc: 17 }, { lngs: ['mnk'], nr: [0, 1, 2], fc: 18 }, { lngs: ['mt'], nr: [1, 2, 11, 20], fc: 19 }, { lngs: ['or'], nr: [2, 1], fc: 2 }, { lngs: ['ro'], nr: [1, 2, 20], fc: 20 }, { lngs: ['sl'], nr: [5, 1, 2, 3], fc: 21 }];
966
967var _rulesPluralsTypes = {
968  1: function _(n) {
969    return Number(n > 1);
970  },
971  2: function _(n) {
972    return Number(n != 1);
973  },
974  3: function _(n) {
975    return 0;
976  },
977  4: function _(n) {
978    return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
979  },
980  5: function _(n) {
981    return Number(n === 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
982  },
983  6: function _(n) {
984    return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
985  },
986  7: function _(n) {
987    return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
988  },
989  8: function _(n) {
990    return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
991  },
992  9: function _(n) {
993    return Number(n >= 2);
994  },
995  10: function _(n) {
996    return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
997  },
998  11: function _(n) {
999    return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
1000  },
1001  12: function _(n) {
1002    return Number(n % 10 != 1 || n % 100 == 11);
1003  },
1004  13: function _(n) {
1005    return Number(n !== 0);
1006  },
1007  14: function _(n) {
1008    return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
1009  },
1010  15: function _(n) {
1011    return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1012  },
1013  16: function _(n) {
1014    return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
1015  },
1016  17: function _(n) {
1017    return Number(n == 1 || n % 10 == 1 ? 0 : 1);
1018  },
1019  18: function _(n) {
1020    return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
1021  },
1022  19: function _(n) {
1023    return Number(n == 1 ? 0 : n === 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
1024  },
1025  20: function _(n) {
1026    return Number(n == 1 ? 0 : n === 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
1027  },
1028  21: function _(n) {
1029    return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
1030  }
1031};
1032/* eslint-enable */
1033
1034function createRules() {
1035  var rules = {};
1036  sets.forEach(function (set$$1) {
1037    set$$1.lngs.forEach(function (l) {
1038      rules[l] = {
1039        numbers: set$$1.nr,
1040        plurals: _rulesPluralsTypes[set$$1.fc]
1041      };
1042    });
1043  });
1044  return rules;
1045}
1046
1047var PluralResolver = function () {
1048  function PluralResolver(languageUtils) {
1049    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1050    classCallCheck(this, PluralResolver);
1051
1052    this.languageUtils = languageUtils;
1053    this.options = options;
1054
1055    this.logger = baseLogger.create('pluralResolver');
1056
1057    this.rules = createRules();
1058  }
1059
1060  PluralResolver.prototype.addRule = function addRule(lng, obj) {
1061    this.rules[lng] = obj;
1062  };
1063
1064  PluralResolver.prototype.getRule = function getRule(code) {
1065    return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
1066  };
1067
1068  PluralResolver.prototype.needsPlural = function needsPlural(code) {
1069    var rule = this.getRule(code);
1070
1071    return rule && rule.numbers.length > 1;
1072  };
1073
1074  PluralResolver.prototype.getPluralFormsOfKey = function getPluralFormsOfKey(code, key) {
1075    var _this = this;
1076
1077    var ret = [];
1078
1079    var rule = this.getRule(code);
1080
1081    if (!rule) return ret;
1082
1083    rule.numbers.forEach(function (n) {
1084      var suffix = _this.getSuffix(code, n);
1085      ret.push('' + key + suffix);
1086    });
1087
1088    return ret;
1089  };
1090
1091  PluralResolver.prototype.getSuffix = function getSuffix(code, count) {
1092    var _this2 = this;
1093
1094    var rule = this.getRule(code);
1095
1096    if (rule) {
1097      // if (rule.numbers.length === 1) return ''; // only singular
1098
1099      var idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
1100      var suffix = rule.numbers[idx];
1101
1102      // special treatment for lngs only having singular and plural
1103      if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1104        if (suffix === 2) {
1105          suffix = 'plural';
1106        } else if (suffix === 1) {
1107          suffix = '';
1108        }
1109      }
1110
1111      var returnSuffix = function returnSuffix() {
1112        return _this2.options.prepend && suffix.toString() ? _this2.options.prepend + suffix.toString() : suffix.toString();
1113      };
1114
1115      // COMPATIBILITY JSON
1116      // v1
1117      if (this.options.compatibilityJSON === 'v1') {
1118        if (suffix === 1) return '';
1119        if (typeof suffix === 'number') return '_plural_' + suffix.toString();
1120        return returnSuffix();
1121      } else if ( /* v2 */this.options.compatibilityJSON === 'v2' || rule.numbers.length === 2 && rule.numbers[0] === 1) {
1122        return returnSuffix();
1123      } else if ( /* v3 - gettext index */rule.numbers.length === 2 && rule.numbers[0] === 1) {
1124        return returnSuffix();
1125      }
1126      return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
1127    }
1128
1129    this.logger.warn('no plural rule found for: ' + code);
1130    return '';
1131  };
1132
1133  return PluralResolver;
1134}();
1135
1136var Interpolator = function () {
1137  function Interpolator() {
1138    var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1139    classCallCheck(this, Interpolator);
1140
1141    this.logger = baseLogger.create('interpolator');
1142
1143    this.init(options, true);
1144  }
1145
1146  /* eslint no-param-reassign: 0 */
1147
1148
1149  Interpolator.prototype.init = function init() {
1150    var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1151    var reset = arguments[1];
1152
1153    if (reset) {
1154      this.options = options;
1155      this.format = options.interpolation && options.interpolation.format || function (value) {
1156        return value;
1157      };
1158      this.escape = options.interpolation && options.interpolation.escape || escape;
1159    }
1160    if (!options.interpolation) options.interpolation = { escapeValue: true };
1161
1162    var iOpts = options.interpolation;
1163
1164    this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;
1165
1166    this.prefix = iOpts.prefix ? regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';
1167    this.suffix = iOpts.suffix ? regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';
1168
1169    this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
1170
1171    this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';
1172    this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';
1173
1174    this.nestingPrefix = iOpts.nestingPrefix ? regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || regexEscape('$t(');
1175    this.nestingSuffix = iOpts.nestingSuffix ? regexEscape(iOpts.nestingSuffix
1175) : iOpts.nestingSuffixEscaped || regexEscape(')');
1176
1177    this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000;
1178
1179    // the regexp
1180    this.resetRegExp();
1181  };
1182
1183  Interpolator.prototype.reset = function reset() {
1184    if (this.options) this.init(this.options);
1185  };
1186
1187  Interpolator.prototype.resetRegExp = function resetRegExp() {
1188    // the regexp
1189    var regexpStr = this.prefix + '(.+?)' + this.suffix;
1190    this.regexp = new RegExp(regexpStr, 'g');
1191
1192    var regexpUnescapeStr = '' + this.prefix + this.unescapePrefix + '(.+?)' + this.unescapeSuffix + this.suffix;
1193    this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');
1194
1195    var nestingRegexpStr = this.nestingPrefix + '(.+?)' + this.nestingSuffix;
1196    this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
1197  };
1198
1199  Interpolator.prototype.interpolate = function interpolate(str, data, lng) {
1200    var _this = this;
1201
1202    var match = void 0;
1203    var value = void 0;
1204    var replaces = void 0;
1205
1206    function regexSafe(val) {
1207      return val.replace(/\$/g, '$$$$');
1208    }
1209
1210    var handleFormat = function handleFormat(key) {
1211      if (key.indexOf(_this.formatSeparator) < 0) return getPath(data, key);
1212
1213      var p = key.split(_this.formatSeparator);
1214      var k = p.shift().trim();
1215      var f = p.join(_this.formatSeparator).trim();
1216
1217      return _this.format(getPath(data, k), f, lng);
1218    };
1219
1220    this.resetRegExp();
1221
1222    replaces = 0;
1223    // unescape if has unescapePrefix/Suffix
1224    /* eslint no-cond-assign: 0 */
1225    while (match = this.regexpUnescape.exec(str)) {
1226      value = handleFormat(match[1].trim());
1227      str = str.replace(match[0], value);
1228      this.regexpUnescape.lastIndex = 0;
1229      replaces++;
1230      if (replaces >= this.maxReplaces) {
1231        break;
1232      }
1233    }
1234
1235    replaces = 0;
1236    // regular escape on demand
1237    while (match = this.regexp.exec(str)) {
1238      value = handleFormat(match[1].trim());
1239      if (typeof value !== 'string') value = makeString(value);
1240      if (!value) {
1241        if (typeof this.options.missingInterpolationHandler === 'function') {
1242          var temp = this.options.missingInterpolationHandler(str, match);
1243          value = typeof temp === 'string' ? temp : '';
1244        } else {
1245          this.logger.warn('missed to pass in variable ' + match[1] + ' for interpolating ' + str);
1246          value = '';
1247        }
1248      }
1249      value = this.escapeValue ? regexSafe(this.escape(value)) : regexSafe(value);
1250      str = str.replace(match[0], value);
1251      this.regexp.lastIndex = 0;
1252      replaces++;
1253      if (replaces >= this.maxReplaces) {
1254        break;
1255      }
1256    }
1257    return str;
1258  };
1259
1260  Interpolator.prototype.nest = function nest(str, fc) {
1261    var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1262
1263    var match = void 0;
1264    var value = void 0;
1265
1266    var clonedOptions = _extends({}, options);
1267    clonedOptions.applyPostProcessor = false; // avoid post processing on nested lookup
1268
1269    // if value is something like "myKey": "lorem $(anotherKey, { "count": {{aValueInOptions}} })"
1270    function handleHasOptions(key, inheritedOptions) {
1271      if (key.indexOf(',') < 0) return key;
1272
1273      var p = key.split(',');
1274      key = p.shift();
1275      var optionsString = p.join(',');
1276      optionsString = this.interpolate(optionsString, clonedOptions);
1277      optionsString = optionsString.replace(/'/g, '"');
1278
1279      try {
1280        clonedOptions = JSON.parse(optionsString);
1281
1282        if (inheritedOptions) clonedOptions = _extends({}, inheritedOptions, clonedOptions);
1283      } catch (e) {
1284        this.logger.error('failed parsing options string in nesting for key ' + key, e);
1285      }
1286
1287      return key;
1288    }
1289
1290    // regular escape on demand
1291    while (match = this.nestingRegexp.exec(str)) {
1292      value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1293
1294      // is only the nesting key (key1 = '$(key2)') return the value without stringify
1295      if (value && match[0] === str && typeof value !== 'string') return value;
1296
1297      // no string to include or empty
1298      if (typeof value !== 'string') value = makeString(value);
1299      if (!value) {
1300        this.logger.warn('missed to resolve ' + match[1] + ' for nesting ' + str);
1301        value = '';
1302      }
1303      // Nested keys should not be escaped by default #854
1304      // value = this.escapeValue ? regexSafe(utils.escape(value)) : regexSafe(value);
1305      str = str.replace(match[0], value);
1306      this.regexp.lastIndex = 0;
1307    }
1308    return str;
1309  };
1310
1311  return Interpolator;
1312}();
1313
1314function remove(arr, what) {
1315  var found = arr.indexOf(what);
1316
1317  while (found !== -1) {
1318    arr.splice(found, 1);
1319    found = arr.indexOf(what);
1320  }
1321}
1322
1323var Connector = function (_EventEmitter) {
1324  inherits(Connector, _EventEmitter);
1325
1326  function Connector(backend, store, services) {
1327    var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1328    classCallCheck(this, Connector);
1329
1330    var _this = possibleConstructorReturn(this, _EventEmitter.call(this));
1331
1332    _this.backend = backend;
1333    _this.store = store;
1334    _this.languageUtils = services.languageUtils;
1335    _this.options = options;
vendor: 18,897 bytes, lines 1336-1887
1336    _this.logger = baseLogger.create('backendConnector');
1337
1338    _this.state = {};
1339    _this.queue = [];
1340
1341    if (_this.backend && _this.backend.init) {
1342      _this.backend.init(services, options.backend, options);
1343    }
1344    return _this;
1345  }
1346
1347  Connector.prototype.queueLoad = function queueLoad(languages, namespaces, callback) {
1348    var _this2 = this;
1349
1350    // find what needs to be loaded
1351    var toLoad = [];
1352    var pending = [];
1353    var toLoadLanguages = [];
1354    var toLoadNamespaces = [];
1355
1356    languages.forEach(function (lng) {
1357      var hasAllNamespaces = true;
1358
1359      namespaces.forEach(function (ns) {
1360        var name = lng + '|' + ns;
1361
1362        if (_this2.store.hasResourceBundle(lng, ns)) {
1363          _this2.state[name] = 2; // loaded
1364        } else if (_this2.state[name] < 0) {
1365          // nothing to do for err
1366        } else if (_this2.state[name] === 1) {
1367          if (pending.indexOf(name) < 0) pending.push(name);
1368        } else {
1369          _this2.state[name] = 1; // pending
1370
1371          hasAllNamespaces = false;
1372
1373          if (pending.indexOf(name) < 0) pending.push(name);
1374          if (toLoad.indexOf(name) < 0) toLoad.push(name);
1375          if (toLoadNamespaces.indexOf(ns) < 0) toLoadNamespaces.push(ns);
1376        }
1377      });
1378
1379      if (!hasAllNamespaces) toLoadLanguages.push(lng);
1380    });
1381
1382    if (toLoad.length || pending.length) {
1383      this.queue.push({
1384        pending: pending,
1385        loaded: {},
1386        errors: [],
1387        callback: callback
1388      });
1389    }
1390
1391    return {
1392      toLoad: toLoad,
1393      pending: pending,
1394      toLoadLanguages: toLoadLanguages,
1395      toLoadNamespaces: toLoadNamespaces
1396    };
1397  };
1398
1399  Connector.prototype.loaded = function loaded(name, err, data) {
1400    var _this3 = this;
1401
1402    var _name$split = name.split('|'),
1403        _name$split2 = slicedToArray(_name$split, 2),
1404        lng = _name$split2[0],
1405        ns = _name$split2[1];
1406
1407    if (err) this.emit('failedLoading', lng, ns, err);
1408
1409    if (data) {
1410      this.store.addResourceBundle(lng, ns, data);
1411    }
1412
1413    // set loaded
1414    this.state[name] = err ? -1 : 2;
1415
1416    // callback if ready
1417    this.queue.forEach(function (q) {
1418      pushPath(q.loaded, [lng], ns);
1419      remove(q.pending, name);
1420
1421      if (err) q.errors.push(err);
1422
1423      if (q.pending.length === 0 && !q.done) {
1424        _this3.emit('loaded', q.loaded);
1425        /* eslint no-param-reassign: 0 */
1426        q.done = true;
1427        if (q.errors.length) {
1428          q.callback(q.errors);
1429        } else {
1430          q.callback();
1431        }
1432      }
1433    });
1434
1435    // remove done load requests
1436    this.queue = this.queue.filter(function (q) {
1437      return !q.done;
1438    });
1439  };
1440
1441  Connector.prototype.read = function read(lng, ns, fcName) {
1442    var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1443
1444    var _this4 = this;
1445
1446    var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 250;
1447    var callback = arguments[5];
1448
1449    if (!lng.length) return callback(null, {}); // noting to load
1450
1451    return this.backend[fcName](lng, ns, function (err, data) {
1452      if (err && data /* = retryFlag */ && tried < 5) {
1453        setTimeout(function () {
1454          _this4.read.call(_this4, lng, ns, fcName, tried + 1, wait * 2, callback);
1455        }, wait);
1456        return;
1457      }
1458      callback(err, data);
1459    });
1460  };
1461
1462  /* eslint consistent-return: 0 */
1463
1464
1465  Connector.prototype.load = function load(languages, namespaces, callback) {
1466    var _this5 = this;
1467
1468    if (!this.backend) {
1469      this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1470      return callback && callback();
1471    }
1472    var options = _extends({}, this.backend.options, this.options.backend);
1473
1474    if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
1475    if (typeof namespaces === 'string') namespaces = [namespaces];
1476
1477    var toLoad = this.queueLoad(languages, namespaces, callback);
1478    if (!toLoad.toLoad.length) {
1479      if (!toLoad.pending.length) callback(); // nothing to load and no pendings...callback now
1480      return null; // pendings will trigger callback
1481    }
1482
1483    // load with multi-load
1484    if (options.allowMultiLoading && this.backend.readMulti) {
1485      this.read(toLoad.toLoadLanguages, toLoad.toLoadNamespaces, 'readMulti', null, null, function (err, data) {
1486        if (err) _this5.logger.warn('loading namespaces ' + toLoad.toLoadNamespaces.join(', ') + ' for languages ' + toLoad.toLoadLanguages.join(', ') + ' via multiloading failed', err);
1487        if (!err && data) _this5.logger.log('successfully loaded namespaces ' + toLoad.toLoadNamespaces.join(', ') + ' for languages ' + toLoad.toLoadLanguages.join(', ') + ' via multiloading', data);
1488
1489        toLoad.toLoad.forEach(function (name) {
1490          var _name$split3 = name.split('|'),
1491              _name$split4 = slicedToArray(_name$split3, 2),
1492              l = _name$split4[0],
1493              n = _name$split4[1];
1494
1495          var bundle = getPath(data, [l, n]);
1496          if (bundle) {
1497            _this5.loaded(name, err, bundle);
1498          } else {
1499            var error = 'loading namespace ' + n + ' for language ' + l + ' via multiloading failed';
1500            _this5.loaded(name, error);
1501            _this5.logger.error(error);
1502          }
1503        });
1504      });
1505    } else {
1506      toLoad.toLoad.forEach(function (name) {
1507        _this5.loadOne(name);
1508      });
1509    }
1510  };
1511
1512  Connector.prototype.reload = function reload(languages, namespaces) {
1513    var _this6 = this;
1514
1515    if (!this.backend) {
1516      this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1517    }
1518    var options = _extends({}, this.backend.options, this.options.backend);
1519
1520    if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
1521    if (typeof namespaces === 'string') namespaces = [namespaces];
1522
1523    // load with multi-load
1524    if (options.allowMultiLoading && this.backend.readMulti) {
1525      this.read(languages, namespaces, 'readMulti', null, null, function (err, data) {
1526        if (err) _this6.logger.warn('reloading namespaces ' + namespaces.join(', ') + ' for languages ' + languages.join(', ') + ' via multiloading failed', err);
1527        if (!err && data) _this6.logger.log('successfully reloaded namespaces ' + namespaces.join(', ') + ' for languages ' + languages.join(', ') + ' via multiloading', data);
1528
1529        languages.forEach(function (l) {
1530          namespaces.forEach(function (n) {
1531            var bundle = getPath(data, [l, n]);
1532            if (bundle) {
1533              _this6.loaded(l + '|' + n, err, bundle);
1534            } else {
1535              var error = 'reloading namespace ' + n + ' for language ' + l + ' via multiloading failed';
1536              _this6.loaded(l + '|' + n, error);
1537              _this6.logger.error(error);
1538            }
1539          });
1540        });
1541      });
1542    } else {
1543      languages.forEach(function (l) {
1544        namespaces.forEach(function (n) {
1545          _this6.loadOne(l + '|' + n, 're');
1546        });
1547      });
1548    }
1549  };
1550
1551  Connector.prototype.loadOne = function loadOne(name) {
1552    var _this7 = this;
1553
1554    var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1555
1556    var _name$split5 = name.split('|'),
1557        _name$split6 = slicedToArray(_name$split5, 2),
1558        lng = _name$split6[0],
1559        ns = _name$split6[1];
1560
1561    this.read(lng, ns, 'read', null, null, function (err, data) {
1562      if (err) _this7.logger.warn(prefix + 'loading namespace ' + ns + ' for language ' + lng + ' failed', err);
1563      if (!err && data) _this7.logger.log(prefix + 'loaded namespace ' + ns + ' for language ' + lng, data);
1564
1565      _this7.loaded(name, err, data);
1566    });
1567  };
1568
1569  Connector.prototype.saveMissing = function saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
1570    var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1571
1572    if (this.backend && this.backend.create) {
1573      this.backend.create(languages, namespace, key, fallbackValue, null /* unused callback */, _extends({}, options, { isUpdate: isUpdate }));
1574    }
1575
1576    // write to store to avoid resending
1577    if (!languages || !languages[0]) return;
1578    this.store.addResource(languages[0], namespace, key, fallbackValue);
1579  };
1580
1581  return Connector;
1582}(EventEmitter);
1583
1584var Connector$1 = function (_EventEmitter) {
1585  inherits(Connector, _EventEmitter);
1586
1587  function Connector(cache, store, services) {
1588    var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1589    classCallCheck(this, Connector);
1590
1591    var _this = possibleConstructorReturn(this, _EventEmitter.call(this));
1592
1593    _this.cache = cache;
1594    _this.store = store;
1595    _this.services = services;
1596    _this.options = options;
1597    _this.logger = baseLogger.create('cacheConnector');
1598
1599    if (_this.cache && _this.cache.init) _this.cache.init(services, options.cache, options);
1600    return _this;
1601  }
1602
1603  /* eslint consistent-return: 0 */
1604
1605
1606  Connector.prototype.load = function load(languages, namespaces, callback) {
1607    var _this2 = this;
1608
1609    if (!this.cache) return callback && callback();
1610    var options = _extends({}, this.cache.options, this.options.cache);
1611
1612    var loadLngs = typeof languages === 'string' ? this.services.languageUtils.toResolveHierarchy(languages) : languages;
1613
1614    if (options.enabled) {
1615      this.cache.load(loadLngs, function (err, data) {
1616        if (err) _this2.logger.error('loading languages ' + loadLngs.join(', ') + ' from cache failed', err);
1617        if (data) {
1618          /* eslint no-restricted-syntax: 0 */
1619          for (var l in data) {
1620            if (Object.prototype.hasOwnProperty.call(data, l)) {
1621              for (var n in data[l]) {
1622                if (Object.prototype.hasOwnProperty.call(data[l], n)) {
1623                  if (n !== 'i18nStamp') {
1624                    var bundle = data[l][n];
1625                    if (bundle) _this2.store.addResourceBundle(l, n, bundle);
1626                  }
1627                }
1628              }
1629            }
1630          }
1631        }
1632        if (callback) callback();
1633      });
1634    } else if (callback) {
1635      callback();
1636    }
1637  };
1638
1639  Connector.prototype.save = function save() {
1640    if (this.cache && this.options.cache && this.options.cache.enabled) this.cache.save(this.store.data);
1641  };
1642
1643  return Connector;
1644}(EventEmitter);
1645
1646function get$1() {
1647  return {
1648    debug: false,
1649    initImmediate: true,
1650
1651    ns: ['translation'],
1652    defaultNS: ['translation'],
1653    fallbackLng: ['dev'],
1654    fallbackNS: false, // string or array of namespaces
1655
1656    whitelist: false, // array with whitelisted languages
1657    nonExplicitWhitelist: false,
1658    load: 'all', // | currentOnly | languageOnly
1659    preload: false, // array with preload languages
1660
1661    simplifyPluralSuffix: true,
1662    keySeparator: '.',
1663    nsSeparator: ':',
1664    pluralSeparator: '_',
1665    contextSeparator: '_',
1666
1667    saveMissing: false, // enable to send missing values
1668    updateMissing: false, // enable to update default values if different from translated value (only useful on initial development, or when keeping code as source of truth)
1669    saveMissingTo: 'fallback', // 'current' || 'all'
1670    saveMissingPlurals: true, // will save all forms not only singular key
1671    missingKeyHandler: false, // function(lng, ns, key, fallbackValue) -> override if prefer on handling
1672    missingInterpolationHandler: false, // function(str, match)
1673
1674    postProcess: false, // string or array of postProcessor names
1675    returnNull: true, // allows null value as valid translation
1676    returnEmptyString: true, // allows empty string value as valid translation
1677    returnObjects: false,
1678    joinArrays: false, // or string to join array
1679    returnedObjectHandler: function returnedObjectHandler() {}, // function(key, value, options) triggered if key returns object but returnObjects is set to false
1680    parseMissingKeyHandler: false, // function(key) parsed a key that was not found in t() before returning
1681    appendNamespaceToMissingKey: false,
1682    appendNamespaceToCIMode: false,
1683    overloadTranslationOptionHandler: function handle(args) {
1684      var ret = {};
1685      if (args[1]) ret.defaultValue = args[1];
1686      if (args[2]) ret.tDescription = args[2];
1687      return ret;
1688    },
1689
1690    interpolation: {
1691      escapeValue: true,
1692      format: function format(value, _format, lng) {
1693        return value;
1694      },
1695      prefix: '{{',
1696      suffix: '}}',
1697      formatSeparator: ',',
1698      // prefixEscaped: '{{',
1699      // suffixEscaped: '}}',
1700      // unescapeSuffix: '',
1701      unescapePrefix: '-',
1702
1703      nestingPrefix: '$t(',
1704      nestingSuffix: ')',
1705      // nestingPrefixEscaped: '$t(',
1706      // nestingSuffixEscaped: ')',
1707      // defaultVariables: undefined // object that can have values to interpolate on - extends passed in interpolation data
1708      maxReplaces: 1000 // max replaces to prevent endless loop
1709    }
1710  };
1711}
1712
1713/* eslint no-param-reassign: 0 */
1714function transformOptions(options) {
1715  // create namespace object if namespace is passed in as string
1716  if (typeof options.ns === 'string') options.ns = [options.ns];
1717  if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
1718  if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
1719
1720  // extend whitelist with cimode
1721  if (options.whitelist && options.whitelist.indexOf('cimode') < 0) {
1722    options.whitelist = options.whitelist.concat(['cimode']);
1723  }
1724
1725  return options;
1726}
1727
1728function noop() {}
1729
1730var I18n = function (_EventEmitter) {
1731  inherits(I18n, _EventEmitter);
1732
1733  function I18n() {
1734    var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1735    var callback = arguments[1];
1736    classCallCheck(this, I18n);
1737
1738    var _this = possibleConstructorReturn(this, _EventEmitter.call(this));
1739
1740    _this.options = transformOptions(options);
1741    _this.services = {};
1742    _this.logger = baseLogger;
1743    _this.modules = { external: [] };
1744
1745    if (callback && !_this.isInitialized && !options.isClone) {
1746      var _ret;
1747
1748      // https://github.com/i18next/i18next/issues/879
1749      if (!_this.options.initImmediate) return _ret = _this.init(options, callback), possibleConstructorReturn(_this, _ret);
1750      setTimeout(function () {
1751        _this.init(options, callback);
1752      }, 0);
1753    }
1754    return _this;
1755  }
1756
1757  I18n.prototype.init = function init() {
1758    var _this2 = this;
1759
1760    var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1761    var callback = arguments[1];
1762
1763    if (typeof options === 'function') {
1764      callback = options;
1765      options = {};
1766    }
1767    this.options = _extends({}, get$1(), this.options, transformOptions(options));
1768
1769    this.format = this.options.interpolation.format;
1770    if (!callback) callback = noop;
1771
1772    function createClassOnDemand(ClassOrObject) {
1773      if (!ClassOrObject) return null;
1774      if (typeof ClassOrObject === 'function') return new ClassOrObject();
1775      return ClassOrObject;
1776    }
1777
1778    // init services
1779    if (!this.options.isClone) {
1780      if (this.modules.logger) {
1781        baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
1782      } else {
1783        baseLogger.init(null, this.options);
1784      }
1785
1786      var lu = new LanguageUtil(this.options);
1787      this.store = new ResourceStore(this.options.resources, this.options);
1788
1789      var s = this.services;
1790      s.logger = baseLogger;
1791      s.resourceStore = this.store;
1792      s.resourceStore.on('added removed', function (lng, ns) {
1793        s.cacheConnector.save();
1794      });
1795      s.languageUtils = lu;
1796      s.pluralResolver = new PluralResolver(lu, { prepend: this.options.pluralSeparator, compatibilityJSON: this.options.compatibilityJSON, simplifyPluralSuffix: this.options.simplifyPluralSuffix });
1797      s.interpolator = new Interpolator(this.options);
1798
1799      s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1800      // pipe events from backendConnector
1801      s.backendConnector.on('*', function (event) {
1802        for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1803          args[_key - 1] = arguments[_key];
1804        }
1805
1806        _this2.emit.apply(_this2, [event].concat(args));
1807      });
1808
1809      s.backendConnector.on('loaded', function (loaded) {
1810        s.cacheConnector.save();
1811      });
1812
1813      s.cacheConnector = new Connector$1(createClassOnDemand(this.modules.cache), s.resourceStore, s, this.options);
1814      // pipe events from backendConnector
1815      s.cacheConnector.on('*', function (event) {
1816        for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1817          args[_key2 - 1] = arguments[_key2];
1818        }
1819
1820        _this2.emit.apply(_this2, [event].concat(args));
1821      });
1822
1823      if (this.modules.languageDetector) {
1824        s.languageDetector = createClassOnDemand(this.modules.languageDetector);
1825        s.languageDetector.init(s, this.options.detection, this.options);
1826      }
1827
1828      this.translator = new Translator(this.services, this.options);
1829      // pipe events from translator
1830      this.translator.on('*', function (event) {
1831        for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
1832          args[_key3 - 1] = arguments[_key3];
1833        }
1834
1835        _this2.emit.apply(_this2, [event].concat(args));
1836      });
1837
1838      this.modules.external.forEach(function (m) {
1839        if (m.init) m.init(_this2);
1840      });
1841    }
1842
1843    // append api
1844    var storeApi = ['getResource', 'addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle', 'hasResourceBundle', 'getResourceBundle'];
1845    storeApi.forEach(function (fcName) {
1846      _this2[fcName] = function () {
1847        var _store;
1848
1849        return (_store = _this2.store)[fcName].apply(_store, arguments);
1850      };
1851    });
1852
1853    var load = function load() {
1854      _this2.changeLanguage(_this2.options.lng, function (err, t) {
1855        _this2.isInitialized = true;
1856        _this2.logger.log('initialized', _this2.options);
1857        _this2.emit('initialized', _this2.options);
1858
1859        callback(err, t);
1860      });
1861    };
1862
1863    if (this.options.resources || !this.options.initImmediate) {
1864      load();
1865    } else {
1866      setTimeout(load, 0);
1867    }
1868
1869    return this;
1870  };
1871
1872  /* eslint consistent-return: 0 */
1873
1874
1875  I18n.prototype.loadResources = function loadResources() {
1876    var _this3 = this;
1877
1878    var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noop;
1879
1880    if (!this.options.resources) {
1881      if (this.language && this.language.toLowerCase() === 'cimode') return callback(); // avoid loading resources for cimode
1882
1883      var toLoad = [];
1884
1885      var append = function append(lng) {
1886        if (!lng) return;
1887        var lngs = _this3.services.languageUtils.toResolveHierarchy(lng);
1888        lngs.forEach(function (l) {
1889          if (toLoad.indexOf(l) < 0) toLoad.push(l);
1890        });
1891      };
1892
1893      if (!this.language) {
1894        // at least load fallbacks in this case
1895        var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1896        fallbacks.forEach(function (l) {
1897          return append(l);
1898        });
1899      } else {
1900        append(this.language);
1901      }
1902
1903      if (this.options.preload) {
1904        this.options.preload.forEach(function (l) {
1905          return append(l);
1906        });
1907      }
1908
1909      this.services.cacheConnector.load(toLoad, this.options.ns, function () {
1910        _this3.services.backendConnector.load(toLoad, _this3.options.ns, callback);
1911      });
1912    } else {
1913      callback(null);
1914    }
1915  };
1916
1917  I18n.prototype.reloadResources = function reloadResources(lngs, ns) {
1918    if (!lngs) lngs = this.languages;
1919    if (!ns) ns = this.options.ns;
1920    this.services.backendConnector.reload(lngs, ns);
1921  };
1922
1923  I18n.prototype.use = function use(module) {
1924    if (module.type === 'backend') {
1925      this.modules.backend = module;
1926    }
1927
1928    if (module.type === 'cache') {
1929      this.modules.cache = module;
1930    }
1931
1932    if (module.type === 'logger' || module.log && module.warn && module.error) {
1933      this.modules.logger = module;
1934    }
1935
1936    if (module.type === 'languageDetector') {
1937      this.modules.languageDetector = module;
1938    }
1939
1940    if (module.type === 'postProcessor') {
1941      postProcessor.addPostProcessor(module);
1942    }
1943
1944    if (module.type === '3rdParty') {
1945      this.modules.external.push(module);
1946    }
1947
1948    return this;
1949  };
1950
1951  I18n.prototype.changeLanguage = function changeLanguage(lng, callback) {
1952    var _this4 = this;
1953
1954    var done = function done(err, l) {
1955      _this4.translator.changeLanguage(l);
1956
1957      if (l) {
1958        _this4.emit('languageChanged', l);
1959        _this4.logger.log('languageChanged', l);
1960      }
1961
1962      if (callback) callback(err, function () {
1963        return _this4.t.apply(_this4, arguments);
1964      });
1965    };
1966
1967    var setLng = function setLng(l) {
1968      if (l) {
1969        _this4.language = l;
1970        _this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);
1971        if (!_this4.translator.language) _this4.translator.changeLanguage(l);
1972
1973        if (_this4.services.languageDetector) _this4.services.languageDetector.cacheUserLanguage(l);
1974      }
1975
1976      _this4.loadResources(function (err) {
1977        done(err, l);
1978      });
1979    };
1980
1981    if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
1982      setLng(this.services.languageDetector.detect());
1983    } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
1984      this.services.languageDetector.detect(setLng);
1985    } else {
1986      setLng(lng);
1987    }
1988  };
1989
1990  I18n.prototype.getFixedT = function getFixedT(lng, ns) {
1991    var _this5 = this;
1992
1993    var fixedT = function fixedT(key, opts) {
1994      for (var _len4 = arguments.length, rest = Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
1995        rest[_key4 - 2] = arguments[_key4];
1996      }
1997
1998      var options = _extends({}, opts);
1999      if ((typeof opts === 'undefined' ? 'undefined' : _typeof(opts)) !== 'object') {
2000        options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2001      }
2002
2003      options.lng = options.lng || fixedT.lng;
2004      options.lngs = options.lngs || fixedT.lngs;
2005      options.ns = options.ns || fixedT.ns;
2006      return _this5.t(key, options);
2007    };
2008    if (typeof lng === 'string') {
2009      fixedT.lng = lng;
2010    } else {
2011      fixedT.lngs = lng;
2012    }
2013    fixedT.ns = ns;
2014    return fixedT;
2015  };
2016
2017  I18n.prototype.t = function t() {
2018    var _translator;
2019
2020    return this.translator && (_translator = this.translator).translate.apply(_translator, arguments);
2021  };
2022
2023  I18n.prototype.exists = function exists() {
2024    var _translator2;
2025
2026    return this.translator && (_translator2 = this.translator).exists.apply(_translator2, arguments);
2027  };
2028
2029  I18n.prototype.setDefaultNamespace = function setDefaultNamespace(ns) {
2030    this.options.defaultNS = ns;
2031  };
2032
2033  I18n.prototype.loadNamespaces = function loadNamespaces(ns, callback) {
2034    var _this6 = this;
2035
2036    if (!this.options.ns) return callback && callback();
2037    if (typeof ns === 'string') ns = [ns];
2038
2039    ns.forEach(function (n) {
2040      if (_this6.options.ns.indexOf(n) < 0) _this6.options.ns.push(n);
2041    });
2042
2043    this.loadResources(callback);
2044  };
2045
2046  I18n.prototype.loadLanguages = function loadLanguages(lngs, callback) {
2047    if (typeof lngs === 'string') lngs = [lngs];
2048    var preloaded = this.options.preload || [];
2049
2050    var newLngs = lngs.filter(function (lng) {
2051      return preloaded.indexOf(lng) < 0;
2052    });
2053    // Exit early if all given languages are already preloaded
2054    if (!newLngs.length) return callback();
2055
2056    this.options.preload = preloaded.concat(newLngs);
2057    this.loadResources(callback);
2058  };
2059
2060  I18n.prototype.dir = function dir(lng) {
2061    if (!lng) lng = this.languages && this.languages.length > 0 ? this.languages[0] : this.language;
2062    if (!lng) return 'rtl';
2063
2064    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', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam'];
2065
2066    return rtlLngs.indexOf(this.services.languageUtils.getLanguagePartFromCode(lng)) >= 0 ? 'rtl' : 'ltr';
2067  };
2068
2069  /* eslint class-methods-use-this: 0 */
2070
2071
2072  I18n.prototype.createInstance = function createInstance() {
2073    var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2074    var callback = arguments[1];
2075
2076    return new I18n(options, callback);
2077  };
2078
2079  I18n.prototype.cloneInstance = function cloneInstance() {
2080    var _this7 = this;
2081
2082    var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2083    var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2084
2085    var mergedOptions = _extends({}, this.options, options, { isClone: true });
2086    var clone = new I18n(mergedOptions);
2087    var membersToCopy = ['store', 'services', 'language'];
2088    membersToCopy.forEach(function (m) {
2089      clone[m] = _this7[m];
2090    });
2091    clone.translator = new Translator(clone.services, clone.options);
2092    clone.translator.on('*', function (event) {
2093      for (var _len5 = arguments.length, args = Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
2094        args[_key5 - 1] = arguments[_key5];
2095      }
2096
2097      clone.emit.apply(clone, [event].concat(args));
2098    });
2099    clone.init(mergedOptions, callback);
2100    clone.translator.options = clone.options; // sync options
2101
2102    return clone;
2103  };
2104
2105  return I18n;
2106}(EventEmitter);
2107
2108var i18next = new I18n();
2109
2110return i18next;
2111
2112})));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.