i18next 23.16.1 → 23.16.3

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.
@@ -1,122 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const consoleLogger = {
4
- type: 'logger',
5
- log(args) {
6
- this.output('log', args);
7
- },
8
- warn(args) {
9
- this.output('warn', args);
10
- },
11
- error(args) {
12
- this.output('error', args);
13
- },
14
- output(type, args) {
15
- if (console && console[type]) console[type].apply(console, args);
16
- }
17
- };
18
- class Logger {
19
- constructor(concreteLogger) {
20
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
21
- this.init(concreteLogger, options);
22
- }
23
- init(concreteLogger) {
24
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25
- this.prefix = options.prefix || 'i18next:';
26
- this.logger = concreteLogger || consoleLogger;
27
- this.options = options;
28
- this.debug = options.debug;
29
- }
30
- log() {
31
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
32
- args[_key] = arguments[_key];
33
- }
34
- return this.forward(args, 'log', '', true);
35
- }
36
- warn() {
37
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
38
- args[_key2] = arguments[_key2];
39
- }
40
- return this.forward(args, 'warn', '', true);
41
- }
42
- error() {
43
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
44
- args[_key3] = arguments[_key3];
45
- }
46
- return this.forward(args, 'error', '');
47
- }
48
- deprecate() {
49
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
50
- args[_key4] = arguments[_key4];
51
- }
52
- return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
53
- }
54
- forward(args, lvl, prefix, debugOnly) {
55
- if (debugOnly && !this.debug) return null;
56
- if (typeof args[0] === 'string') args[0] = `${prefix}${this.prefix} ${args[0]}`;
57
- return this.logger[lvl](args);
58
- }
59
- create(moduleName) {
60
- return new Logger(this.logger, {
61
- ...{
62
- prefix: `${this.prefix}:${moduleName}:`
63
- },
64
- ...this.options
65
- });
66
- }
67
- clone(options) {
68
- options = options || this.options;
69
- options.prefix = options.prefix || this.prefix;
70
- return new Logger(this.logger, options);
71
- }
72
- }
73
- var baseLogger = new Logger();
74
-
75
- class EventEmitter {
76
- constructor() {
77
- this.observers = {};
78
- }
79
- on(events, listener) {
80
- events.split(' ').forEach(event => {
81
- if (!this.observers[event]) this.observers[event] = new Map();
82
- const numListeners = this.observers[event].get(listener) || 0;
83
- this.observers[event].set(listener, numListeners + 1);
84
- });
85
- return this;
86
- }
87
- off(event, listener) {
88
- if (!this.observers[event]) return;
89
- if (!listener) {
90
- delete this.observers[event];
91
- return;
92
- }
93
- this.observers[event].delete(listener);
94
- }
95
- emit(event) {
96
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
97
- args[_key - 1] = arguments[_key];
98
- }
99
- if (this.observers[event]) {
100
- const cloned = Array.from(this.observers[event].entries());
101
- cloned.forEach(_ref => {
102
- let [observer, numTimesAdded] = _ref;
103
- for (let i = 0; i < numTimesAdded; i++) {
104
- observer(...args);
105
- }
106
- });
107
- }
108
- if (this.observers['*']) {
109
- const cloned = Array.from(this.observers['*'].entries());
110
- cloned.forEach(_ref2 => {
111
- let [observer, numTimesAdded] = _ref2;
112
- for (let i = 0; i < numTimesAdded; i++) {
113
- observer.apply(observer, [event, ...args]);
114
- }
115
- });
116
- }
117
- }
118
- }
119
-
3
+ const isString = obj => typeof obj === 'string';
120
4
  const defer = () => {
121
5
  let res;
122
6
  let rej;
@@ -139,9 +23,9 @@ const copy = (a, s, t) => {
139
23
  };
140
24
  const lastOfPathSeparatorRegExp = /###/g;
141
25
  const cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
142
- const canNotTraverseDeeper = object => !object || typeof object === 'string';
26
+ const canNotTraverseDeeper = object => !object || isString(object);
143
27
  const getLastOfPath = (object, path, Empty) => {
144
- const stack = typeof path !== 'string' ? path : path.split('.');
28
+ const stack = !isString(path) ? path : path.split('.');
145
29
  let stackIndex = 0;
146
30
  while (stackIndex < stack.length - 1) {
147
31
  if (canNotTraverseDeeper(object)) return {};
@@ -209,7 +93,7 @@ const deepExtend = (target, source, overwrite) => {
209
93
  for (const prop in source) {
210
94
  if (prop !== '__proto__' && prop !== 'constructor') {
211
95
  if (prop in target) {
212
- if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
96
+ if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
213
97
  if (overwrite) target[prop] = source[prop];
214
98
  } else {
215
99
  deepExtend(target[prop], source[prop], overwrite);
@@ -231,7 +115,7 @@ var _entityMap = {
231
115
  '/': '&#x2F;'
232
116
  };
233
117
  const escape = data => {
234
- if (typeof data === 'string') {
118
+ if (isString(data)) {
235
119
  return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
236
120
  }
237
121
  return data;
@@ -305,6 +189,123 @@ const deepFind = function (obj, path) {
305
189
  };
306
190
  const getCleanedCode = code => code && code.replace('_', '-');
307
191
 
192
+ const consoleLogger = {
193
+ type: 'logger',
194
+ log(args) {
195
+ this.output('log', args);
196
+ },
197
+ warn(args) {
198
+ this.output('warn', args);
199
+ },
200
+ error(args) {
201
+ this.output('error', args);
202
+ },
203
+ output(type, args) {
204
+ if (console && console[type]) console[type].apply(console, args);
205
+ }
206
+ };
207
+ class Logger {
208
+ constructor(concreteLogger) {
209
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
210
+ this.init(concreteLogger, options);
211
+ }
212
+ init(concreteLogger) {
213
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
214
+ this.prefix = options.prefix || 'i18next:';
215
+ this.logger = concreteLogger || consoleLogger;
216
+ this.options = options;
217
+ this.debug = options.debug;
218
+ }
219
+ log() {
220
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
221
+ args[_key] = arguments[_key];
222
+ }
223
+ return this.forward(args, 'log', '', true);
224
+ }
225
+ warn() {
226
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
227
+ args[_key2] = arguments[_key2];
228
+ }
229
+ return this.forward(args, 'warn', '', true);
230
+ }
231
+ error() {
232
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
233
+ args[_key3] = arguments[_key3];
234
+ }
235
+ return this.forward(args, 'error', '');
236
+ }
237
+ deprecate() {
238
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
239
+ args[_key4] = arguments[_key4];
240
+ }
241
+ return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
242
+ }
243
+ forward(args, lvl, prefix, debugOnly) {
244
+ if (debugOnly && !this.debug) return null;
245
+ if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
246
+ return this.logger[lvl](args);
247
+ }
248
+ create(moduleName) {
249
+ return new Logger(this.logger, {
250
+ ...{
251
+ prefix: `${this.prefix}:${moduleName}:`
252
+ },
253
+ ...this.options
254
+ });
255
+ }
256
+ clone(options) {
257
+ options = options || this.options;
258
+ options.prefix = options.prefix || this.prefix;
259
+ return new Logger(this.logger, options);
260
+ }
261
+ }
262
+ var baseLogger = new Logger();
263
+
264
+ class EventEmitter {
265
+ constructor() {
266
+ this.observers = {};
267
+ }
268
+ on(events, listener) {
269
+ events.split(' ').forEach(event => {
270
+ if (!this.observers[event]) this.observers[event] = new Map();
271
+ const numListeners = this.observers[event].get(listener) || 0;
272
+ this.observers[event].set(listener, numListeners + 1);
273
+ });
274
+ return this;
275
+ }
276
+ off(event, listener) {
277
+ if (!this.observers[event]) return;
278
+ if (!listener) {
279
+ delete this.observers[event];
280
+ return;
281
+ }
282
+ this.observers[event].delete(listener);
283
+ }
284
+ emit(event) {
285
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
286
+ args[_key - 1] = arguments[_key];
287
+ }
288
+ if (this.observers[event]) {
289
+ const cloned = Array.from(this.observers[event].entries());
290
+ cloned.forEach(_ref => {
291
+ let [observer, numTimesAdded] = _ref;
292
+ for (let i = 0; i < numTimesAdded; i++) {
293
+ observer(...args);
294
+ }
295
+ });
296
+ }
297
+ if (this.observers['*']) {
298
+ const cloned = Array.from(this.observers['*'].entries());
299
+ cloned.forEach(_ref2 => {
300
+ let [observer, numTimesAdded] = _ref2;
301
+ for (let i = 0; i < numTimesAdded; i++) {
302
+ observer.apply(observer, [event, ...args]);
303
+ }
304
+ });
305
+ }
306
+ }
307
+ }
308
+
308
309
  class ResourceStore extends EventEmitter {
309
310
  constructor(data) {
310
311
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
@@ -344,7 +345,7 @@ class ResourceStore extends EventEmitter {
344
345
  if (key) {
345
346
  if (Array.isArray(key)) {
346
347
  path.push(...key);
347
- } else if (typeof key === 'string' && keySeparator) {
348
+ } else if (isString(key) && keySeparator) {
348
349
  path.push(...key.split(keySeparator));
349
350
  } else {
350
351
  path.push(key);
@@ -357,7 +358,7 @@ class ResourceStore extends EventEmitter {
357
358
  ns = path[1];
358
359
  key = path.slice(2).join('.');
359
360
  }
360
- if (result || !ignoreJSONStructure || typeof key !== 'string') return result;
361
+ if (result || !ignoreJSONStructure || !isString(key)) return result;
361
362
  return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
362
363
  }
363
364
  addResource(lng, ns, key, value) {
@@ -381,7 +382,7 @@ class ResourceStore extends EventEmitter {
381
382
  silent: false
382
383
  };
383
384
  for (const m in resources) {
384
- if (typeof resources[m] === 'string' || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
385
+ if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
385
386
  silent: true
386
387
  });
387
388
  }
@@ -501,7 +502,7 @@ class Translator extends EventEmitter {
501
502
  if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
502
503
  key = parts.join(keySeparator);
503
504
  }
504
- if (typeof namespaces === 'string') namespaces = [namespaces];
505
+ if (isString(namespaces)) namespaces = [namespaces];
505
506
  return {
506
507
  key,
507
508
  namespaces
@@ -561,8 +562,8 @@ class Translator extends EventEmitter {
561
562
  const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
562
563
  const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
563
564
  const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
564
- const handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
565
- if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && Array.isArray(res))) {
565
+ const handleAsObject = !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
566
+ if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(res))) {
566
567
  if (!options.returnObjects && !this.options.returnObjects) {
567
568
  if (!this.options.returnedObjectHandler) {
568
569
  this.logger.warn('accessing an object - but returnObjects options is not enabled!');
@@ -597,13 +598,13 @@ class Translator extends EventEmitter {
597
598
  }
598
599
  res = copy;
599
600
  }
600
- } else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && Array.isArray(res)) {
601
+ } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
601
602
  res = res.join(joinArrays);
602
603
  if (res) res = this.extendTranslation(res, keys, options, lastKey);
603
604
  } else {
604
605
  let usedDefault = false;
605
606
  let usedKey = false;
606
- const needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
607
+ const needsPluralHandling = options.count !== undefined && !isString(options.count);
607
608
  const hasDefaultValue = Translator.hasDefaultValue(options);
608
609
  const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
609
610
  const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
@@ -703,13 +704,13 @@ class Translator extends EventEmitter {
703
704
  }
704
705
  }
705
706
  });
706
- const skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
707
+ const skipOnVariables = isString(res) && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
707
708
  let nestBef;
708
709
  if (skipOnVariables) {
709
710
  const nb = res.match(this.interpolator.nestingRegexp);
710
711
  nestBef = nb && nb.length;
711
712
  }
712
- let data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
713
+ let data = options.replace && !isString(options.replace) ? options.replace : options;
713
714
  if (this.options.interpolation.defaultVariables) data = {
714
715
  ...this.options.interpolation.defaultVariables,
715
716
  ...data
@@ -734,7 +735,7 @@ class Translator extends EventEmitter {
734
735
  if (options.interpolation) this.interpolator.reset();
735
736
  }
736
737
  const postProcess = options.postProcess || this.options.postProcess;
737
- const postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
738
+ const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
738
739
  if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
739
740
  res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
740
741
  i18nResolved: {
@@ -753,7 +754,7 @@ class Translator extends EventEmitter {
753
754
  let exactUsedKey;
754
755
  let usedLng;
755
756
  let usedNS;
756
- if (typeof keys === 'string') keys = [keys];
757
+ if (isString(keys)) keys = [keys];
757
758
  keys.forEach(k => {
758
759
  if (this.isValidLookup(found)) return;
759
760
  const extracted = this.extractFromKey(k, options);
@@ -761,9 +762,9 @@ class Translator extends EventEmitter {
761
762
  usedKey = key;
762
763
  let namespaces = extracted.namespaces;
763
764
  if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
764
- const needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
765
+ const needsPluralHandling = options.count !== undefined && !isString(options.count);
765
766
  const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
766
- const needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';
767
+ const needsContextHandling = options.context !== undefined && (isString(options.context) || typeof options.context === 'number') && options.context !== '';
767
768
  const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
768
769
  namespaces.forEach(ns => {
769
770
  if (this.isValidLookup(found)) return;
@@ -835,7 +836,7 @@ class Translator extends EventEmitter {
835
836
  getUsedParamsDetails() {
836
837
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
837
838
  const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
838
- const useOptionsReplaceForData = options.replace && typeof options.replace !== 'string';
839
+ const useOptionsReplaceForData = options.replace && !isString(options.replace);
839
840
  let data = useOptionsReplaceForData ? options.replace : options;
840
841
  if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
841
842
  data.count = options.count;
@@ -890,7 +891,7 @@ class LanguageUtil {
890
891
  return this.formatLanguageCode(p[0]);
891
892
  }
892
893
  formatLanguageCode(code) {
893
- if (typeof code === 'string' && code.indexOf('-') > -1) {
894
+ if (isString(code) && code.indexOf('-') > -1) {
894
895
  if (typeof Intl !== 'undefined' && typeof Intl.getCanonicalLocales !== 'undefined') {
895
896
  try {
896
897
  let formattedCode = Intl.getCanonicalLocales(code)[0];
@@ -952,7 +953,7 @@ class LanguageUtil {
952
953
  getFallbackCodes(fallbacks, code) {
953
954
  if (!fallbacks) return [];
954
955
  if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
955
- if (typeof fallbacks === 'string') fallbacks = [fallbacks];
956
+ if (isString(fallbacks)) fallbacks = [fallbacks];
956
957
  if (Array.isArray(fallbacks)) return fallbacks;
957
958
  if (!code) return fallbacks.default || [];
958
959
  let found = fallbacks[code];
@@ -973,11 +974,11 @@ class LanguageUtil {
973
974
  this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
974
975
  }
975
976
  };
976
- if (typeof code === 'string' && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
977
+ if (isString(code) && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
977
978
  if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
978
979
  if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
979
980
  if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
980
- } else if (typeof code === 'string') {
981
+ } else if (isString(code)) {
981
982
  addCode(this.formatLanguageCode(code));
982
983
  }
983
984
  fallbackCodes.forEach(fc => {
@@ -1235,7 +1236,7 @@ const deepFindWithDefaults = function (data, defaultData, key) {
1235
1236
  let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
1236
1237
  let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1237
1238
  let path = getPathWithDefaults(data, defaultData, key);
1238
- if (!path && ignoreJSONStructure && typeof key === 'string') {
1239
+ if (!path && ignoreJSONStructure && isString(key)) {
1239
1240
  path = deepFind(data, key, keySeparator);
1240
1241
  if (path === undefined) path = deepFind(defaultData, key, keySeparator);
1241
1242
  }
@@ -1345,7 +1346,7 @@ class Interpolator {
1345
1346
  if (value === undefined) {
1346
1347
  if (typeof missingInterpolationHandler === 'function') {
1347
1348
  const temp = missingInterpolationHandler(str, match, options);
1348
- value = typeof temp === 'string' ? temp : '';
1349
+ value = isString(temp) ? temp : '';
1349
1350
  } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
1350
1351
  value = '';
1351
1352
  } else if (skipOnVariables) {
@@ -1355,7 +1356,7 @@ class Interpolator {
1355
1356
  this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
1356
1357
  value = '';
1357
1358
  }
1358
- } else if (typeof value !== 'string' && !this.useRawValueToEscape) {
1359
+ } else if (!isString(value) && !this.useRawValueToEscape) {
1359
1360
  value = makeString(value);
1360
1361
  }
1361
1362
  const safeValue = todo.safeValue(value);
@@ -1409,7 +1410,7 @@ class Interpolator {
1409
1410
  clonedOptions = {
1410
1411
  ...options
1411
1412
  };
1412
- clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;
1413
+ clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1413
1414
  clonedOptions.applyPostProcessor = false;
1414
1415
  delete clonedOptions.defaultValue;
1415
1416
  let doReduce = false;
@@ -1420,8 +1421,8 @@ class Interpolator {
1420
1421
  doReduce = true;
1421
1422
  }
1422
1423
  value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1423
- if (value && match[0] === str && typeof value !== 'string') return value;
1424
- if (typeof value !== 'string') value = makeString(value);
1424
+ if (value && match[0] === str && !isString(value)) return value;
1425
+ if (!isString(value)) value = makeString(value);
1425
1426
  if (!value) {
1426
1427
  this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1427
1428
  value = '';
@@ -1719,8 +1720,8 @@ class Connector extends EventEmitter {
1719
1720
  this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1720
1721
  return callback && callback();
1721
1722
  }
1722
- if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
1723
- if (typeof namespaces === 'string') namespaces = [namespaces];
1723
+ if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
1724
+ if (isString(namespaces)) namespaces = [namespaces];
1724
1725
  const toLoad = this.queueLoad(languages, namespaces, options, callback);
1725
1726
  if (!toLoad.toLoad.length) {
1726
1727
  if (!toLoad.pending.length) callback();
@@ -1824,8 +1825,8 @@ const get = () => ({
1824
1825
  overloadTranslationOptionHandler: args => {
1825
1826
  let ret = {};
1826
1827
  if (typeof args[1] === 'object') ret = args[1];
1827
- if (typeof args[1] === 'string') ret.defaultValue = args[1];
1828
- if (typeof args[2] === 'string') ret.tDescription = args[2];
1828
+ if (isString(args[1])) ret.defaultValue = args[1];
1829
+ if (isString(args[2])) ret.tDescription = args[2];
1829
1830
  if (typeof args[2] === 'object' || typeof args[3] === 'object') {
1830
1831
  const options = args[3] || args[2];
1831
1832
  Object.keys(options).forEach(key => {
@@ -1849,9 +1850,9 @@ const get = () => ({
1849
1850
  }
1850
1851
  });
1851
1852
  const transformOptions = options => {
1852
- if (typeof options.ns === 'string') options.ns = [options.ns];
1853
- if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
1854
- if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
1853
+ if (isString(options.ns)) options.ns = [options.ns];
1854
+ if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
1855
+ if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
1855
1856
  if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
1856
1857
  options.supportedLngs = options.supportedLngs.concat(['cimode']);
1857
1858
  }
@@ -1899,7 +1900,7 @@ class I18n extends EventEmitter {
1899
1900
  options = {};
1900
1901
  }
1901
1902
  if (!options.defaultNS && options.defaultNS !== false && options.ns) {
1902
- if (typeof options.ns === 'string') {
1903
+ if (isString(options.ns)) {
1903
1904
  options.defaultNS = options.ns;
1904
1905
  } else if (options.ns.indexOf('translation') < 0) {
1905
1906
  options.defaultNS = options.ns[0];
@@ -2032,7 +2033,7 @@ class I18n extends EventEmitter {
2032
2033
  loadResources(language) {
2033
2034
  let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2034
2035
  let usedCallback = callback;
2035
- const usedLng = typeof language === 'string' ? language : this.language;
2036
+ const usedLng = isString(language) ? language : this.language;
2036
2037
  if (typeof language === 'function') usedCallback = language;
2037
2038
  if (!this.options.resources || this.options.partialBundledLanguages) {
2038
2039
  if (usedLng && usedLng.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
@@ -2150,7 +2151,7 @@ class I18n extends EventEmitter {
2150
2151
  };
2151
2152
  const setLng = lngs => {
2152
2153
  if (!lng && !lngs && this.services.languageDetector) lngs = [];
2153
- const l = typeof lngs === 'string' ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
2154
+ const l = isString(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
2154
2155
  if (l) {
2155
2156
  if (!this.language) {
2156
2157
  setLngProps(l);
@@ -2202,7 +2203,7 @@ class I18n extends EventEmitter {
2202
2203
  }
2203
2204
  return _this3.t(resultKey, options);
2204
2205
  };
2205
- if (typeof lng === 'string') {
2206
+ if (isString(lng)) {
2206
2207
  fixedT.lng = lng;
2207
2208
  } else {
2208
2209
  fixedT.lngs = lng;
@@ -2253,7 +2254,7 @@ class I18n extends EventEmitter {
2253
2254
  if (callback) callback();
2254
2255
  return Promise.resolve();
2255
2256
  }
2256
- if (typeof ns === 'string') ns = [ns];
2257
+ if (isString(ns)) ns = [ns];
2257
2258
  ns.forEach(n => {
2258
2259
  if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
2259
2260
  });
@@ -2265,7 +2266,7 @@ class I18n extends EventEmitter {
2265
2266
  }
2266
2267
  loadLanguages(lngs, callback) {
2267
2268
  const deferred = defer();
2268
- if (typeof lngs === 'string') lngs = [lngs];
2269
+ if (isString(lngs)) lngs = [lngs];
2269
2270
  const preloaded = this.options.preload || [];
2270
2271
  const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
2271
2272
  if (!newLngs.length) {