@bigbinary/neeto-filters-frontend 2.14.1 → 2.14.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.
package/dist/index.cjs.js CHANGED
@@ -6,9 +6,11 @@ var React = require('react');
6
6
  var classnames = require('classnames');
7
7
  var ramda = require('ramda');
8
8
  var neetoui = require('@bigbinary/neetoui');
9
+ var reactI18next = require('react-i18next');
9
10
  var reactRouterDom = require('react-router-dom');
10
11
  var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
11
12
  var neetoIcons = require('@bigbinary/neeto-icons');
13
+ var i18next = require('i18next');
12
14
  var dayjs = require('dayjs');
13
15
  var utils = require('@bigbinary/neeto-commons-frontend/utils');
14
16
  var yup = require('yup');
@@ -43,6 +45,7 @@ function _interopNamespace(e) {
43
45
 
44
46
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
45
47
  var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
48
+ var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
46
49
  var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
47
50
  var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
48
51
  var timezone__default = /*#__PURE__*/_interopDefaultLegacy(timezone);
@@ -52,2919 +55,6 @@ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
52
55
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
53
56
  var MenuBar__default = /*#__PURE__*/_interopDefaultLegacy(MenuBar);
54
57
 
55
- const consoleLogger = {
56
- type: 'logger',
57
- log(args) {
58
- this.output('log', args);
59
- },
60
- warn(args) {
61
- this.output('warn', args);
62
- },
63
- error(args) {
64
- this.output('error', args);
65
- },
66
- output(type, args) {
67
- if (console && console[type]) console[type].apply(console, args);
68
- }
69
- };
70
- class Logger {
71
- constructor(concreteLogger) {
72
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
73
- this.init(concreteLogger, options);
74
- }
75
- init(concreteLogger) {
76
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
77
- this.prefix = options.prefix || 'i18next:';
78
- this.logger = concreteLogger || consoleLogger;
79
- this.options = options;
80
- this.debug = options.debug;
81
- }
82
- log() {
83
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
84
- args[_key] = arguments[_key];
85
- }
86
- return this.forward(args, 'log', '', true);
87
- }
88
- warn() {
89
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
90
- args[_key2] = arguments[_key2];
91
- }
92
- return this.forward(args, 'warn', '', true);
93
- }
94
- error() {
95
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
96
- args[_key3] = arguments[_key3];
97
- }
98
- return this.forward(args, 'error', '');
99
- }
100
- deprecate() {
101
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
102
- args[_key4] = arguments[_key4];
103
- }
104
- return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
105
- }
106
- forward(args, lvl, prefix, debugOnly) {
107
- if (debugOnly && !this.debug) return null;
108
- if (typeof args[0] === 'string') args[0] = `${prefix}${this.prefix} ${args[0]}`;
109
- return this.logger[lvl](args);
110
- }
111
- create(moduleName) {
112
- return new Logger(this.logger, {
113
- ...{
114
- prefix: `${this.prefix}:${moduleName}:`
115
- },
116
- ...this.options
117
- });
118
- }
119
- clone(options) {
120
- options = options || this.options;
121
- options.prefix = options.prefix || this.prefix;
122
- return new Logger(this.logger, options);
123
- }
124
- }
125
- var baseLogger = new Logger();
126
-
127
- class EventEmitter {
128
- constructor() {
129
- this.observers = {};
130
- }
131
- on(events, listener) {
132
- events.split(' ').forEach(event => {
133
- this.observers[event] = this.observers[event] || [];
134
- this.observers[event].push(listener);
135
- });
136
- return this;
137
- }
138
- off(event, listener) {
139
- if (!this.observers[event]) return;
140
- if (!listener) {
141
- delete this.observers[event];
142
- return;
143
- }
144
- this.observers[event] = this.observers[event].filter(l => l !== listener);
145
- }
146
- emit(event) {
147
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
148
- args[_key - 1] = arguments[_key];
149
- }
150
- if (this.observers[event]) {
151
- const cloned = [].concat(this.observers[event]);
152
- cloned.forEach(observer => {
153
- observer(...args);
154
- });
155
- }
156
- if (this.observers['*']) {
157
- const cloned = [].concat(this.observers['*']);
158
- cloned.forEach(observer => {
159
- observer.apply(observer, [event, ...args]);
160
- });
161
- }
162
- }
163
- }
164
-
165
- function defer() {
166
- let res;
167
- let rej;
168
- const promise = new Promise((resolve, reject) => {
169
- res = resolve;
170
- rej = reject;
171
- });
172
- promise.resolve = res;
173
- promise.reject = rej;
174
- return promise;
175
- }
176
- function makeString(object) {
177
- if (object == null) return '';
178
- return '' + object;
179
- }
180
- function copy(a, s, t) {
181
- a.forEach(m => {
182
- if (s[m]) t[m] = s[m];
183
- });
184
- }
185
- function getLastOfPath(object, path, Empty) {
186
- function cleanKey(key) {
187
- return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
188
- }
189
- function canNotTraverseDeeper() {
190
- return !object || typeof object === 'string';
191
- }
192
- const stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
193
- while (stack.length > 1) {
194
- if (canNotTraverseDeeper()) return {};
195
- const key = cleanKey(stack.shift());
196
- if (!object[key] && Empty) object[key] = new Empty();
197
- if (Object.prototype.hasOwnProperty.call(object, key)) {
198
- object = object[key];
199
- } else {
200
- object = {};
201
- }
202
- }
203
- if (canNotTraverseDeeper()) return {};
204
- return {
205
- obj: object,
206
- k: cleanKey(stack.shift())
207
- };
208
- }
209
- function setPath(object, path, newValue) {
210
- const {
211
- obj,
212
- k
213
- } = getLastOfPath(object, path, Object);
214
- obj[k] = newValue;
215
- }
216
- function pushPath(object, path, newValue, concat) {
217
- const {
218
- obj,
219
- k
220
- } = getLastOfPath(object, path, Object);
221
- obj[k] = obj[k] || [];
222
- if (concat) obj[k] = obj[k].concat(newValue);
223
- if (!concat) obj[k].push(newValue);
224
- }
225
- function getPath(object, path) {
226
- const {
227
- obj,
228
- k
229
- } = getLastOfPath(object, path);
230
- if (!obj) return undefined;
231
- return obj[k];
232
- }
233
- function getPathWithDefaults(data, defaultData, key) {
234
- const value = getPath(data, key);
235
- if (value !== undefined) {
236
- return value;
237
- }
238
- return getPath(defaultData, key);
239
- }
240
- function deepExtend(target, source, overwrite) {
241
- for (const prop in source) {
242
- if (prop !== '__proto__' && prop !== 'constructor') {
243
- if (prop in target) {
244
- if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
245
- if (overwrite) target[prop] = source[prop];
246
- } else {
247
- deepExtend(target[prop], source[prop], overwrite);
248
- }
249
- } else {
250
- target[prop] = source[prop];
251
- }
252
- }
253
- }
254
- return target;
255
- }
256
- function regexEscape(str) {
257
- return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
258
- }
259
- var _entityMap = {
260
- '&': '&amp;',
261
- '<': '&lt;',
262
- '>': '&gt;',
263
- '"': '&quot;',
264
- "'": '&#39;',
265
- '/': '&#x2F;'
266
- };
267
- function escape(data) {
268
- if (typeof data === 'string') {
269
- return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
270
- }
271
- return data;
272
- }
273
- const chars = [' ', ',', '?', '!', ';'];
274
- function looksLikeObjectPath(key, nsSeparator, keySeparator) {
275
- nsSeparator = nsSeparator || '';
276
- keySeparator = keySeparator || '';
277
- const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
278
- if (possibleChars.length === 0) return true;
279
- const r = new RegExp(`(${possibleChars.map(c => c === '?' ? '\\?' : c).join('|')})`);
280
- let matched = !r.test(key);
281
- if (!matched) {
282
- const ki = key.indexOf(keySeparator);
283
- if (ki > 0 && !r.test(key.substring(0, ki))) {
284
- matched = true;
285
- }
286
- }
287
- return matched;
288
- }
289
- function deepFind(obj, path) {
290
- let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
291
- if (!obj) return undefined;
292
- if (obj[path]) return obj[path];
293
- const paths = path.split(keySeparator);
294
- let current = obj;
295
- for (let i = 0; i < paths.length; ++i) {
296
- if (!current) return undefined;
297
- if (typeof current[paths[i]] === 'string' && i + 1 < paths.length) {
298
- return undefined;
299
- }
300
- if (current[paths[i]] === undefined) {
301
- let j = 2;
302
- let p = paths.slice(i, i + j).join(keySeparator);
303
- let mix = current[p];
304
- while (mix === undefined && paths.length > i + j) {
305
- j++;
306
- p = paths.slice(i, i + j).join(keySeparator);
307
- mix = current[p];
308
- }
309
- if (mix === undefined) return undefined;
310
- if (mix === null) return null;
311
- if (path.endsWith(p)) {
312
- if (typeof mix === 'string') return mix;
313
- if (p && typeof mix[p] === 'string') return mix[p];
314
- }
315
- const joinedPath = paths.slice(i + j).join(keySeparator);
316
- if (joinedPath) return deepFind(mix, joinedPath, keySeparator);
317
- return undefined;
318
- }
319
- current = current[paths[i]];
320
- }
321
- return current;
322
- }
323
- function getCleanedCode(code) {
324
- if (code && code.indexOf('_') > 0) return code.replace('_', '-');
325
- return code;
326
- }
327
-
328
- class ResourceStore extends EventEmitter {
329
- constructor(data) {
330
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
331
- ns: ['translation'],
332
- defaultNS: 'translation'
333
- };
334
- super();
335
- this.data = data || {};
336
- this.options = options;
337
- if (this.options.keySeparator === undefined) {
338
- this.options.keySeparator = '.';
339
- }
340
- if (this.options.ignoreJSONStructure === undefined) {
341
- this.options.ignoreJSONStructure = true;
342
- }
343
- }
344
- addNamespaces(ns) {
345
- if (this.options.ns.indexOf(ns) < 0) {
346
- this.options.ns.push(ns);
347
- }
348
- }
349
- removeNamespaces(ns) {
350
- const index = this.options.ns.indexOf(ns);
351
- if (index > -1) {
352
- this.options.ns.splice(index, 1);
353
- }
354
- }
355
- getResource(lng, ns, key) {
356
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
357
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
358
- const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
359
- let path = [lng, ns];
360
- if (key && typeof key !== 'string') path = path.concat(key);
361
- if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
362
- if (lng.indexOf('.') > -1) {
363
- path = lng.split('.');
364
- }
365
- const result = getPath(this.data, path);
366
- if (result || !ignoreJSONStructure || typeof key !== 'string') return result;
367
- return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
368
- }
369
- addResource(lng, ns, key, value) {
370
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
371
- silent: false
372
- };
373
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
374
- let path = [lng, ns];
375
- if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
376
- if (lng.indexOf('.') > -1) {
377
- path = lng.split('.');
378
- value = ns;
379
- ns = path[1];
380
- }
381
- this.addNamespaces(ns);
382
- setPath(this.data, path, value);
383
- if (!options.silent) this.emit('added', lng, ns, key, value);
384
- }
385
- addResources(lng, ns, resources) {
386
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
387
- silent: false
388
- };
389
- for (const m in resources) {
390
- if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
391
- silent: true
392
- });
393
- }
394
- if (!options.silent) this.emit('added', lng, ns, resources);
395
- }
396
- addResourceBundle(lng, ns, resources, deep, overwrite) {
397
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
398
- silent: false
399
- };
400
- let path = [lng, ns];
401
- if (lng.indexOf('.') > -1) {
402
- path = lng.split('.');
403
- deep = resources;
404
- resources = ns;
405
- ns = path[1];
406
- }
407
- this.addNamespaces(ns);
408
- let pack = getPath(this.data, path) || {};
409
- if (deep) {
410
- deepExtend(pack, resources, overwrite);
411
- } else {
412
- pack = {
413
- ...pack,
414
- ...resources
415
- };
416
- }
417
- setPath(this.data, path, pack);
418
- if (!options.silent) this.emit('added', lng, ns, resources);
419
- }
420
- removeResourceBundle(lng, ns) {
421
- if (this.hasResourceBundle(lng, ns)) {
422
- delete this.data[lng][ns];
423
- }
424
- this.removeNamespaces(ns);
425
- this.emit('removed', lng, ns);
426
- }
427
- hasResourceBundle(lng, ns) {
428
- return this.getResource(lng, ns) !== undefined;
429
- }
430
- getResourceBundle(lng, ns) {
431
- if (!ns) ns = this.options.defaultNS;
432
- if (this.options.compatibilityAPI === 'v1') return {
433
- ...{},
434
- ...this.getResource(lng, ns)
435
- };
436
- return this.getResource(lng, ns);
437
- }
438
- getDataByLanguage(lng) {
439
- return this.data[lng];
440
- }
441
- hasLanguageSomeTranslations(lng) {
442
- const data = this.getDataByLanguage(lng);
443
- const n = data && Object.keys(data) || [];
444
- return !!n.find(v => data[v] && Object.keys(data[v]).length > 0);
445
- }
446
- toJSON() {
447
- return this.data;
448
- }
449
- }
450
-
451
- var postProcessor = {
452
- processors: {},
453
- addPostProcessor(module) {
454
- this.processors[module.name] = module;
455
- },
456
- handle(processors, value, key, options, translator) {
457
- processors.forEach(processor => {
458
- if (this.processors[processor]) value = this.processors[processor].process(value, key, options, translator);
459
- });
460
- return value;
461
- }
462
- };
463
-
464
- const checkedLoadedFor = {};
465
- class Translator extends EventEmitter {
466
- constructor(services) {
467
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
468
- super();
469
- copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
470
- this.options = options;
471
- if (this.options.keySeparator === undefined) {
472
- this.options.keySeparator = '.';
473
- }
474
- this.logger = baseLogger.create('translator');
475
- }
476
- changeLanguage(lng) {
477
- if (lng) this.language = lng;
478
- }
479
- exists(key) {
480
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
481
- interpolation: {}
482
- };
483
- if (key === undefined || key === null) {
484
- return false;
485
- }
486
- const resolved = this.resolve(key, options);
487
- return resolved && resolved.res !== undefined;
488
- }
489
- extractFromKey(key, options) {
490
- let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
491
- if (nsSeparator === undefined) nsSeparator = ':';
492
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
493
- let namespaces = options.ns || this.options.defaultNS || [];
494
- const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
495
- const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
496
- if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
497
- const m = key.match(this.interpolator.nestingRegexp);
498
- if (m && m.length > 0) {
499
- return {
500
- key,
501
- namespaces
502
- };
503
- }
504
- const parts = key.split(nsSeparator);
505
- if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
506
- key = parts.join(keySeparator);
507
- }
508
- if (typeof namespaces === 'string') namespaces = [namespaces];
509
- return {
510
- key,
511
- namespaces
512
- };
513
- }
514
- translate(keys, options, lastKey) {
515
- if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {
516
- options = this.options.overloadTranslationOptionHandler(arguments);
517
- }
518
- if (typeof options === 'object') options = {
519
- ...options
520
- };
521
- if (!options) options = {};
522
- if (keys === undefined || keys === null) return '';
523
- if (!Array.isArray(keys)) keys = [String(keys)];
524
- const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
525
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
526
- const {
527
- key,
528
- namespaces
529
- } = this.extractFromKey(keys[keys.length - 1], options);
530
- const namespace = namespaces[namespaces.length - 1];
531
- const lng = options.lng || this.language;
532
- const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
533
- if (lng && lng.toLowerCase() === 'cimode') {
534
- if (appendNamespaceToCIMode) {
535
- const nsSeparator = options.nsSeparator || this.options.nsSeparator;
536
- if (returnDetails) {
537
- return {
538
- res: `${namespace}${nsSeparator}${key}`,
539
- usedKey: key,
540
- exactUsedKey: key,
541
- usedLng: lng,
542
- usedNS: namespace
543
- };
544
- }
545
- return `${namespace}${nsSeparator}${key}`;
546
- }
547
- if (returnDetails) {
548
- return {
549
- res: key,
550
- usedKey: key,
551
- exactUsedKey: key,
552
- usedLng: lng,
553
- usedNS: namespace
554
- };
555
- }
556
- return key;
557
- }
558
- const resolved = this.resolve(keys, options);
559
- let res = resolved && resolved.res;
560
- const resUsedKey = resolved && resolved.usedKey || key;
561
- const resExactUsedKey = resolved && resolved.exactUsedKey || key;
562
- const resType = Object.prototype.toString.apply(res);
563
- const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
564
- const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
565
- const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
566
- const handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
567
- if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
568
- if (!options.returnObjects && !this.options.returnObjects) {
569
- if (!this.options.returnedObjectHandler) {
570
- this.logger.warn('accessing an object - but returnObjects options is not enabled!');
571
- }
572
- const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, {
573
- ...options,
574
- ns: namespaces
575
- }) : `key '${key} (${this.language})' returned an object instead of string.`;
576
- if (returnDetails) {
577
- resolved.res = r;
578
- return resolved;
579
- }
580
- return r;
581
- }
582
- if (keySeparator) {
583
- const resTypeIsArray = resType === '[object Array]';
584
- const copy = resTypeIsArray ? [] : {};
585
- const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
586
- for (const m in res) {
587
- if (Object.prototype.hasOwnProperty.call(res, m)) {
588
- const deepKey = `${newKeyToUse}${keySeparator}${m}`;
589
- copy[m] = this.translate(deepKey, {
590
- ...options,
591
- ...{
592
- joinArrays: false,
593
- ns: namespaces
594
- }
595
- });
596
- if (copy[m] === deepKey) copy[m] = res[m];
597
- }
598
- }
599
- res = copy;
600
- }
601
- } else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
602
- res = res.join(joinArrays);
603
- if (res) res = this.extendTranslation(res, keys, options, lastKey);
604
- } else {
605
- let usedDefault = false;
606
- let usedKey = false;
607
- const needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
608
- const hasDefaultValue = Translator.hasDefaultValue(options);
609
- const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
610
- const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
611
- ordinal: false
612
- }) : '';
613
- const defaultValue = options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
614
- if (!this.isValidLookup(res) && hasDefaultValue) {
615
- usedDefault = true;
616
- res = defaultValue;
617
- }
618
- if (!this.isValidLookup(res)) {
619
- usedKey = true;
620
- res = key;
621
- }
622
- const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
623
- const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
624
- const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
625
- if (usedKey || usedDefault || updateMissing) {
626
- this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
627
- if (keySeparator) {
628
- const fk = this.resolve(key, {
629
- ...options,
630
- keySeparator: false
631
- });
632
- if (fk && fk.res) this.logger.warn('Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.');
633
- }
634
- let lngs = [];
635
- const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
636
- if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
637
- for (let i = 0; i < fallbackLngs.length; i++) {
638
- lngs.push(fallbackLngs[i]);
639
- }
640
- } else if (this.options.saveMissingTo === 'all') {
641
- lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
642
- } else {
643
- lngs.push(options.lng || this.language);
644
- }
645
- const send = (l, k, specificDefaultValue) => {
646
- const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
647
- if (this.options.missingKeyHandler) {
648
- this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
649
- } else if (this.backendConnector && this.backendConnector.saveMissing) {
650
- this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
651
- }
652
- this.emit('missingKey', l, namespace, k, res);
653
- };
654
- if (this.options.saveMissing) {
655
- if (this.options.saveMissingPlurals && needsPluralHandling) {
656
- lngs.forEach(language => {
657
- this.pluralResolver.getSuffixes(language, options).forEach(suffix => {
658
- send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
659
- });
660
- });
661
- } else {
662
- send(lngs, key, defaultValue);
663
- }
664
- }
665
- }
666
- res = this.extendTranslation(res, keys, options, resolved, lastKey);
667
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
668
- if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
669
- if (this.options.compatibilityAPI !== 'v1') {
670
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
671
- } else {
672
- res = this.options.parseMissingKeyHandler(res);
673
- }
674
- }
675
- }
676
- if (returnDetails) {
677
- resolved.res = res;
678
- return resolved;
679
- }
680
- return res;
681
- }
682
- extendTranslation(res, key, options, resolved, lastKey) {
683
- var _this = this;
684
- if (this.i18nFormat && this.i18nFormat.parse) {
685
- res = this.i18nFormat.parse(res, {
686
- ...this.options.interpolation.defaultVariables,
687
- ...options
688
- }, resolved.usedLng, resolved.usedNS, resolved.usedKey, {
689
- resolved
690
- });
691
- } else if (!options.skipInterpolation) {
692
- if (options.interpolation) this.interpolator.init({
693
- ...options,
694
- ...{
695
- interpolation: {
696
- ...this.options.interpolation,
697
- ...options.interpolation
698
- }
699
- }
700
- });
701
- const skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
702
- let nestBef;
703
- if (skipOnVariables) {
704
- const nb = res.match(this.interpolator.nestingRegexp);
705
- nestBef = nb && nb.length;
706
- }
707
- let data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
708
- if (this.options.interpolation.defaultVariables) data = {
709
- ...this.options.interpolation.defaultVariables,
710
- ...data
711
- };
712
- res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
713
- if (skipOnVariables) {
714
- const na = res.match(this.interpolator.nestingRegexp);
715
- const nestAft = na && na.length;
716
- if (nestBef < nestAft) options.nest = false;
717
- }
718
- if (!options.lng && this.options.compatibilityAPI !== 'v1' && resolved && resolved.res) options.lng = resolved.usedLng;
719
- if (options.nest !== false) res = this.interpolator.nest(res, function () {
720
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
721
- args[_key] = arguments[_key];
722
- }
723
- if (lastKey && lastKey[0] === args[0] && !options.context) {
724
- _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
725
- return null;
726
- }
727
- return _this.translate(...args, key);
728
- }, options);
729
- if (options.interpolation) this.interpolator.reset();
730
- }
731
- const postProcess = options.postProcess || this.options.postProcess;
732
- const postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
733
- if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
734
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
735
- i18nResolved: resolved,
736
- ...options
737
- } : options, this);
738
- }
739
- return res;
740
- }
741
- resolve(keys) {
742
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
743
- let found;
744
- let usedKey;
745
- let exactUsedKey;
746
- let usedLng;
747
- let usedNS;
748
- if (typeof keys === 'string') keys = [keys];
749
- keys.forEach(k => {
750
- if (this.isValidLookup(found)) return;
751
- const extracted = this.extractFromKey(k, options);
752
- const key = extracted.key;
753
- usedKey = key;
754
- let namespaces = extracted.namespaces;
755
- if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
756
- const needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
757
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
758
- const needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';
759
- const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
760
- namespaces.forEach(ns => {
761
- if (this.isValidLookup(found)) return;
762
- usedNS = ns;
763
- if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(usedNS)) {
764
- checkedLoadedFor[`${codes[0]}-${ns}`] = true;
765
- this.logger.warn(`key "${usedKey}" for languages "${codes.join(', ')}" won't get resolved as namespace "${usedNS}" was not yet loaded`, 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
766
- }
767
- codes.forEach(code => {
768
- if (this.isValidLookup(found)) return;
769
- usedLng = code;
770
- const finalKeys = [key];
771
- if (this.i18nFormat && this.i18nFormat.addLookupKeys) {
772
- this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
773
- } else {
774
- let pluralSuffix;
775
- if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
776
- const zeroSuffix = `${this.options.pluralSeparator}zero`;
777
- const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
778
- if (needsPluralHandling) {
779
- finalKeys.push(key + pluralSuffix);
780
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
781
- finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
782
- }
783
- if (needsZeroSuffixLookup) {
784
- finalKeys.push(key + zeroSuffix);
785
- }
786
- }
787
- if (needsContextHandling) {
788
- const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
789
- finalKeys.push(contextKey);
790
- if (needsPluralHandling) {
791
- finalKeys.push(contextKey + pluralSuffix);
792
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
793
- finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
794
- }
795
- if (needsZeroSuffixLookup) {
796
- finalKeys.push(contextKey + zeroSuffix);
797
- }
798
- }
799
- }
800
- }
801
- let possibleKey;
802
- while (possibleKey = finalKeys.pop()) {
803
- if (!this.isValidLookup(found)) {
804
- exactUsedKey = possibleKey;
805
- found = this.getResource(code, ns, possibleKey, options);
806
- }
807
- }
808
- });
809
- });
810
- });
811
- return {
812
- res: found,
813
- usedKey,
814
- exactUsedKey,
815
- usedLng,
816
- usedNS
817
- };
818
- }
819
- isValidLookup(res) {
820
- return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
821
- }
822
- getResource(code, ns, key) {
823
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
824
- if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
825
- return this.resourceStore.getResource(code, ns, key, options);
826
- }
827
- static hasDefaultValue(options) {
828
- const prefix = 'defaultValue';
829
- for (const option in options) {
830
- if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
831
- return true;
832
- }
833
- }
834
- return false;
835
- }
836
- }
837
-
838
- function capitalize$1(string) {
839
- return string.charAt(0).toUpperCase() + string.slice(1);
840
- }
841
- class LanguageUtil {
842
- constructor(options) {
843
- this.options = options;
844
- this.supportedLngs = this.options.supportedLngs || false;
845
- this.logger = baseLogger.create('languageUtils');
846
- }
847
- getScriptPartFromCode(code) {
848
- code = getCleanedCode(code);
849
- if (!code || code.indexOf('-') < 0) return null;
850
- const p = code.split('-');
851
- if (p.length === 2) return null;
852
- p.pop();
853
- if (p[p.length - 1].toLowerCase() === 'x') return null;
854
- return this.formatLanguageCode(p.join('-'));
855
- }
856
- getLanguagePartFromCode(code) {
857
- code = getCleanedCode(code);
858
- if (!code || code.indexOf('-') < 0) return code;
859
- const p = code.split('-');
860
- return this.formatLanguageCode(p[0]);
861
- }
862
- formatLanguageCode(code) {
863
- if (typeof code === 'string' && code.indexOf('-') > -1) {
864
- const specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
865
- let p = code.split('-');
866
- if (this.options.lowerCaseLng) {
867
- p = p.map(part => part.toLowerCase());
868
- } else if (p.length === 2) {
869
- p[0] = p[0].toLowerCase();
870
- p[1] = p[1].toUpperCase();
871
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize$1(p[1].toLowerCase());
872
- } else if (p.length === 3) {
873
- p[0] = p[0].toLowerCase();
874
- if (p[1].length === 2) p[1] = p[1].toUpperCase();
875
- if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
876
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize$1(p[1].toLowerCase());
877
- if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize$1(p[2].toLowerCase());
878
- }
879
- return p.join('-');
880
- }
881
- return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
882
- }
883
- isSupportedCode(code) {
884
- if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
885
- code = this.getLanguagePartFromCode(code);
886
- }
887
- return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
888
- }
889
- getBestMatchFromCodes(codes) {
890
- if (!codes) return null;
891
- let found;
892
- codes.forEach(code => {
893
- if (found) return;
894
- const cleanedLng = this.formatLanguageCode(code);
895
- if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
896
- });
897
- if (!found && this.options.supportedLngs) {
898
- codes.forEach(code => {
899
- if (found) return;
900
- const lngOnly = this.getLanguagePartFromCode(code);
901
- if (this.isSupportedCode(lngOnly)) return found = lngOnly;
902
- found = this.options.supportedLngs.find(supportedLng => {
903
- if (supportedLng === lngOnly) return supportedLng;
904
- if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
905
- if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;
906
- });
907
- });
908
- }
909
- if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
910
- return found;
911
- }
912
- getFallbackCodes(fallbacks, code) {
913
- if (!fallbacks) return [];
914
- if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
915
- if (typeof fallbacks === 'string') fallbacks = [fallbacks];
916
- if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;
917
- if (!code) return fallbacks.default || [];
918
- let found = fallbacks[code];
919
- if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
920
- if (!found) found = fallbacks[this.formatLanguageCode(code)];
921
- if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
922
- if (!found) found = fallbacks.default;
923
- return found || [];
924
- }
925
- toResolveHierarchy(code, fallbackCode) {
926
- const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
927
- const codes = [];
928
- const addCode = c => {
929
- if (!c) return;
930
- if (this.isSupportedCode(c)) {
931
- codes.push(c);
932
- } else {
933
- this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
934
- }
935
- };
936
- if (typeof code === 'string' && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
937
- if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
938
- if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
939
- if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
940
- } else if (typeof code === 'string') {
941
- addCode(this.formatLanguageCode(code));
942
- }
943
- fallbackCodes.forEach(fc => {
944
- if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
945
- });
946
- return codes;
947
- }
948
- }
949
-
950
- let sets = [{
951
- lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
952
- nr: [1, 2],
953
- fc: 1
954
- }, {
955
- lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'hi', 'hu', 'hy', 'ia', 'it', 'kk', 'kn', 'ku', 'lb', 'mai', 'ml', 'mn', 'mr', 'nah', 'nap', 'nb', 'ne', 'nl', 'nn', 'no', 'nso', 'pa', 'pap', 'pms', 'ps', 'pt-PT', 'rm', 'sco', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw', 'ta', 'te', 'tk', 'ur', 'yo'],
956
- nr: [1, 2],
957
- fc: 2
958
- }, {
959
- lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
960
- nr: [1],
961
- fc: 3
962
- }, {
963
- lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
964
- nr: [1, 2, 5],
965
- fc: 4
966
- }, {
967
- lngs: ['ar'],
968
- nr: [0, 1, 2, 3, 11, 100],
969
- fc: 5
970
- }, {
971
- lngs: ['cs', 'sk'],
972
- nr: [1, 2, 5],
973
- fc: 6
974
- }, {
975
- lngs: ['csb', 'pl'],
976
- nr: [1, 2, 5],
977
- fc: 7
978
- }, {
979
- lngs: ['cy'],
980
- nr: [1, 2, 3, 8],
981
- fc: 8
982
- }, {
983
- lngs: ['fr'],
984
- nr: [1, 2],
985
- fc: 9
986
- }, {
987
- lngs: ['ga'],
988
- nr: [1, 2, 3, 7, 11],
989
- fc: 10
990
- }, {
991
- lngs: ['gd'],
992
- nr: [1, 2, 3, 20],
993
- fc: 11
994
- }, {
995
- lngs: ['is'],
996
- nr: [1, 2],
997
- fc: 12
998
- }, {
999
- lngs: ['jv'],
1000
- nr: [0, 1],
1001
- fc: 13
1002
- }, {
1003
- lngs: ['kw'],
1004
- nr: [1, 2, 3, 4],
1005
- fc: 14
1006
- }, {
1007
- lngs: ['lt'],
1008
- nr: [1, 2, 10],
1009
- fc: 15
1010
- }, {
1011
- lngs: ['lv'],
1012
- nr: [1, 2, 0],
1013
- fc: 16
1014
- }, {
1015
- lngs: ['mk'],
1016
- nr: [1, 2],
1017
- fc: 17
1018
- }, {
1019
- lngs: ['mnk'],
1020
- nr: [0, 1, 2],
1021
- fc: 18
1022
- }, {
1023
- lngs: ['mt'],
1024
- nr: [1, 2, 11, 20],
1025
- fc: 19
1026
- }, {
1027
- lngs: ['or'],
1028
- nr: [2, 1],
1029
- fc: 2
1030
- }, {
1031
- lngs: ['ro'],
1032
- nr: [1, 2, 20],
1033
- fc: 20
1034
- }, {
1035
- lngs: ['sl'],
1036
- nr: [5, 1, 2, 3],
1037
- fc: 21
1038
- }, {
1039
- lngs: ['he', 'iw'],
1040
- nr: [1, 2, 20, 21],
1041
- fc: 22
1042
- }];
1043
- let _rulesPluralsTypes = {
1044
- 1: function (n) {
1045
- return Number(n > 1);
1046
- },
1047
- 2: function (n) {
1048
- return Number(n != 1);
1049
- },
1050
- 3: function (n) {
1051
- return 0;
1052
- },
1053
- 4: function (n) {
1054
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1055
- },
1056
- 5: function (n) {
1057
- return Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
1058
- },
1059
- 6: function (n) {
1060
- return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
1061
- },
1062
- 7: function (n) {
1063
- return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1064
- },
1065
- 8: function (n) {
1066
- return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
1067
- },
1068
- 9: function (n) {
1069
- return Number(n >= 2);
1070
- },
1071
- 10: function (n) {
1072
- return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
1073
- },
1074
- 11: function (n) {
1075
- return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
1076
- },
1077
- 12: function (n) {
1078
- return Number(n % 10 != 1 || n % 100 == 11);
1079
- },
1080
- 13: function (n) {
1081
- return Number(n !== 0);
1082
- },
1083
- 14: function (n) {
1084
- return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
1085
- },
1086
- 15: function (n) {
1087
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1088
- },
1089
- 16: function (n) {
1090
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
1091
- },
1092
- 17: function (n) {
1093
- return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);
1094
- },
1095
- 18: function (n) {
1096
- return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
1097
- },
1098
- 19: function (n) {
1099
- return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
1100
- },
1101
- 20: function (n) {
1102
- return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
1103
- },
1104
- 21: function (n) {
1105
- return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
1106
- },
1107
- 22: function (n) {
1108
- return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
1109
- }
1110
- };
1111
- const nonIntlVersions = ['v1', 'v2', 'v3'];
1112
- const intlVersions = ['v4'];
1113
- const suffixesOrder = {
1114
- zero: 0,
1115
- one: 1,
1116
- two: 2,
1117
- few: 3,
1118
- many: 4,
1119
- other: 5
1120
- };
1121
- function createRules() {
1122
- const rules = {};
1123
- sets.forEach(set => {
1124
- set.lngs.forEach(l => {
1125
- rules[l] = {
1126
- numbers: set.nr,
1127
- plurals: _rulesPluralsTypes[set.fc]
1128
- };
1129
- });
1130
- });
1131
- return rules;
1132
- }
1133
- class PluralResolver {
1134
- constructor(languageUtils) {
1135
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1136
- this.languageUtils = languageUtils;
1137
- this.options = options;
1138
- this.logger = baseLogger.create('pluralResolver');
1139
- if ((!this.options.compatibilityJSON || intlVersions.includes(this.options.compatibilityJSON)) && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
1140
- this.options.compatibilityJSON = 'v3';
1141
- this.logger.error('Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.');
1142
- }
1143
- this.rules = createRules();
1144
- }
1145
- addRule(lng, obj) {
1146
- this.rules[lng] = obj;
1147
- }
1148
- getRule(code) {
1149
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1150
- if (this.shouldUseIntlApi()) {
1151
- try {
1152
- return new Intl.PluralRules(getCleanedCode(code), {
1153
- type: options.ordinal ? 'ordinal' : 'cardinal'
1154
- });
1155
- } catch {
1156
- return;
1157
- }
1158
- }
1159
- return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
1160
- }
1161
- needsPlural(code) {
1162
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1163
- const rule = this.getRule(code, options);
1164
- if (this.shouldUseIntlApi()) {
1165
- return rule && rule.resolvedOptions().pluralCategories.length > 1;
1166
- }
1167
- return rule && rule.numbers.length > 1;
1168
- }
1169
- getPluralFormsOfKey(code, key) {
1170
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1171
- return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
1172
- }
1173
- getSuffixes(code) {
1174
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1175
- const rule = this.getRule(code, options);
1176
- if (!rule) {
1177
- return [];
1178
- }
1179
- if (this.shouldUseIntlApi()) {
1180
- return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
1181
- }
1182
- return rule.numbers.map(number => this.getSuffix(code, number, options));
1183
- }
1184
- getSuffix(code, count) {
1185
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1186
- const rule = this.getRule(code, options);
1187
- if (rule) {
1188
- if (this.shouldUseIntlApi()) {
1189
- return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
1190
- }
1191
- return this.getSuffixRetroCompatible(rule, count);
1192
- }
1193
- this.logger.warn(`no plural rule found for: ${code}`);
1194
- return '';
1195
- }
1196
- getSuffixRetroCompatible(rule, count) {
1197
- const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
1198
- let suffix = rule.numbers[idx];
1199
- if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1200
- if (suffix === 2) {
1201
- suffix = 'plural';
1202
- } else if (suffix === 1) {
1203
- suffix = '';
1204
- }
1205
- }
1206
- const returnSuffix = () => this.options.prepend && suffix.toString() ? this.options.prepend + suffix.toString() : suffix.toString();
1207
- if (this.options.compatibilityJSON === 'v1') {
1208
- if (suffix === 1) return '';
1209
- if (typeof suffix === 'number') return `_plural_${suffix.toString()}`;
1210
- return returnSuffix();
1211
- } else if (this.options.compatibilityJSON === 'v2') {
1212
- return returnSuffix();
1213
- } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1214
- return returnSuffix();
1215
- }
1216
- return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
1217
- }
1218
- shouldUseIntlApi() {
1219
- return !nonIntlVersions.includes(this.options.compatibilityJSON);
1220
- }
1221
- }
1222
-
1223
- function deepFindWithDefaults(data, defaultData, key) {
1224
- let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
1225
- let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1226
- let path = getPathWithDefaults(data, defaultData, key);
1227
- if (!path && ignoreJSONStructure && typeof key === 'string') {
1228
- path = deepFind(data, key, keySeparator);
1229
- if (path === undefined) path = deepFind(defaultData, key, keySeparator);
1230
- }
1231
- return path;
1232
- }
1233
- class Interpolator {
1234
- constructor() {
1235
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1236
- this.logger = baseLogger.create('interpolator');
1237
- this.options = options;
1238
- this.format = options.interpolation && options.interpolation.format || (value => value);
1239
- this.init(options);
1240
- }
1241
- init() {
1242
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1243
- if (!options.interpolation) options.interpolation = {
1244
- escapeValue: true
1245
- };
1246
- const iOpts = options.interpolation;
1247
- this.escape = iOpts.escape !== undefined ? iOpts.escape : escape;
1248
- this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;
1249
- this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;
1250
- this.prefix = iOpts.prefix ? regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';
1251
- this.suffix = iOpts.suffix ? regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';
1252
- this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
1253
- this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';
1254
- this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';
1255
- this.nestingPrefix = iOpts.nestingPrefix ? regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || regexEscape('$t(');
1256
- this.nestingSuffix = iOpts.nestingSuffix ? regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || regexEscape(')');
1257
- this.nestingOptionsSeparator = iOpts.nestingOptionsSeparator ? iOpts.nestingOptionsSeparator : iOpts.nestingOptionsSeparator || ',';
1258
- this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000;
1259
- this.alwaysFormat = iOpts.alwaysFormat !== undefined ? iOpts.alwaysFormat : false;
1260
- this.resetRegExp();
1261
- }
1262
- reset() {
1263
- if (this.options) this.init(this.options);
1264
- }
1265
- resetRegExp() {
1266
- const regexpStr = `${this.prefix}(.+?)${this.suffix}`;
1267
- this.regexp = new RegExp(regexpStr, 'g');
1268
- const regexpUnescapeStr = `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;
1269
- this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');
1270
- const nestingRegexpStr = `${this.nestingPrefix}(.+?)${this.nestingSuffix}`;
1271
- this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
1272
- }
1273
- interpolate(str, data, lng, options) {
1274
- let match;
1275
- let value;
1276
- let replaces;
1277
- const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
1278
- function regexSafe(val) {
1279
- return val.replace(/\$/g, '$$$$');
1280
- }
1281
- const handleFormat = key => {
1282
- if (key.indexOf(this.formatSeparator) < 0) {
1283
- const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
1284
- return this.alwaysFormat ? this.format(path, undefined, lng, {
1285
- ...options,
1286
- ...data,
1287
- interpolationkey: key
1288
- }) : path;
1289
- }
1290
- const p = key.split(this.formatSeparator);
1291
- const k = p.shift().trim();
1292
- const f = p.join(this.formatSeparator).trim();
1293
- return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
1294
- ...options,
1295
- ...data,
1296
- interpolationkey: k
1297
- });
1298
- };
1299
- this.resetRegExp();
1300
- const missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
1301
- const skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1302
- const todos = [{
1303
- regex: this.regexpUnescape,
1304
- safeValue: val => regexSafe(val)
1305
- }, {
1306
- regex: this.regexp,
1307
- safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
1308
- }];
1309
- todos.forEach(todo => {
1310
- replaces = 0;
1311
- while (match = todo.regex.exec(str)) {
1312
- const matchedVar = match[1].trim();
1313
- value = handleFormat(matchedVar);
1314
- if (value === undefined) {
1315
- if (typeof missingInterpolationHandler === 'function') {
1316
- const temp = missingInterpolationHandler(str, match, options);
1317
- value = typeof temp === 'string' ? temp : '';
1318
- } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
1319
- value = '';
1320
- } else if (skipOnVariables) {
1321
- value = match[0];
1322
- continue;
1323
- } else {
1324
- this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
1325
- value = '';
1326
- }
1327
- } else if (typeof value !== 'string' && !this.useRawValueToEscape) {
1328
- value = makeString(value);
1329
- }
1330
- const safeValue = todo.safeValue(value);
1331
- str = str.replace(match[0], safeValue);
1332
- if (skipOnVariables) {
1333
- todo.regex.lastIndex += value.length;
1334
- todo.regex.lastIndex -= match[0].length;
1335
- } else {
1336
- todo.regex.lastIndex = 0;
1337
- }
1338
- replaces++;
1339
- if (replaces >= this.maxReplaces) {
1340
- break;
1341
- }
1342
- }
1343
- });
1344
- return str;
1345
- }
1346
- nest(str, fc) {
1347
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1348
- let match;
1349
- let value;
1350
- let clonedOptions;
1351
- function handleHasOptions(key, inheritedOptions) {
1352
- const sep = this.nestingOptionsSeparator;
1353
- if (key.indexOf(sep) < 0) return key;
1354
- const c = key.split(new RegExp(`${sep}[ ]*{`));
1355
- let optionsString = `{${c[1]}`;
1356
- key = c[0];
1357
- optionsString = this.interpolate(optionsString, clonedOptions);
1358
- const matchedSingleQuotes = optionsString.match(/'/g);
1359
- const matchedDoubleQuotes = optionsString.match(/"/g);
1360
- if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
1361
- optionsString = optionsString.replace(/'/g, '"');
1362
- }
1363
- try {
1364
- clonedOptions = JSON.parse(optionsString);
1365
- if (inheritedOptions) clonedOptions = {
1366
- ...inheritedOptions,
1367
- ...clonedOptions
1368
- };
1369
- } catch (e) {
1370
- this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
1371
- return `${key}${sep}${optionsString}`;
1372
- }
1373
- delete clonedOptions.defaultValue;
1374
- return key;
1375
- }
1376
- while (match = this.nestingRegexp.exec(str)) {
1377
- let formatters = [];
1378
- clonedOptions = {
1379
- ...options
1380
- };
1381
- clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;
1382
- clonedOptions.applyPostProcessor = false;
1383
- delete clonedOptions.defaultValue;
1384
- let doReduce = false;
1385
- if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
1386
- const r = match[1].split(this.formatSeparator).map(elem => elem.trim());
1387
- match[1] = r.shift();
1388
- formatters = r;
1389
- doReduce = true;
1390
- }
1391
- value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1392
- if (value && match[0] === str && typeof value !== 'string') return value;
1393
- if (typeof value !== 'string') value = makeString(value);
1394
- if (!value) {
1395
- this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1396
- value = '';
1397
- }
1398
- if (doReduce) {
1399
- value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
1400
- ...options,
1401
- interpolationkey: match[1].trim()
1402
- }), value.trim());
1403
- }
1404
- str = str.replace(match[0], value);
1405
- this.regexp.lastIndex = 0;
1406
- }
1407
- return str;
1408
- }
1409
- }
1410
-
1411
- function parseFormatStr(formatStr) {
1412
- let formatName = formatStr.toLowerCase().trim();
1413
- const formatOptions = {};
1414
- if (formatStr.indexOf('(') > -1) {
1415
- const p = formatStr.split('(');
1416
- formatName = p[0].toLowerCase().trim();
1417
- const optStr = p[1].substring(0, p[1].length - 1);
1418
- if (formatName === 'currency' && optStr.indexOf(':') < 0) {
1419
- if (!formatOptions.currency) formatOptions.currency = optStr.trim();
1420
- } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
1421
- if (!formatOptions.range) formatOptions.range = optStr.trim();
1422
- } else {
1423
- const opts = optStr.split(';');
1424
- opts.forEach(opt => {
1425
- if (!opt) return;
1426
- const [key, ...rest] = opt.split(':');
1427
- const val = rest.join(':').trim().replace(/^'+|'+$/g, '');
1428
- if (!formatOptions[key.trim()]) formatOptions[key.trim()] = val;
1429
- if (val === 'false') formatOptions[key.trim()] = false;
1430
- if (val === 'true') formatOptions[key.trim()] = true;
1431
- if (!isNaN(val)) formatOptions[key.trim()] = parseInt(val, 10);
1432
- });
1433
- }
1434
- }
1435
- return {
1436
- formatName,
1437
- formatOptions
1438
- };
1439
- }
1440
- function createCachedFormatter(fn) {
1441
- const cache = {};
1442
- return function invokeFormatter(val, lng, options) {
1443
- const key = lng + JSON.stringify(options);
1444
- let formatter = cache[key];
1445
- if (!formatter) {
1446
- formatter = fn(getCleanedCode(lng), options);
1447
- cache[key] = formatter;
1448
- }
1449
- return formatter(val);
1450
- };
1451
- }
1452
- class Formatter {
1453
- constructor() {
1454
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1455
- this.logger = baseLogger.create('formatter');
1456
- this.options = options;
1457
- this.formats = {
1458
- number: createCachedFormatter((lng, opt) => {
1459
- const formatter = new Intl.NumberFormat(lng, {
1460
- ...opt
1461
- });
1462
- return val => formatter.format(val);
1463
- }),
1464
- currency: createCachedFormatter((lng, opt) => {
1465
- const formatter = new Intl.NumberFormat(lng, {
1466
- ...opt,
1467
- style: 'currency'
1468
- });
1469
- return val => formatter.format(val);
1470
- }),
1471
- datetime: createCachedFormatter((lng, opt) => {
1472
- const formatter = new Intl.DateTimeFormat(lng, {
1473
- ...opt
1474
- });
1475
- return val => formatter.format(val);
1476
- }),
1477
- relativetime: createCachedFormatter((lng, opt) => {
1478
- const formatter = new Intl.RelativeTimeFormat(lng, {
1479
- ...opt
1480
- });
1481
- return val => formatter.format(val, opt.range || 'day');
1482
- }),
1483
- list: createCachedFormatter((lng, opt) => {
1484
- const formatter = new Intl.ListFormat(lng, {
1485
- ...opt
1486
- });
1487
- return val => formatter.format(val);
1488
- })
1489
- };
1490
- this.init(options);
1491
- }
1492
- init(services) {
1493
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1494
- interpolation: {}
1495
- };
1496
- const iOpts = options.interpolation;
1497
- this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
1498
- }
1499
- add(name, fc) {
1500
- this.formats[name.toLowerCase().trim()] = fc;
1501
- }
1502
- addCached(name, fc) {
1503
- this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1504
- }
1505
- format(value, format, lng) {
1506
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1507
- const formats = format.split(this.formatSeparator);
1508
- const result = formats.reduce((mem, f) => {
1509
- const {
1510
- formatName,
1511
- formatOptions
1512
- } = parseFormatStr(f);
1513
- if (this.formats[formatName]) {
1514
- let formatted = mem;
1515
- try {
1516
- const valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
1517
- const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1518
- formatted = this.formats[formatName](mem, l, {
1519
- ...formatOptions,
1520
- ...options,
1521
- ...valOptions
1522
- });
1523
- } catch (error) {
1524
- this.logger.warn(error);
1525
- }
1526
- return formatted;
1527
- } else {
1528
- this.logger.warn(`there was no format function for ${formatName}`);
1529
- }
1530
- return mem;
1531
- }, value);
1532
- return result;
1533
- }
1534
- }
1535
-
1536
- function removePending(q, name) {
1537
- if (q.pending[name] !== undefined) {
1538
- delete q.pending[name];
1539
- q.pendingCount--;
1540
- }
1541
- }
1542
- class Connector extends EventEmitter {
1543
- constructor(backend, store, services) {
1544
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1545
- super();
1546
- this.backend = backend;
1547
- this.store = store;
1548
- this.services = services;
1549
- this.languageUtils = services.languageUtils;
1550
- this.options = options;
1551
- this.logger = baseLogger.create('backendConnector');
1552
- this.waitingReads = [];
1553
- this.maxParallelReads = options.maxParallelReads || 10;
1554
- this.readingCalls = 0;
1555
- this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
1556
- this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
1557
- this.state = {};
1558
- this.queue = [];
1559
- if (this.backend && this.backend.init) {
1560
- this.backend.init(services, options.backend, options);
1561
- }
1562
- }
1563
- queueLoad(languages, namespaces, options, callback) {
1564
- const toLoad = {};
1565
- const pending = {};
1566
- const toLoadLanguages = {};
1567
- const toLoadNamespaces = {};
1568
- languages.forEach(lng => {
1569
- let hasAllNamespaces = true;
1570
- namespaces.forEach(ns => {
1571
- const name = `${lng}|${ns}`;
1572
- if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
1573
- this.state[name] = 2;
1574
- } else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
1575
- if (pending[name] === undefined) pending[name] = true;
1576
- } else {
1577
- this.state[name] = 1;
1578
- hasAllNamespaces = false;
1579
- if (pending[name] === undefined) pending[name] = true;
1580
- if (toLoad[name] === undefined) toLoad[name] = true;
1581
- if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
1582
- }
1583
- });
1584
- if (!hasAllNamespaces) toLoadLanguages[lng] = true;
1585
- });
1586
- if (Object.keys(toLoad).length || Object.keys(pending).length) {
1587
- this.queue.push({
1588
- pending,
1589
- pendingCount: Object.keys(pending).length,
1590
- loaded: {},
1591
- errors: [],
1592
- callback
1593
- });
1594
- }
1595
- return {
1596
- toLoad: Object.keys(toLoad),
1597
- pending: Object.keys(pending),
1598
- toLoadLanguages: Object.keys(toLoadLanguages),
1599
- toLoadNamespaces: Object.keys(toLoadNamespaces)
1600
- };
1601
- }
1602
- loaded(name, err, data) {
1603
- const s = name.split('|');
1604
- const lng = s[0];
1605
- const ns = s[1];
1606
- if (err) this.emit('failedLoading', lng, ns, err);
1607
- if (data) {
1608
- this.store.addResourceBundle(lng, ns, data);
1609
- }
1610
- this.state[name] = err ? -1 : 2;
1611
- const loaded = {};
1612
- this.queue.forEach(q => {
1613
- pushPath(q.loaded, [lng], ns);
1614
- removePending(q, name);
1615
- if (err) q.errors.push(err);
1616
- if (q.pendingCount === 0 && !q.done) {
1617
- Object.keys(q.loaded).forEach(l => {
1618
- if (!loaded[l]) loaded[l] = {};
1619
- const loadedKeys = q.loaded[l];
1620
- if (loadedKeys.length) {
1621
- loadedKeys.forEach(n => {
1622
- if (loaded[l][n] === undefined) loaded[l][n] = true;
1623
- });
1624
- }
1625
- });
1626
- q.done = true;
1627
- if (q.errors.length) {
1628
- q.callback(q.errors);
1629
- } else {
1630
- q.callback();
1631
- }
1632
- }
1633
- });
1634
- this.emit('loaded', loaded);
1635
- this.queue = this.queue.filter(q => !q.done);
1636
- }
1637
- read(lng, ns, fcName) {
1638
- let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1639
- let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
1640
- let callback = arguments.length > 5 ? arguments[5] : undefined;
1641
- if (!lng.length) return callback(null, {});
1642
- if (this.readingCalls >= this.maxParallelReads) {
1643
- this.waitingReads.push({
1644
- lng,
1645
- ns,
1646
- fcName,
1647
- tried,
1648
- wait,
1649
- callback
1650
- });
1651
- return;
1652
- }
1653
- this.readingCalls++;
1654
- const resolver = (err, data) => {
1655
- this.readingCalls--;
1656
- if (this.waitingReads.length > 0) {
1657
- const next = this.waitingReads.shift();
1658
- this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
1659
- }
1660
- if (err && data && tried < this.maxRetries) {
1661
- setTimeout(() => {
1662
- this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
1663
- }, wait);
1664
- return;
1665
- }
1666
- callback(err, data);
1667
- };
1668
- const fc = this.backend[fcName].bind(this.backend);
1669
- if (fc.length === 2) {
1670
- try {
1671
- const r = fc(lng, ns);
1672
- if (r && typeof r.then === 'function') {
1673
- r.then(data => resolver(null, data)).catch(resolver);
1674
- } else {
1675
- resolver(null, r);
1676
- }
1677
- } catch (err) {
1678
- resolver(err);
1679
- }
1680
- return;
1681
- }
1682
- return fc(lng, ns, resolver);
1683
- }
1684
- prepareLoading(languages, namespaces) {
1685
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1686
- let callback = arguments.length > 3 ? arguments[3] : undefined;
1687
- if (!this.backend) {
1688
- this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1689
- return callback && callback();
1690
- }
1691
- if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
1692
- if (typeof namespaces === 'string') namespaces = [namespaces];
1693
- const toLoad = this.queueLoad(languages, namespaces, options, callback);
1694
- if (!toLoad.toLoad.length) {
1695
- if (!toLoad.pending.length) callback();
1696
- return null;
1697
- }
1698
- toLoad.toLoad.forEach(name => {
1699
- this.loadOne(name);
1700
- });
1701
- }
1702
- load(languages, namespaces, callback) {
1703
- this.prepareLoading(languages, namespaces, {}, callback);
1704
- }
1705
- reload(languages, namespaces, callback) {
1706
- this.prepareLoading(languages, namespaces, {
1707
- reload: true
1708
- }, callback);
1709
- }
1710
- loadOne(name) {
1711
- let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1712
- const s = name.split('|');
1713
- const lng = s[0];
1714
- const ns = s[1];
1715
- this.read(lng, ns, 'read', undefined, undefined, (err, data) => {
1716
- if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
1717
- if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
1718
- this.loaded(name, err, data);
1719
- });
1720
- }
1721
- saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
1722
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1723
- let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
1724
- if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
1725
- this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" was not yet loaded`, 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
1726
- return;
1727
- }
1728
- if (key === undefined || key === null || key === '') return;
1729
- if (this.backend && this.backend.create) {
1730
- const opts = {
1731
- ...options,
1732
- isUpdate
1733
- };
1734
- const fc = this.backend.create.bind(this.backend);
1735
- if (fc.length < 6) {
1736
- try {
1737
- let r;
1738
- if (fc.length === 5) {
1739
- r = fc(languages, namespace, key, fallbackValue, opts);
1740
- } else {
1741
- r = fc(languages, namespace, key, fallbackValue);
1742
- }
1743
- if (r && typeof r.then === 'function') {
1744
- r.then(data => clb(null, data)).catch(clb);
1745
- } else {
1746
- clb(null, r);
1747
- }
1748
- } catch (err) {
1749
- clb(err);
1750
- }
1751
- } else {
1752
- fc(languages, namespace, key, fallbackValue, clb, opts);
1753
- }
1754
- }
1755
- if (!languages || !languages[0]) return;
1756
- this.store.addResource(languages[0], namespace, key, fallbackValue);
1757
- }
1758
- }
1759
-
1760
- function get() {
1761
- return {
1762
- debug: false,
1763
- initImmediate: true,
1764
- ns: ['translation'],
1765
- defaultNS: ['translation'],
1766
- fallbackLng: ['dev'],
1767
- fallbackNS: false,
1768
- supportedLngs: false,
1769
- nonExplicitSupportedLngs: false,
1770
- load: 'all',
1771
- preload: false,
1772
- simplifyPluralSuffix: true,
1773
- keySeparator: '.',
1774
- nsSeparator: ':',
1775
- pluralSeparator: '_',
1776
- contextSeparator: '_',
1777
- partialBundledLanguages: false,
1778
- saveMissing: false,
1779
- updateMissing: false,
1780
- saveMissingTo: 'fallback',
1781
- saveMissingPlurals: true,
1782
- missingKeyHandler: false,
1783
- missingInterpolationHandler: false,
1784
- postProcess: false,
1785
- postProcessPassResolved: false,
1786
- returnNull: false,
1787
- returnEmptyString: true,
1788
- returnObjects: false,
1789
- joinArrays: false,
1790
- returnedObjectHandler: false,
1791
- parseMissingKeyHandler: false,
1792
- appendNamespaceToMissingKey: false,
1793
- appendNamespaceToCIMode: false,
1794
- overloadTranslationOptionHandler: function handle(args) {
1795
- let ret = {};
1796
- if (typeof args[1] === 'object') ret = args[1];
1797
- if (typeof args[1] === 'string') ret.defaultValue = args[1];
1798
- if (typeof args[2] === 'string') ret.tDescription = args[2];
1799
- if (typeof args[2] === 'object' || typeof args[3] === 'object') {
1800
- const options = args[3] || args[2];
1801
- Object.keys(options).forEach(key => {
1802
- ret[key] = options[key];
1803
- });
1804
- }
1805
- return ret;
1806
- },
1807
- interpolation: {
1808
- escapeValue: true,
1809
- format: (value, format, lng, options) => value,
1810
- prefix: '{{',
1811
- suffix: '}}',
1812
- formatSeparator: ',',
1813
- unescapePrefix: '-',
1814
- nestingPrefix: '$t(',
1815
- nestingSuffix: ')',
1816
- nestingOptionsSeparator: ',',
1817
- maxReplaces: 1000,
1818
- skipOnVariables: true
1819
- }
1820
- };
1821
- }
1822
- function transformOptions(options) {
1823
- if (typeof options.ns === 'string') options.ns = [options.ns];
1824
- if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
1825
- if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
1826
- if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
1827
- options.supportedLngs = options.supportedLngs.concat(['cimode']);
1828
- }
1829
- return options;
1830
- }
1831
-
1832
- function noop$2() {}
1833
- function bindMemberFunctions(inst) {
1834
- const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
1835
- mems.forEach(mem => {
1836
- if (typeof inst[mem] === 'function') {
1837
- inst[mem] = inst[mem].bind(inst);
1838
- }
1839
- });
1840
- }
1841
- class I18n extends EventEmitter {
1842
- constructor() {
1843
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1844
- let callback = arguments.length > 1 ? arguments[1] : undefined;
1845
- super();
1846
- this.options = transformOptions(options);
1847
- this.services = {};
1848
- this.logger = baseLogger;
1849
- this.modules = {
1850
- external: []
1851
- };
1852
- bindMemberFunctions(this);
1853
- if (callback && !this.isInitialized && !options.isClone) {
1854
- if (!this.options.initImmediate) {
1855
- this.init(options, callback);
1856
- return this;
1857
- }
1858
- setTimeout(() => {
1859
- this.init(options, callback);
1860
- }, 0);
1861
- }
1862
- }
1863
- init() {
1864
- var _this = this;
1865
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1866
- let callback = arguments.length > 1 ? arguments[1] : undefined;
1867
- if (typeof options === 'function') {
1868
- callback = options;
1869
- options = {};
1870
- }
1871
- if (!options.defaultNS && options.defaultNS !== false && options.ns) {
1872
- if (typeof options.ns === 'string') {
1873
- options.defaultNS = options.ns;
1874
- } else if (options.ns.indexOf('translation') < 0) {
1875
- options.defaultNS = options.ns[0];
1876
- }
1877
- }
1878
- const defOpts = get();
1879
- this.options = {
1880
- ...defOpts,
1881
- ...this.options,
1882
- ...transformOptions(options)
1883
- };
1884
- if (this.options.compatibilityAPI !== 'v1') {
1885
- this.options.interpolation = {
1886
- ...defOpts.interpolation,
1887
- ...this.options.interpolation
1888
- };
1889
- }
1890
- if (options.keySeparator !== undefined) {
1891
- this.options.userDefinedKeySeparator = options.keySeparator;
1892
- }
1893
- if (options.nsSeparator !== undefined) {
1894
- this.options.userDefinedNsSeparator = options.nsSeparator;
1895
- }
1896
- function createClassOnDemand(ClassOrObject) {
1897
- if (!ClassOrObject) return null;
1898
- if (typeof ClassOrObject === 'function') return new ClassOrObject();
1899
- return ClassOrObject;
1900
- }
1901
- if (!this.options.isClone) {
1902
- if (this.modules.logger) {
1903
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
1904
- } else {
1905
- baseLogger.init(null, this.options);
1906
- }
1907
- let formatter;
1908
- if (this.modules.formatter) {
1909
- formatter = this.modules.formatter;
1910
- } else if (typeof Intl !== 'undefined') {
1911
- formatter = Formatter;
1912
- }
1913
- const lu = new LanguageUtil(this.options);
1914
- this.store = new ResourceStore(this.options.resources, this.options);
1915
- const s = this.services;
1916
- s.logger = baseLogger;
1917
- s.resourceStore = this.store;
1918
- s.languageUtils = lu;
1919
- s.pluralResolver = new PluralResolver(lu, {
1920
- prepend: this.options.pluralSeparator,
1921
- compatibilityJSON: this.options.compatibilityJSON,
1922
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1923
- });
1924
- if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1925
- s.formatter = createClassOnDemand(formatter);
1926
- s.formatter.init(s, this.options);
1927
- this.options.interpolation.format = s.formatter.format.bind(s.formatter);
1928
- }
1929
- s.interpolator = new Interpolator(this.options);
1930
- s.utils = {
1931
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1932
- };
1933
- s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1934
- s.backendConnector.on('*', function (event) {
1935
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1936
- args[_key - 1] = arguments[_key];
1937
- }
1938
- _this.emit(event, ...args);
1939
- });
1940
- if (this.modules.languageDetector) {
1941
- s.languageDetector = createClassOnDemand(this.modules.languageDetector);
1942
- if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
1943
- }
1944
- if (this.modules.i18nFormat) {
1945
- s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
1946
- if (s.i18nFormat.init) s.i18nFormat.init(this);
1947
- }
1948
- this.translator = new Translator(this.services, this.options);
1949
- this.translator.on('*', function (event) {
1950
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1951
- args[_key2 - 1] = arguments[_key2];
1952
- }
1953
- _this.emit(event, ...args);
1954
- });
1955
- this.modules.external.forEach(m => {
1956
- if (m.init) m.init(this);
1957
- });
1958
- }
1959
- this.format = this.options.interpolation.format;
1960
- if (!callback) callback = noop$2;
1961
- if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1962
- const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1963
- if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
1964
- }
1965
- if (!this.services.languageDetector && !this.options.lng) {
1966
- this.logger.warn('init: no languageDetector is used and no lng is defined');
1967
- }
1968
- const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
1969
- storeApi.forEach(fcName => {
1970
- this[fcName] = function () {
1971
- return _this.store[fcName](...arguments);
1972
- };
1973
- });
1974
- const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
1975
- storeApiChained.forEach(fcName => {
1976
- this[fcName] = function () {
1977
- _this.store[fcName](...arguments);
1978
- return _this;
1979
- };
1980
- });
1981
- const deferred = defer();
1982
- const load = () => {
1983
- const finish = (err, t) => {
1984
- if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn('init: i18next is already initialized. You should call init just once!');
1985
- this.isInitialized = true;
1986
- if (!this.options.isClone) this.logger.log('initialized', this.options);
1987
- this.emit('initialized', this.options);
1988
- deferred.resolve(t);
1989
- callback(err, t);
1990
- };
1991
- if (this.languages && this.options.compatibilityAPI !== 'v1' && !this.isInitialized) return finish(null, this.t.bind(this));
1992
- this.changeLanguage(this.options.lng, finish);
1993
- };
1994
- if (this.options.resources || !this.options.initImmediate) {
1995
- load();
1996
- } else {
1997
- setTimeout(load, 0);
1998
- }
1999
- return deferred;
2000
- }
2001
- loadResources(language) {
2002
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
2003
- let usedCallback = callback;
2004
- const usedLng = typeof language === 'string' ? language : this.language;
2005
- if (typeof language === 'function') usedCallback = language;
2006
- if (!this.options.resources || this.options.partialBundledLanguages) {
2007
- if (usedLng && usedLng.toLowerCase() === 'cimode') return usedCallback();
2008
- const toLoad = [];
2009
- const append = lng => {
2010
- if (!lng) return;
2011
- const lngs = this.services.languageUtils.toResolveHierarchy(lng);
2012
- lngs.forEach(l => {
2013
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
2014
- });
2015
- };
2016
- if (!usedLng) {
2017
- const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
2018
- fallbacks.forEach(l => append(l));
2019
- } else {
2020
- append(usedLng);
2021
- }
2022
- if (this.options.preload) {
2023
- this.options.preload.forEach(l => append(l));
2024
- }
2025
- this.services.backendConnector.load(toLoad, this.options.ns, e => {
2026
- if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
2027
- usedCallback(e);
2028
- });
2029
- } else {
2030
- usedCallback(null);
2031
- }
2032
- }
2033
- reloadResources(lngs, ns, callback) {
2034
- const deferred = defer();
2035
- if (!lngs) lngs = this.languages;
2036
- if (!ns) ns = this.options.ns;
2037
- if (!callback) callback = noop$2;
2038
- this.services.backendConnector.reload(lngs, ns, err => {
2039
- deferred.resolve();
2040
- callback(err);
2041
- });
2042
- return deferred;
2043
- }
2044
- use(module) {
2045
- if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
2046
- if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
2047
- if (module.type === 'backend') {
2048
- this.modules.backend = module;
2049
- }
2050
- if (module.type === 'logger' || module.log && module.warn && module.error) {
2051
- this.modules.logger = module;
2052
- }
2053
- if (module.type === 'languageDetector') {
2054
- this.modules.languageDetector = module;
2055
- }
2056
- if (module.type === 'i18nFormat') {
2057
- this.modules.i18nFormat = module;
2058
- }
2059
- if (module.type === 'postProcessor') {
2060
- postProcessor.addPostProcessor(module);
2061
- }
2062
- if (module.type === 'formatter') {
2063
- this.modules.formatter = module;
2064
- }
2065
- if (module.type === '3rdParty') {
2066
- this.modules.external.push(module);
2067
- }
2068
- return this;
2069
- }
2070
- setResolvedLanguage(l) {
2071
- if (!l || !this.languages) return;
2072
- if (['cimode', 'dev'].indexOf(l) > -1) return;
2073
- for (let li = 0; li < this.languages.length; li++) {
2074
- const lngInLngs = this.languages[li];
2075
- if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
2076
- if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
2077
- this.resolvedLanguage = lngInLngs;
2078
- break;
2079
- }
2080
- }
2081
- }
2082
- changeLanguage(lng, callback) {
2083
- var _this2 = this;
2084
- this.isLanguageChangingTo = lng;
2085
- const deferred = defer();
2086
- this.emit('languageChanging', lng);
2087
- const setLngProps = l => {
2088
- this.language = l;
2089
- this.languages = this.services.languageUtils.toResolveHierarchy(l);
2090
- this.resolvedLanguage = undefined;
2091
- this.setResolvedLanguage(l);
2092
- };
2093
- const done = (err, l) => {
2094
- if (l) {
2095
- setLngProps(l);
2096
- this.translator.changeLanguage(l);
2097
- this.isLanguageChangingTo = undefined;
2098
- this.emit('languageChanged', l);
2099
- this.logger.log('languageChanged', l);
2100
- } else {
2101
- this.isLanguageChangingTo = undefined;
2102
- }
2103
- deferred.resolve(function () {
2104
- return _this2.t(...arguments);
2105
- });
2106
- if (callback) callback(err, function () {
2107
- return _this2.t(...arguments);
2108
- });
2109
- };
2110
- const setLng = lngs => {
2111
- if (!lng && !lngs && this.services.languageDetector) lngs = [];
2112
- const l = typeof lngs === 'string' ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
2113
- if (l) {
2114
- if (!this.language) {
2115
- setLngProps(l);
2116
- }
2117
- if (!this.translator.language) this.translator.changeLanguage(l);
2118
- if (this.services.languageDetector && this.services.languageDetector.cacheUserLanguage) this.services.languageDetector.cacheUserLanguage(l);
2119
- }
2120
- this.loadResources(l, err => {
2121
- done(err, l);
2122
- });
2123
- };
2124
- if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
2125
- setLng(this.services.languageDetector.detect());
2126
- } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
2127
- if (this.services.languageDetector.detect.length === 0) {
2128
- this.services.languageDetector.detect().then(setLng);
2129
- } else {
2130
- this.services.languageDetector.detect(setLng);
2131
- }
2132
- } else {
2133
- setLng(lng);
2134
- }
2135
- return deferred;
2136
- }
2137
- getFixedT(lng, ns, keyPrefix) {
2138
- var _this3 = this;
2139
- const fixedT = function (key, opts) {
2140
- let options;
2141
- if (typeof opts !== 'object') {
2142
- for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
2143
- rest[_key3 - 2] = arguments[_key3];
2144
- }
2145
- options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2146
- } else {
2147
- options = {
2148
- ...opts
2149
- };
2150
- }
2151
- options.lng = options.lng || fixedT.lng;
2152
- options.lngs = options.lngs || fixedT.lngs;
2153
- options.ns = options.ns || fixedT.ns;
2154
- options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
2155
- const keySeparator = _this3.options.keySeparator || '.';
2156
- let resultKey;
2157
- if (options.keyPrefix && Array.isArray(key)) {
2158
- resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);
2159
- } else {
2160
- resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
2161
- }
2162
- return _this3.t(resultKey, options);
2163
- };
2164
- if (typeof lng === 'string') {
2165
- fixedT.lng = lng;
2166
- } else {
2167
- fixedT.lngs = lng;
2168
- }
2169
- fixedT.ns = ns;
2170
- fixedT.keyPrefix = keyPrefix;
2171
- return fixedT;
2172
- }
2173
- t() {
2174
- return this.translator && this.translator.translate(...arguments);
2175
- }
2176
- exists() {
2177
- return this.translator && this.translator.exists(...arguments);
2178
- }
2179
- setDefaultNamespace(ns) {
2180
- this.options.defaultNS = ns;
2181
- }
2182
- hasLoadedNamespace(ns) {
2183
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2184
- if (!this.isInitialized) {
2185
- this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
2186
- return false;
2187
- }
2188
- if (!this.languages || !this.languages.length) {
2189
- this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
2190
- return false;
2191
- }
2192
- const lng = options.lng || this.resolvedLanguage || this.languages[0];
2193
- const fallbackLng = this.options ? this.options.fallbackLng : false;
2194
- const lastLng = this.languages[this.languages.length - 1];
2195
- if (lng.toLowerCase() === 'cimode') return true;
2196
- const loadNotPending = (l, n) => {
2197
- const loadState = this.services.backendConnector.state[`${l}|${n}`];
2198
- return loadState === -1 || loadState === 2;
2199
- };
2200
- if (options.precheck) {
2201
- const preResult = options.precheck(this, loadNotPending);
2202
- if (preResult !== undefined) return preResult;
2203
- }
2204
- if (this.hasResourceBundle(lng, ns)) return true;
2205
- if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
2206
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2207
- return false;
2208
- }
2209
- loadNamespaces(ns, callback) {
2210
- const deferred = defer();
2211
- if (!this.options.ns) {
2212
- if (callback) callback();
2213
- return Promise.resolve();
2214
- }
2215
- if (typeof ns === 'string') ns = [ns];
2216
- ns.forEach(n => {
2217
- if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
2218
- });
2219
- this.loadResources(err => {
2220
- deferred.resolve();
2221
- if (callback) callback(err);
2222
- });
2223
- return deferred;
2224
- }
2225
- loadLanguages(lngs, callback) {
2226
- const deferred = defer();
2227
- if (typeof lngs === 'string') lngs = [lngs];
2228
- const preloaded = this.options.preload || [];
2229
- const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0);
2230
- if (!newLngs.length) {
2231
- if (callback) callback();
2232
- return Promise.resolve();
2233
- }
2234
- this.options.preload = preloaded.concat(newLngs);
2235
- this.loadResources(err => {
2236
- deferred.resolve();
2237
- if (callback) callback(err);
2238
- });
2239
- return deferred;
2240
- }
2241
- dir(lng) {
2242
- if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
2243
- if (!lng) return 'rtl';
2244
- const rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ug', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam', 'ckb'];
2245
- const languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
2246
- return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2247
- }
2248
- static createInstance() {
2249
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2250
- let callback = arguments.length > 1 ? arguments[1] : undefined;
2251
- return new I18n(options, callback);
2252
- }
2253
- cloneInstance() {
2254
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2255
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
2256
- const forkResourceStore = options.forkResourceStore;
2257
- if (forkResourceStore) delete options.forkResourceStore;
2258
- const mergedOptions = {
2259
- ...this.options,
2260
- ...options,
2261
- ...{
2262
- isClone: true
2263
- }
2264
- };
2265
- const clone = new I18n(mergedOptions);
2266
- if (options.debug !== undefined || options.prefix !== undefined) {
2267
- clone.logger = clone.logger.clone(options);
2268
- }
2269
- const membersToCopy = ['store', 'services', 'language'];
2270
- membersToCopy.forEach(m => {
2271
- clone[m] = this[m];
2272
- });
2273
- clone.services = {
2274
- ...this.services
2275
- };
2276
- clone.services.utils = {
2277
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2278
- };
2279
- if (forkResourceStore) {
2280
- clone.store = new ResourceStore(this.store.data, mergedOptions);
2281
- clone.services.resourceStore = clone.store;
2282
- }
2283
- clone.translator = new Translator(clone.services, mergedOptions);
2284
- clone.translator.on('*', function (event) {
2285
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
2286
- args[_key4 - 1] = arguments[_key4];
2287
- }
2288
- clone.emit(event, ...args);
2289
- });
2290
- clone.init(mergedOptions, callback);
2291
- clone.translator.options = mergedOptions;
2292
- clone.translator.backendConnector.services.utils = {
2293
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2294
- };
2295
- return clone;
2296
- }
2297
- toJSON() {
2298
- return {
2299
- options: this.options,
2300
- store: this.store,
2301
- language: this.language,
2302
- languages: this.languages,
2303
- resolvedLanguage: this.resolvedLanguage
2304
- };
2305
- }
2306
- }
2307
- const instance = I18n.createInstance();
2308
- instance.createInstance = I18n.createInstance;
2309
-
2310
- instance.createInstance;
2311
- instance.dir;
2312
- instance.init;
2313
- instance.loadResources;
2314
- instance.reloadResources;
2315
- instance.use;
2316
- instance.changeLanguage;
2317
- instance.getFixedT;
2318
- const t$2 = instance.t;
2319
- instance.exists;
2320
- instance.setDefaultNamespace;
2321
- instance.hasLoadedNamespace;
2322
- instance.loadNamespaces;
2323
- instance.loadLanguages;
2324
-
2325
- /**
2326
- * This file automatically generated from `pre-publish.js`.
2327
- * Do not manually edit.
2328
- */
2329
-
2330
- var voidElements = {
2331
- "area": true,
2332
- "base": true,
2333
- "br": true,
2334
- "col": true,
2335
- "embed": true,
2336
- "hr": true,
2337
- "img": true,
2338
- "input": true,
2339
- "link": true,
2340
- "meta": true,
2341
- "param": true,
2342
- "source": true,
2343
- "track": true,
2344
- "wbr": true
2345
- };
2346
-
2347
- var t$1=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function n$1(n){var r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},i=n.match(/<\/?([^\s]+?)[/\s>]/);if(i&&(r.name=i[1],(voidElements[i[1]]||"/"===n.charAt(n.length-2))&&(r.voidElement=!0),r.name.startsWith("!--"))){var s=n.indexOf("--\x3e");return {type:"comment",comment:-1!==s?n.slice(4,s):""}}for(var a=new RegExp(t$1),c=null;null!==(c=a.exec(n));)if(c[0].trim())if(c[1]){var o=c[1].trim(),l=[o,""];o.indexOf("=")>-1&&(l=o.split("=")),r.attrs[l[0]]=l[1],a.lastIndex--;}else c[2]&&(r.attrs[c[2]]=c[3].trim().substring(1,c[3].length-1));return r}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,i=/^\s*$/,s=Object.create(null);function a(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(a,"")+"</"+t.name+">";case"comment":return e+"\x3c!--"+t.comment+"--\x3e"}}var c={parse:function(e,t){t||(t={}),t.components||(t.components=s);var a,c=[],o=[],l=-1,m=!1;if(0!==e.indexOf("<")){var u=e.indexOf("<");c.push({type:"text",content:-1===u?e:e.substring(0,u)});}return e.replace(r,function(r,s){if(m){if(r!=="</"+a.name+">")return;m=!1;}var u,f="/"!==r.charAt(1),h=r.startsWith("\x3c!--"),p=s+r.length,d=e.charAt(p);if(h){var v=n$1(r);return l<0?(c.push(v),c):((u=o[l]).children.push(v),c)}if(f&&(l++,"tag"===(a=n$1(r)).type&&t.components[a.name]&&(a.type="component",m=!0),a.voidElement||m||!d||"<"===d||a.children.push({type:"text",content:e.slice(p,e.indexOf("<",p))}),0===l&&c.push(a),(u=o[l-1])&&u.children.push(a),o[l]=a),(!f||a.voidElement)&&(l>-1&&(a.voidElement||a.name===r.slice(2,-1))&&(l--,a=-1===l?c:o[l]),!m&&"<"!==d&&d)){u=-1===l?c:o[l].children;var x=e.indexOf("<",p),g=e.slice(p,-1===x?void 0:x);i.test(g)&&(g=" "),(x>-1&&l+u.length>=0||" "!==g)&&u.push({type:"text",content:g});}}),c},stringify:function(e){return e.reduce(function(e,t){return e+a("",t)},"")}};
2348
-
2349
- function warn() {
2350
- if (console && console.warn) {
2351
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2352
- args[_key] = arguments[_key];
2353
- }
2354
- if (typeof args[0] === 'string') args[0] = `react-i18next:: ${args[0]}`;
2355
- console.warn(...args);
2356
- }
2357
- }
2358
- const alreadyWarned = {};
2359
- function warnOnce() {
2360
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2361
- args[_key2] = arguments[_key2];
2362
- }
2363
- if (typeof args[0] === 'string' && alreadyWarned[args[0]]) return;
2364
- if (typeof args[0] === 'string') alreadyWarned[args[0]] = new Date();
2365
- warn(...args);
2366
- }
2367
- const loadedClb = (i18n, cb) => () => {
2368
- if (i18n.isInitialized) {
2369
- cb();
2370
- } else {
2371
- const initialized = () => {
2372
- setTimeout(() => {
2373
- i18n.off('initialized', initialized);
2374
- }, 0);
2375
- cb();
2376
- };
2377
- i18n.on('initialized', initialized);
2378
- }
2379
- };
2380
- function loadNamespaces(i18n, ns, cb) {
2381
- i18n.loadNamespaces(ns, loadedClb(i18n, cb));
2382
- }
2383
- function loadLanguages(i18n, lng, ns, cb) {
2384
- if (typeof ns === 'string') ns = [ns];
2385
- ns.forEach(n => {
2386
- if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n);
2387
- });
2388
- i18n.loadLanguages(lng, loadedClb(i18n, cb));
2389
- }
2390
- function oldI18nextHasLoadedNamespace(ns, i18n) {
2391
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2392
- const lng = i18n.languages[0];
2393
- const fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
2394
- const lastLng = i18n.languages[i18n.languages.length - 1];
2395
- if (lng.toLowerCase() === 'cimode') return true;
2396
- const loadNotPending = (l, n) => {
2397
- const loadState = i18n.services.backendConnector.state[`${l}|${n}`];
2398
- return loadState === -1 || loadState === 2;
2399
- };
2400
- if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false;
2401
- if (i18n.hasResourceBundle(lng, ns)) return true;
2402
- if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
2403
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2404
- return false;
2405
- }
2406
- function hasLoadedNamespace(ns, i18n) {
2407
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2408
- if (!i18n.languages || !i18n.languages.length) {
2409
- warnOnce('i18n.languages were undefined or empty', i18n.languages);
2410
- return true;
2411
- }
2412
- const isNewerI18next = i18n.options.ignoreJSONStructure !== undefined;
2413
- if (!isNewerI18next) {
2414
- return oldI18nextHasLoadedNamespace(ns, i18n, options);
2415
- }
2416
- return i18n.hasLoadedNamespace(ns, {
2417
- lng: options.lng,
2418
- precheck: (i18nInstance, loadNotPending) => {
2419
- if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
2420
- }
2421
- });
2422
- }
2423
-
2424
- const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
2425
- const htmlEntities = {
2426
- '&amp;': '&',
2427
- '&#38;': '&',
2428
- '&lt;': '<',
2429
- '&#60;': '<',
2430
- '&gt;': '>',
2431
- '&#62;': '>',
2432
- '&apos;': "'",
2433
- '&#39;': "'",
2434
- '&quot;': '"',
2435
- '&#34;': '"',
2436
- '&nbsp;': ' ',
2437
- '&#160;': ' ',
2438
- '&copy;': '©',
2439
- '&#169;': '©',
2440
- '&reg;': '®',
2441
- '&#174;': '®',
2442
- '&hellip;': '…',
2443
- '&#8230;': '…',
2444
- '&#x2F;': '/',
2445
- '&#47;': '/'
2446
- };
2447
- const unescapeHtmlEntity = m => htmlEntities[m];
2448
- const unescape = text => text.replace(matchHtmlEntity, unescapeHtmlEntity);
2449
-
2450
- let defaultOptions = {
2451
- bindI18n: 'languageChanged',
2452
- bindI18nStore: '',
2453
- transEmptyNodeValue: '',
2454
- transSupportBasicHtmlNodes: true,
2455
- transWrapTextNodes: '',
2456
- transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
2457
- useSuspense: true,
2458
- unescape
2459
- };
2460
- function setDefaults() {
2461
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2462
- defaultOptions = {
2463
- ...defaultOptions,
2464
- ...options
2465
- };
2466
- }
2467
- function getDefaults() {
2468
- return defaultOptions;
2469
- }
2470
-
2471
- let i18nInstance;
2472
- function setI18n(instance) {
2473
- i18nInstance = instance;
2474
- }
2475
- function getI18n() {
2476
- return i18nInstance;
2477
- }
2478
-
2479
- function hasChildren(node, checkLength) {
2480
- if (!node) return false;
2481
- const base = node.props ? node.props.children : node.children;
2482
- if (checkLength) return base.length > 0;
2483
- return !!base;
2484
- }
2485
- function getChildren(node) {
2486
- if (!node) return [];
2487
- return node.props ? node.props.children : node.children;
2488
- }
2489
- function hasValidReactChildren(children) {
2490
- if (Object.prototype.toString.call(children) !== '[object Array]') return false;
2491
- return children.every(child => React.isValidElement(child));
2492
- }
2493
- function getAsArray(data) {
2494
- return Array.isArray(data) ? data : [data];
2495
- }
2496
- function mergeProps(source, target) {
2497
- const newTarget = {
2498
- ...target
2499
- };
2500
- newTarget.props = Object.assign(source.props, target.props);
2501
- return newTarget;
2502
- }
2503
- function nodesToString(children, i18nOptions) {
2504
- if (!children) return '';
2505
- let stringNode = '';
2506
- const childrenArray = getAsArray(children);
2507
- const keepArray = i18nOptions.transSupportBasicHtmlNodes && i18nOptions.transKeepBasicHtmlNodesFor ? i18nOptions.transKeepBasicHtmlNodesFor : [];
2508
- childrenArray.forEach((child, childIndex) => {
2509
- if (typeof child === 'string') {
2510
- stringNode += `${child}`;
2511
- } else if (React.isValidElement(child)) {
2512
- const childPropsCount = Object.keys(child.props).length;
2513
- const shouldKeepChild = keepArray.indexOf(child.type) > -1;
2514
- const childChildren = child.props.children;
2515
- if (!childChildren && shouldKeepChild && childPropsCount === 0) {
2516
- stringNode += `<${child.type}/>`;
2517
- } else if (!childChildren && (!shouldKeepChild || childPropsCount !== 0)) {
2518
- stringNode += `<${childIndex}></${childIndex}>`;
2519
- } else if (child.props.i18nIsDynamicList) {
2520
- stringNode += `<${childIndex}></${childIndex}>`;
2521
- } else if (shouldKeepChild && childPropsCount === 1 && typeof childChildren === 'string') {
2522
- stringNode += `<${child.type}>${childChildren}</${child.type}>`;
2523
- } else {
2524
- const content = nodesToString(childChildren, i18nOptions);
2525
- stringNode += `<${childIndex}>${content}</${childIndex}>`;
2526
- }
2527
- } else if (child === null) {
2528
- warn(`Trans: the passed in value is invalid - seems you passed in a null child.`);
2529
- } else if (typeof child === 'object') {
2530
- const {
2531
- format,
2532
- ...clone
2533
- } = child;
2534
- const keys = Object.keys(clone);
2535
- if (keys.length === 1) {
2536
- const value = format ? `${keys[0]}, ${format}` : keys[0];
2537
- stringNode += `{{${value}}}`;
2538
- } else {
2539
- warn(`react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.`, child);
2540
- }
2541
- } else {
2542
- warn(`Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.`, child);
2543
- }
2544
- });
2545
- return stringNode;
2546
- }
2547
- function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) {
2548
- if (targetString === '') return [];
2549
- const keepArray = i18nOptions.transKeepBasicHtmlNodesFor || [];
2550
- const emptyChildrenButNeedsHandling = targetString && new RegExp(keepArray.join('|')).test(targetString);
2551
- if (!children && !emptyChildrenButNeedsHandling) return [targetString];
2552
- const data = {};
2553
- function getData(childs) {
2554
- const childrenArray = getAsArray(childs);
2555
- childrenArray.forEach(child => {
2556
- if (typeof child === 'string') return;
2557
- if (hasChildren(child)) getData(getChildren(child));else if (typeof child === 'object' && !React.isValidElement(child)) Object.assign(data, child);
2558
- });
2559
- }
2560
- getData(children);
2561
- const ast = c.parse(`<0>${targetString}</0>`);
2562
- const opts = {
2563
- ...data,
2564
- ...combinedTOpts
2565
- };
2566
- function renderInner(child, node, rootReactNode) {
2567
- const childs = getChildren(child);
2568
- const mappedChildren = mapAST(childs, node.children, rootReactNode);
2569
- return hasValidReactChildren(childs) && mappedChildren.length === 0 ? childs : mappedChildren;
2570
- }
2571
- function pushTranslatedJSX(child, inner, mem, i, isVoid) {
2572
- if (child.dummy) child.children = inner;
2573
- mem.push(React.cloneElement(child, {
2574
- ...child.props,
2575
- key: i
2576
- }, isVoid ? undefined : inner));
2577
- }
2578
- function mapAST(reactNode, astNode, rootReactNode) {
2579
- const reactNodes = getAsArray(reactNode);
2580
- const astNodes = getAsArray(astNode);
2581
- return astNodes.reduce((mem, node, i) => {
2582
- const translationContent = node.children && node.children[0] && node.children[0].content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
2583
- if (node.type === 'tag') {
2584
- let tmp = reactNodes[parseInt(node.name, 10)];
2585
- if (!tmp && rootReactNode.length === 1 && rootReactNode[0][node.name]) tmp = rootReactNode[0][node.name];
2586
- if (!tmp) tmp = {};
2587
- const child = Object.keys(node.attrs).length !== 0 ? mergeProps({
2588
- props: node.attrs
2589
- }, tmp) : tmp;
2590
- const isElement = React.isValidElement(child);
2591
- const isValidTranslationWithChildren = isElement && hasChildren(node, true) && !node.voidElement;
2592
- const isEmptyTransWithHTML = emptyChildrenButNeedsHandling && typeof child === 'object' && child.dummy && !isElement;
2593
- const isKnownComponent = typeof children === 'object' && children !== null && Object.hasOwnProperty.call(children, node.name);
2594
- if (typeof child === 'string') {
2595
- const value = i18n.services.interpolator.interpolate(child, opts, i18n.language);
2596
- mem.push(value);
2597
- } else if (hasChildren(child) || isValidTranslationWithChildren) {
2598
- const inner = renderInner(child, node, rootReactNode);
2599
- pushTranslatedJSX(child, inner, mem, i);
2600
- } else if (isEmptyTransWithHTML) {
2601
- const inner = mapAST(reactNodes, node.children, rootReactNode);
2602
- mem.push(React.cloneElement(child, {
2603
- ...child.props,
2604
- key: i
2605
- }, inner));
2606
- } else if (Number.isNaN(parseFloat(node.name))) {
2607
- if (isKnownComponent) {
2608
- const inner = renderInner(child, node, rootReactNode);
2609
- pushTranslatedJSX(child, inner, mem, i, node.voidElement);
2610
- } else if (i18nOptions.transSupportBasicHtmlNodes && keepArray.indexOf(node.name) > -1) {
2611
- if (node.voidElement) {
2612
- mem.push(React.createElement(node.name, {
2613
- key: `${node.name}-${i}`
2614
- }));
2615
- } else {
2616
- const inner = mapAST(reactNodes, node.children, rootReactNode);
2617
- mem.push(React.createElement(node.name, {
2618
- key: `${node.name}-${i}`
2619
- }, inner));
2620
- }
2621
- } else if (node.voidElement) {
2622
- mem.push(`<${node.name} />`);
2623
- } else {
2624
- const inner = mapAST(reactNodes, node.children, rootReactNode);
2625
- mem.push(`<${node.name}>${inner}</${node.name}>`);
2626
- }
2627
- } else if (typeof child === 'object' && !isElement) {
2628
- const content = node.children[0] ? translationContent : null;
2629
- if (content) mem.push(content);
2630
- } else if (node.children.length === 1 && translationContent) {
2631
- mem.push(React.cloneElement(child, {
2632
- ...child.props,
2633
- key: i
2634
- }, translationContent));
2635
- } else {
2636
- mem.push(React.cloneElement(child, {
2637
- ...child.props,
2638
- key: i
2639
- }));
2640
- }
2641
- } else if (node.type === 'text') {
2642
- const wrapTextNodes = i18nOptions.transWrapTextNodes;
2643
- const content = shouldUnescape ? i18nOptions.unescape(i18n.services.interpolator.interpolate(node.content, opts, i18n.language)) : i18n.services.interpolator.interpolate(node.content, opts, i18n.language);
2644
- if (wrapTextNodes) {
2645
- mem.push(React.createElement(wrapTextNodes, {
2646
- key: `${node.name}-${i}`
2647
- }, content));
2648
- } else {
2649
- mem.push(content);
2650
- }
2651
- }
2652
- return mem;
2653
- }, []);
2654
- }
2655
- const result = mapAST([{
2656
- dummy: true,
2657
- children: children || []
2658
- }], ast, getAsArray(children || []));
2659
- return getChildren(result[0]);
2660
- }
2661
- function Trans$1(_ref) {
2662
- let {
2663
- children,
2664
- count,
2665
- parent,
2666
- i18nKey,
2667
- context,
2668
- tOptions = {},
2669
- values,
2670
- defaults,
2671
- components,
2672
- ns,
2673
- i18n: i18nFromProps,
2674
- t: tFromProps,
2675
- shouldUnescape,
2676
- ...additionalProps
2677
- } = _ref;
2678
- const i18n = i18nFromProps || getI18n();
2679
- if (!i18n) {
2680
- warnOnce('You will need to pass in an i18next instance by using i18nextReactModule');
2681
- return children;
2682
- }
2683
- const t = tFromProps || i18n.t.bind(i18n) || (k => k);
2684
- if (context) tOptions.context = context;
2685
- const reactI18nextOptions = {
2686
- ...getDefaults(),
2687
- ...(i18n.options && i18n.options.react)
2688
- };
2689
- let namespaces = ns || t.ns || i18n.options && i18n.options.defaultNS;
2690
- namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
2691
- const defaultValue = defaults || nodesToString(children, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue || i18nKey;
2692
- const {
2693
- hashTransKey
2694
- } = reactI18nextOptions;
2695
- const key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
2696
- const interpolationOverride = values ? tOptions.interpolation : {
2697
- interpolation: {
2698
- ...tOptions.interpolation,
2699
- prefix: '#$?',
2700
- suffix: '?$#'
2701
- }
2702
- };
2703
- const combinedTOpts = {
2704
- ...tOptions,
2705
- count,
2706
- ...values,
2707
- ...interpolationOverride,
2708
- defaultValue,
2709
- ns: namespaces
2710
- };
2711
- const translation = key ? t(key, combinedTOpts) : defaultValue;
2712
- const content = renderNodes(components || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
2713
- const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
2714
- return useAsParent ? React.createElement(useAsParent, additionalProps, content) : content;
2715
- }
2716
-
2717
- const initReactI18next = {
2718
- type: '3rdParty',
2719
- init(instance) {
2720
- setDefaults(instance.options.react);
2721
- setI18n(instance);
2722
- }
2723
- };
2724
-
2725
- const I18nContext = React.createContext();
2726
- class ReportNamespaces {
2727
- constructor() {
2728
- this.usedNamespaces = {};
2729
- }
2730
- addUsedNamespaces(namespaces) {
2731
- namespaces.forEach(ns => {
2732
- if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
2733
- });
2734
- }
2735
- getUsedNamespaces() {
2736
- return Object.keys(this.usedNamespaces);
2737
- }
2738
- }
2739
-
2740
- function Trans(_ref) {
2741
- let {
2742
- children,
2743
- count,
2744
- parent,
2745
- i18nKey,
2746
- context,
2747
- tOptions = {},
2748
- values,
2749
- defaults,
2750
- components,
2751
- ns,
2752
- i18n: i18nFromProps,
2753
- t: tFromProps,
2754
- shouldUnescape,
2755
- ...additionalProps
2756
- } = _ref;
2757
- const {
2758
- i18n: i18nFromContext,
2759
- defaultNS: defaultNSFromContext
2760
- } = React.useContext(I18nContext) || {};
2761
- const i18n = i18nFromProps || i18nFromContext || getI18n();
2762
- const t = tFromProps || i18n && i18n.t.bind(i18n);
2763
- return Trans$1({
2764
- children,
2765
- count,
2766
- parent,
2767
- i18nKey,
2768
- context,
2769
- tOptions,
2770
- values,
2771
- defaults,
2772
- components,
2773
- ns: ns || t && t.ns || defaultNSFromContext || i18n && i18n.options && i18n.options.defaultNS,
2774
- i18n,
2775
- t: tFromProps,
2776
- shouldUnescape,
2777
- ...additionalProps
2778
- });
2779
- }
2780
-
2781
- const usePrevious = (value, ignore) => {
2782
- const ref = React.useRef();
2783
- React.useEffect(() => {
2784
- ref.current = ignore ? ref.current : value;
2785
- }, [value, ignore]);
2786
- return ref.current;
2787
- };
2788
- function useTranslation(ns) {
2789
- let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2790
- const {
2791
- i18n: i18nFromProps
2792
- } = props;
2793
- const {
2794
- i18n: i18nFromContext,
2795
- defaultNS: defaultNSFromContext
2796
- } = React.useContext(I18nContext) || {};
2797
- const i18n = i18nFromProps || i18nFromContext || getI18n();
2798
- if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
2799
- if (!i18n) {
2800
- warnOnce('You will need to pass in an i18next instance by using initReactI18next');
2801
- const notReadyT = (k, optsOrDefaultValue) => {
2802
- if (typeof optsOrDefaultValue === 'string') return optsOrDefaultValue;
2803
- if (optsOrDefaultValue && typeof optsOrDefaultValue === 'object' && typeof optsOrDefaultValue.defaultValue === 'string') return optsOrDefaultValue.defaultValue;
2804
- return Array.isArray(k) ? k[k.length - 1] : k;
2805
- };
2806
- const retNotReady = [notReadyT, {}, false];
2807
- retNotReady.t = notReadyT;
2808
- retNotReady.i18n = {};
2809
- retNotReady.ready = false;
2810
- return retNotReady;
2811
- }
2812
- if (i18n.options.react && i18n.options.react.wait !== undefined) warnOnce('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
2813
- const i18nOptions = {
2814
- ...getDefaults(),
2815
- ...i18n.options.react,
2816
- ...props
2817
- };
2818
- const {
2819
- useSuspense,
2820
- keyPrefix
2821
- } = i18nOptions;
2822
- let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
2823
- namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
2824
- if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
2825
- const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n, i18nOptions));
2826
- function getT() {
2827
- return i18n.getFixedT(props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
2828
- }
2829
- const [t, setT] = React.useState(getT);
2830
- let joinedNS = namespaces.join();
2831
- if (props.lng) joinedNS = `${props.lng}${joinedNS}`;
2832
- const previousJoinedNS = usePrevious(joinedNS);
2833
- const isMounted = React.useRef(true);
2834
- React.useEffect(() => {
2835
- const {
2836
- bindI18n,
2837
- bindI18nStore
2838
- } = i18nOptions;
2839
- isMounted.current = true;
2840
- if (!ready && !useSuspense) {
2841
- if (props.lng) {
2842
- loadLanguages(i18n, props.lng, namespaces, () => {
2843
- if (isMounted.current) setT(getT);
2844
- });
2845
- } else {
2846
- loadNamespaces(i18n, namespaces, () => {
2847
- if (isMounted.current) setT(getT);
2848
- });
2849
- }
2850
- }
2851
- if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
2852
- setT(getT);
2853
- }
2854
- function boundReset() {
2855
- if (isMounted.current) setT(getT);
2856
- }
2857
- if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
2858
- if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
2859
- return () => {
2860
- isMounted.current = false;
2861
- if (bindI18n && i18n) bindI18n.split(' ').forEach(e => i18n.off(e, boundReset));
2862
- if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, boundReset));
2863
- };
2864
- }, [i18n, joinedNS]);
2865
- const isInitial = React.useRef(true);
2866
- React.useEffect(() => {
2867
- if (isMounted.current && !isInitial.current) {
2868
- setT(getT);
2869
- }
2870
- isInitial.current = false;
2871
- }, [i18n, keyPrefix]);
2872
- const ret = [t, i18n, ready];
2873
- ret.t = t;
2874
- ret.i18n = i18n;
2875
- ret.ready = ready;
2876
- if (ready) return ret;
2877
- if (!ready && !useSuspense) return ret;
2878
- throw new Promise(resolve => {
2879
- if (props.lng) {
2880
- loadLanguages(i18n, props.lng, namespaces, () => resolve());
2881
- } else {
2882
- loadNamespaces(i18n, namespaces, () => resolve());
2883
- }
2884
- });
2885
- }
2886
-
2887
- var common = {
2888
- clearFilters: "Clear filters",
2889
- columns: "Columns",
2890
- "delete": "Delete",
2891
- done: "Done",
2892
- filter: "Filter",
2893
- filters: "Filters",
2894
- no: "No",
2895
- proceed: "Proceed",
2896
- rename: "Rename",
2897
- segments: "Segments",
2898
- userCount: "{{count}} Users",
2899
- yes: "Yes",
2900
- update: "Update"
2901
- };
2902
- var messages = {
2903
- enterResource: "Enter {{resource}}",
2904
- noResourcesFound: "No {{resources}} found",
2905
- searchResources: "Search {{resources}}",
2906
- selectResource: "Select {{resource}}",
2907
- selectOption: "Select an option"
2908
- };
2909
- var rules = {
2910
- contains: "Contains",
2911
- doesNotContain: "Does not contain",
2912
- exactly: "Exactly",
2913
- notExactly: "Not exactly",
2914
- startsWith: "Starts with",
2915
- doesNotStartWith: "Does not start with",
2916
- endsWith: "Ends with",
2917
- doesNotEndWith: "Does not end with",
2918
- greaterThan: "Greater than",
2919
- lessThan: "Less than"
2920
- };
2921
- var errors = {
2922
- cannotPassMultipleModels: "Cannot pass multiple Models except for keyword searching"
2923
- };
2924
- var shortcuts = {
2925
- deleteBlock: "Delete block",
2926
- openFilterPane: "Open filter pane",
2927
- closePane: "Close pane"
2928
- };
2929
- var segments = {
2930
- addNewSegment: "Add new segment",
2931
- deleteAlertMessage: "You are permanently deleting the segment <strong>{{entity}}</strong>. This can't be undone.",
2932
- deleteAlertTitle: "Delete segment?",
2933
- manageSegments: "Manage segments",
2934
- name: "Segment name",
2935
- noSegmentsFound: "No segments found",
2936
- saveSegment: "Save segment",
2937
- saveAsSegment: "Save as segment",
2938
- saveAsNewSegment: "Save as new segment",
2939
- searchSegments: "Search segments",
2940
- segmentName: "Segment name",
2941
- showLess: "See less",
2942
- showMoreNumbers: "See {{entity}} more",
2943
- updateSegment: "Update segment?",
2944
- updateSegmentMessage: "You are trying to update the current segment."
2945
- };
2946
- var labels = {
2947
- keyword: "Keyword"
2948
- };
2949
- var en = {
2950
- common: common,
2951
- messages: messages,
2952
- rules: rules,
2953
- errors: errors,
2954
- shortcuts: shortcuts,
2955
- segments: segments,
2956
- labels: labels
2957
- };
2958
-
2959
- instance.use(initReactI18next).init({
2960
- resources: {
2961
- en: {
2962
- translation: en
2963
- }
2964
- },
2965
- fallbackLng: "en"
2966
- });
2967
-
2968
58
  function _arrayLikeToArray$1(arr, len) {
2969
59
  if (len == null || len > arr.length) len = arr.length;
2970
60
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
@@ -3187,15 +277,15 @@ var filterBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
3187
277
  var SHORTCUTS = {
3188
278
  closePane: {
3189
279
  sequence: "escape",
3190
- description: t$2("shortcuts.closePane")
280
+ description: i18next.t("neetoFilters.shortcuts.closePane")
3191
281
  },
3192
282
  deleteBlock: {
3193
283
  sequence: "backspace",
3194
- description: t$2("shortcuts.deleteBlock")
284
+ description: i18next.t("neetoFilters.shortcuts.deleteBlock")
3195
285
  },
3196
286
  openFilterPane: {
3197
287
  sequence: "enter",
3198
- description: t$2("shortcuts.openFilterPane")
288
+ description: i18next.t("neetoFilters.shortcuts.openFilterPane")
3199
289
  }
3200
290
  };
3201
291
 
@@ -3283,48 +373,48 @@ var DATE_RULES = {
3283
373
  };
3284
374
 
3285
375
  var NUMBER_RULES = [{
3286
- label: t$2("rules.exactly"),
376
+ label: i18next.t("neetoFilters.rules.exactly"),
3287
377
  value: "is"
3288
378
  }, {
3289
- label: t$2("rules.notExactly"),
379
+ label: i18next.t("neetoFilters.rules.notExactly"),
3290
380
  value: "is_not"
3291
381
  }, {
3292
- label: t$2("rules.greaterThan"),
382
+ label: i18next.t("neetoFilters.rules.greaterThan"),
3293
383
  value: "greater_than"
3294
384
  }, {
3295
- label: t$2("rules.lessThan"),
385
+ label: i18next.t("neetoFilters.rules.lessThan"),
3296
386
  value: "less_than"
3297
387
  }];
3298
388
  var TEXT_RULES = [{
3299
- label: t$2("rules.contains"),
389
+ label: i18next.t("neetoFilters.rules.contains"),
3300
390
  value: "contains"
3301
391
  }, {
3302
- label: t$2("rules.doesNotContain"),
392
+ label: i18next.t("neetoFilters.rules.doesNotContain"),
3303
393
  value: "does_not_contain"
3304
394
  }, {
3305
- label: t$2("rules.exactly"),
395
+ label: i18next.t("neetoFilters.rules.exactly"),
3306
396
  value: "is"
3307
397
  }, {
3308
- label: t$2("rules.notExactly"),
398
+ label: i18next.t("neetoFilters.rules.notExactly"),
3309
399
  value: "is_not"
3310
400
  }, {
3311
- label: t$2("rules.startsWith"),
401
+ label: i18next.t("neetoFilters.rules.startsWith"),
3312
402
  value: "starts_with"
3313
403
  }, {
3314
- label: t$2("rules.doesNotStartWith"),
404
+ label: i18next.t("neetoFilters.rules.doesNotStartWith"),
3315
405
  value: "does_not_start_with"
3316
406
  }, {
3317
- label: t$2("rules.endsWith"),
407
+ label: i18next.t("neetoFilters.rules.endsWith"),
3318
408
  value: "ends_with"
3319
409
  }, {
3320
- label: t$2("rules.doesNotEndWith"),
410
+ label: i18next.t("neetoFilters.rules.doesNotEndWith"),
3321
411
  value: "does_not_end_with"
3322
412
  }];
3323
413
  var DEFAULT_BOOLEAN_OPTIONS = [{
3324
- label: t$2("common.yes"),
414
+ label: i18next.t("neetoFilters.common.yes"),
3325
415
  value: "true"
3326
416
  }, {
3327
- label: t$2("common.no"),
417
+ label: i18next.t("neetoFilters.common.no"),
3328
418
  value: "false"
3329
419
  }];
3330
420
 
@@ -3704,7 +794,7 @@ var buildFiltersPayload = function buildFiltersPayload(filters) {
3704
794
  defaultType = _filterPayload$defaul === void 0 ? filterPayload.type : _filterPayload$defaul,
3705
795
  value = filterPayload.value;
3706
796
  if (isMultiModelFilter(filterPayload)) {
3707
- throw instance.t("errors.cannotPassMultipleModels");
797
+ throw i18next__default["default"].t("neetoFilters.errors.cannotPassMultipleModels");
3708
798
  }
3709
799
  if (isDate(defaultType)) {
3710
800
  return ramda.mergeRight(filterPayload, buildDatePayload(value));
@@ -3738,7 +828,7 @@ var buildSegmentsPayload = function buildSegmentsPayload(filters) {
3738
828
  defaultType = _filterPayload$defaul2 === void 0 ? filterPayload.type : _filterPayload$defaul2,
3739
829
  value = filterPayload.value;
3740
830
  if (filter.key !== "keyword" && isMultiModelFilter(filterPayload)) {
3741
- throw instance.t("errors.cannotPassMultipleModels");
831
+ throw i18next__default["default"].t("neetoFilters.errors.cannotPassMultipleModels");
3742
832
  }
3743
833
  if (isMulti(defaultType)) {
3744
834
  return ramda.mergeRight(filterPayload, {
@@ -3884,6 +974,9 @@ var buildUrlFromFilters = function buildUrlFromFilters(_ref16) {
3884
974
  columns: columns
3885
975
  });
3886
976
  });
977
+ if (ramda.isEmpty(ramda.omit(["segmentId"], searchParams))) {
978
+ delete searchParams["segmentId"];
979
+ }
3887
980
  return new URLSearchParams(searchParams).toString();
3888
981
  };
3889
982
  var createUrlParamStringForSegments = function createUrlParamStringForSegments(_ref18) {
@@ -4238,7 +1331,7 @@ var Segment = function Segment(_ref) {
4238
1331
  isUpdateAlertOpen = _useState4[0],
4239
1332
  setIsUpdateAlertOpen = _useState4[1];
4240
1333
  var inputRef = React.useRef(null);
4241
- var _useTranslation = useTranslation(),
1334
+ var _useTranslation = reactI18next.useTranslation(),
4242
1335
  t = _useTranslation.t;
4243
1336
  var history = reactRouterDom.useHistory();
4244
1337
  var filtersPayload = buildSegmentsPayload(filters, childrenKeys);
@@ -4250,10 +1343,12 @@ var Segment = function Segment(_ref) {
4250
1343
  _useShowSegment$data = _useShowSegment.data,
4251
1344
  selectedSegment = _useShowSegment$data === void 0 ? {} : _useShowSegment$data;
4252
1345
  var _useCreateSegment = useCreateSegment(),
4253
- createSegment = _useCreateSegment.mutate;
1346
+ createSegment = _useCreateSegment.mutate,
1347
+ isCreating = _useCreateSegment.isLoading;
4254
1348
  var _useUpdateSegment = useUpdateSegment(),
4255
1349
  updateSegment = _useUpdateSegment.mutate,
4256
1350
  isUpdating = _useUpdateSegment.isLoading;
1351
+ var isSubmitting = isCreating || isUpdating;
4257
1352
  var handleUpdate = function handleUpdate() {
4258
1353
  return updateSegment({
4259
1354
  id: segmentId,
@@ -4292,7 +1387,7 @@ var Segment = function Segment(_ref) {
4292
1387
  };
4293
1388
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, ramda.isNil(segmentId) ? /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
4294
1389
  disabled: hasOnlyKeywordFilter(filters),
4295
- label: t("segments.saveAsSegment"),
1390
+ label: t("neetoFilters.segments.saveAsSegment"),
4296
1391
  style: "secondary",
4297
1392
  onClick: function onClick() {
4298
1393
  setIsFilterPaneOpen(false);
@@ -4300,16 +1395,16 @@ var Segment = function Segment(_ref) {
4300
1395
  }
4301
1396
  }) : /*#__PURE__*/React__default["default"].createElement(neetoui.Dropdown, {
4302
1397
  buttonStyle: "secondary",
4303
- label: t("segments.saveSegment")
1398
+ label: t("neetoFilters.segments.saveSegment")
4304
1399
  }, /*#__PURE__*/React__default["default"].createElement(Menu, null, /*#__PURE__*/React__default["default"].createElement(MenuItem.Button, {
4305
1400
  isDisabled: ramda.equals(filtersPayload, selectedSegment === null || selectedSegment === void 0 ? void 0 : selectedSegment.filters),
4306
1401
  onClick: setIsUpdateAlertOpen
4307
- }, t("segments.saveSegment")), /*#__PURE__*/React__default["default"].createElement(MenuItem.Button, {
1402
+ }, t("neetoFilters.segments.saveSegment")), /*#__PURE__*/React__default["default"].createElement(MenuItem.Button, {
4308
1403
  onClick: function onClick() {
4309
1404
  setIsFilterPaneOpen(false);
4310
1405
  setIsSavePaneOpen(true);
4311
1406
  }
4312
- }, t("segments.saveAsNewSegment")))), /*#__PURE__*/React__default["default"].createElement(neetoui.Pane, {
1407
+ }, t("neetoFilters.segments.saveAsNewSegment")))), /*#__PURE__*/React__default["default"].createElement(neetoui.Pane, {
4313
1408
  initialFocusRef: inputRef,
4314
1409
  isOpen: isSavePaneOpen,
4315
1410
  onClose: function onClose() {
@@ -4318,7 +1413,7 @@ var Segment = function Segment(_ref) {
4318
1413
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Header, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
4319
1414
  style: "h2",
4320
1415
  weight: "semibold"
4321
- }, t("segments.addNewSegment"))), /*#__PURE__*/React__default["default"].createElement(formik.Form, {
1416
+ }, t("neetoFilters.segments.addNewSegment"))), /*#__PURE__*/React__default["default"].createElement(formik.Form, {
4322
1417
  className: "w-full",
4323
1418
  formProps: {
4324
1419
  noValidate: true
@@ -4334,9 +1429,9 @@ var Segment = function Segment(_ref) {
4334
1429
  }
4335
1430
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Body, null, /*#__PURE__*/React__default["default"].createElement(formik.Input, {
4336
1431
  className: "w-full",
4337
- label: t("segments.name"),
1432
+ label: t("neetoFilters.segments.name"),
4338
1433
  name: "name",
4339
- placeholder: t("segments.segmentName"),
1434
+ placeholder: t("neetoFilters.segments.segmentName"),
4340
1435
  ref: inputRef
4341
1436
  })), /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Footer, {
4342
1437
  className: "flex items-center space-x-2"
@@ -4346,13 +1441,17 @@ var Segment = function Segment(_ref) {
4346
1441
  return setIsSavePaneOpen(false);
4347
1442
  },
4348
1443
  disabled: false
1444
+ },
1445
+ submitButtonProps: {
1446
+ disabled: isSubmitting,
1447
+ loading: isSubmitting
4349
1448
  }
4350
1449
  })))), /*#__PURE__*/React__default["default"].createElement(neetoui.Alert, {
4351
1450
  isOpen: isUpdateAlertOpen,
4352
1451
  isSubmitting: isUpdating,
4353
- message: t("segments.updateSegmentMessage"),
4354
- submitButtonLabel: t("common.update"),
4355
- title: t("segments.updateSegment"),
1452
+ message: t("neetoFilters.segments.updateSegmentMessage"),
1453
+ submitButtonLabel: t("neetoFilters.common.update"),
1454
+ title: t("neetoFilters.segments.updateSegment"),
4356
1455
  onClose: function onClose() {
4357
1456
  return setIsUpdateAlertOpen(false);
4358
1457
  },
@@ -4377,7 +1476,7 @@ var Bar = function Bar(_ref) {
4377
1476
  setIsPaneOpen = _ref$setIsPaneOpen === void 0 ? ramda.identity : _ref$setIsPaneOpen,
4378
1477
  _ref$childrenKeys = _ref.childrenKeys,
4379
1478
  childrenKeys = _ref$childrenKeys === void 0 ? [] : _ref$childrenKeys;
4380
- var _useTranslation = useTranslation(),
1479
+ var _useTranslation = reactI18next.useTranslation(),
4381
1480
  t = _useTranslation.t;
4382
1481
  var initialRenderRef = React.useRef(true);
4383
1482
  var searchParams = new URLSearchParams(window.location.search);
@@ -4385,7 +1484,7 @@ var Bar = function Bar(_ref) {
4385
1484
  key: "keyword",
4386
1485
  type: "text",
4387
1486
  rule: "contains",
4388
- label: t("labels.keyword")
1487
+ label: t("neetoFilters.labels.keyword")
4389
1488
  }, keyword);
4390
1489
  var filters = buildFiltersFromSearchParams(keyword.value !== "" ? [keywordFilter].concat(_toConsumableArray(columns)) : columns);
4391
1490
  var nonHiddenFilters = removeBy({
@@ -4479,7 +1578,7 @@ var Bar = function Bar(_ref) {
4479
1578
  setIsFilterPaneOpen: setIsPaneOpen
4480
1579
  }), !hideClearButton && /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
4481
1580
  "data-cy": "neeto-filters-bar-clear-btn",
4482
- label: t("common.clearFilters"),
1581
+ label: t("neetoFilters.common.clearFilters"),
4483
1582
  style: "text",
4484
1583
  onClick: handleClearAll
4485
1584
  }));
@@ -7144,7 +4243,7 @@ var Boolean = function Boolean(_ref) {
7144
4243
  filter: filter,
7145
4244
  options: options
7146
4245
  });
7147
- var _useTranslation = useTranslation(),
4246
+ var _useTranslation = reactI18next.useTranslation(),
7148
4247
  t = _useTranslation.t;
7149
4248
  var handleChange = function handleChange(option) {
7150
4249
  if (ramda.isEmpty(option) || ramda.isNil(option)) {
@@ -7161,14 +4260,14 @@ var Boolean = function Boolean(_ref) {
7161
4260
  handleApplyFilter(updatedFilter);
7162
4261
  };
7163
4262
  return /*#__PURE__*/React__default["default"].createElement(neetoui.Select, _extends$1({
7164
- isClearable: true,
7165
4263
  autoFocus: autoFocus,
7166
- "data-cy": "neeto-filters-".concat(key, "-filter"),
7167
4264
  label: label,
7168
4265
  options: options,
7169
- strategy: "fixed",
7170
4266
  value: value,
7171
- placeholder: t("messages.selectOption", {
4267
+ isClearable: true,
4268
+ "data-cy": "neeto-filters-".concat(key, "-filter"),
4269
+ strategy: "fixed",
4270
+ placeholder: t("neetoFilters.messages.selectOption", {
7172
4271
  resource: label.toLocaleLowerCase()
7173
4272
  }),
7174
4273
  onChange: handleChange
@@ -7185,7 +4284,7 @@ var Datetime = function Datetime(_ref) {
7185
4284
  _useState2 = _slicedToArray(_useState, 2),
7186
4285
  selectedRule = _useState2[0],
7187
4286
  setSelectedRule = _useState2[1];
7188
- var _useTranslation = useTranslation(),
4287
+ var _useTranslation = reactI18next.useTranslation(),
7189
4288
  t = _useTranslation.t;
7190
4289
  var key = column.key,
7191
4290
  _column$defaultType = column.defaultType,
@@ -7234,14 +4333,14 @@ var Datetime = function Datetime(_ref) {
7234
4333
  return /*#__PURE__*/React__default["default"].createElement("div", {
7235
4334
  className: "neeto-filters-pane-filter__item-wrapper"
7236
4335
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Select, {
7237
- isClearable: true,
7238
4336
  autoFocus: autoFocus,
7239
4337
  label: label,
4338
+ isClearable: true,
7240
4339
  "data-cy": "neeto-filters-".concat(key, "-filter"),
7241
4340
  options: DATE_OPTIONS,
7242
4341
  strategy: "fixed",
7243
4342
  value: selectedRule,
7244
- placeholder: t("messages.selectResource", {
4343
+ placeholder: t("neetoFilters.messages.selectResource", {
7245
4344
  resource: label.toLocaleLowerCase()
7246
4345
  }),
7247
4346
  onChange: handleChange
@@ -7279,7 +4378,7 @@ var Dropdown = function Dropdown(_ref) {
7279
4378
  filter: filter,
7280
4379
  options: options
7281
4380
  });
7282
- var _useTranslation = useTranslation(),
4381
+ var _useTranslation = reactI18next.useTranslation(),
7283
4382
  t = _useTranslation.t;
7284
4383
  var handleChange = function handleChange(option) {
7285
4384
  if (ramda.isEmpty(option) || ramda.isNil(option)) {
@@ -7297,14 +4396,14 @@ var Dropdown = function Dropdown(_ref) {
7297
4396
  };
7298
4397
  return /*#__PURE__*/React__default["default"].createElement(neetoui.Select, _extends$1({
7299
4398
  autoFocus: autoFocus,
4399
+ label: label,
4400
+ options: options,
4401
+ value: value,
7300
4402
  "data-cy": "neeto-filters-".concat(key, "-filter"),
7301
4403
  isClearable: !defaultValue && isClearable,
7302
4404
  isMulti: isMulti(defaultType),
7303
- label: label,
7304
- options: options,
7305
4405
  strategy: "fixed",
7306
- value: value,
7307
- placeholder: t("messages.selectResource", {
4406
+ placeholder: t("neetoFilters.messages.selectResource", {
7308
4407
  resource: label.toLocaleLowerCase()
7309
4408
  }),
7310
4409
  onChange: handleChange
@@ -7505,7 +4604,7 @@ var Text = function Text(_ref) {
7505
4604
  selectedRule = _useState4[0],
7506
4605
  setSelectedRule = _useState4[1];
7507
4606
  var debouncedInputValue = reactUtils.useDebounce(inputValue);
7508
- var _useTranslation = useTranslation(),
4607
+ var _useTranslation = reactI18next.useTranslation(),
7509
4608
  t = _useTranslation.t;
7510
4609
  var handleUpdateAndApplyFilter = function handleUpdateAndApplyFilter() {
7511
4610
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : debouncedInputValue;
@@ -7548,9 +4647,9 @@ var Text = function Text(_ref) {
7548
4647
  return /*#__PURE__*/React__default["default"].createElement("div", {
7549
4648
  className: "neeto-filters-pane-filter__item-wrapper"
7550
4649
  }, showRuleSelector && /*#__PURE__*/React__default["default"].createElement(neetoui.Select, {
4650
+ label: label,
7551
4651
  "data-cy": "neeto-filters-".concat(key, "-filter-rule"),
7552
4652
  defaultValue: ruleOptions[0],
7553
- label: label,
7554
4653
  options: ruleOptions,
7555
4654
  strategy: "fixed",
7556
4655
  value: selectedRule,
@@ -7561,7 +4660,7 @@ var Text = function Text(_ref) {
7561
4660
  label: !showRuleSelector && label,
7562
4661
  type: inputType,
7563
4662
  value: inputValue,
7564
- placeholder: t("messages.enterResource", {
4663
+ placeholder: t("neetoFilters.messages.enterResource", {
7565
4664
  resource: label.toLocaleLowerCase()
7566
4665
  }),
7567
4666
  onChange: function onChange(event) {
@@ -7583,7 +4682,7 @@ var Time = function Time(_ref) {
7583
4682
  var otherProps = getOtherProps(column);
7584
4683
  var value = buildSingleTimeValue(filter);
7585
4684
  var isCustomTimeRangeShown = filter && isCustomTimeRange(filter.value);
7586
- var _useTranslation = useTranslation(),
4685
+ var _useTranslation = reactI18next.useTranslation(),
7587
4686
  t = _useTranslation.t;
7588
4687
  var handleChange = function handleChange(option) {
7589
4688
  if (ramda.isEmpty(option) || ramda.isNil(option)) {
@@ -7614,14 +4713,14 @@ var Time = function Time(_ref) {
7614
4713
  return /*#__PURE__*/React__default["default"].createElement("div", {
7615
4714
  className: "neeto-filters-pane-filter__item-wrapper"
7616
4715
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Select, {
7617
- isClearable: true,
7618
4716
  autoFocus: autoFocus,
7619
4717
  label: label,
7620
4718
  value: value,
4719
+ isClearable: true,
7621
4720
  "data-cy": "neeto-filters-".concat(key, "-filter"),
7622
4721
  options: TIME_OPTIONS,
7623
4722
  strategy: "fixed",
7624
- placeholder: t("messages.selectResource", {
4723
+ placeholder: t("neetoFilters.messages.selectResource", {
7625
4724
  resource: label.toLocaleLowerCase()
7626
4725
  }),
7627
4726
  onChange: handleChange
@@ -7740,7 +4839,7 @@ var Pane = function Pane(_ref) {
7740
4839
  searchTerm = _useState2[0],
7741
4840
  setSearchTerm = _useState2[1];
7742
4841
  var history = reactRouterDom.useHistory();
7743
- var _useTranslation = useTranslation(),
4842
+ var _useTranslation = reactI18next.useTranslation(),
7744
4843
  t = _useTranslation.t;
7745
4844
  columns = React.useMemo(function () {
7746
4845
  return getColumnsWithStandardizedType(columns);
@@ -7776,7 +4875,7 @@ var Pane = function Pane(_ref) {
7776
4875
  key: "keyword",
7777
4876
  type: "text",
7778
4877
  rule: "contains",
7779
- label: t("labels.keyword")
4878
+ label: t("neetoFilters.labels.keyword")
7780
4879
  }, keyword);
7781
4880
  var handleClearAll = function handleClearAll() {
7782
4881
  keyword.setValue("");
@@ -7811,25 +4910,25 @@ var Pane = function Pane(_ref) {
7811
4910
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
7812
4911
  style: "h2",
7813
4912
  weight: "semibold"
7814
- }, t("common.filters"))), /*#__PURE__*/React__default["default"].createElement(Slider.Body, {
4913
+ }, t("neetoFilters.common.filters"))), /*#__PURE__*/React__default["default"].createElement(Slider.Body, {
7815
4914
  className: "neeto-filters-pane-filter__body neeto-ui-pt-2"
7816
4915
  }, isSearchable && /*#__PURE__*/React__default["default"].createElement(neetoui.Input, {
7817
4916
  autoFocus: true,
7818
4917
  "data-cy": "neeto-filters-column-search",
7819
4918
  prefix: /*#__PURE__*/React__default["default"].createElement(neetoIcons.Search, null),
7820
4919
  value: searchTerm,
7821
- placeholder: t("messages.searchResources", {
7822
- resources: t("common.filters").toLocaleLowerCase()
4920
+ placeholder: t("neetoFilters.messages.searchResources", {
4921
+ resources: t("neetoFilters.common.filters").toLocaleLowerCase()
7823
4922
  }),
7824
4923
  onChange: function onChange(event) {
7825
4924
  return setSearchTerm(event.target.value);
7826
4925
  }
7827
4926
  }), ungroupedColumns.map(function (column) {
7828
4927
  return /*#__PURE__*/React__default["default"].createElement(Item, {
7829
- autoFocus: column.key === isOpen,
7830
4928
  column: column,
7831
4929
  filters: filters,
7832
4930
  onClose: onClose,
4931
+ autoFocus: column.key === isOpen,
7833
4932
  key: column.key,
7834
4933
  onChange: handleChange
7835
4934
  });
@@ -7849,27 +4948,27 @@ var Pane = function Pane(_ref) {
7849
4948
  title: group
7850
4949
  }, columns.map(function (column) {
7851
4950
  return /*#__PURE__*/React__default["default"].createElement(Item, {
7852
- autoFocus: column.key === isOpen,
7853
4951
  column: column,
7854
4952
  filters: filters,
4953
+ autoFocus: column.key === isOpen,
7855
4954
  key: column.key,
7856
4955
  onChange: handleChange
7857
4956
  });
7858
4957
  }));
7859
4958
  })), ramda.isEmpty(ungroupedColumns) && ramda.isEmpty(groupedColumns) && /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
7860
4959
  style: "body2"
7861
- }, t("messages.noResourcesFound", {
7862
- resources: t("common.columns").toLocaleLowerCase()
4960
+ }, t("neetoFilters.messages.noResourcesFound", {
4961
+ resources: t("neetoFilters.common.columns").toLocaleLowerCase()
7863
4962
  })), children), /*#__PURE__*/React__default["default"].createElement(Slider.Footer, {
7864
4963
  className: "neeto-filters-pane-filter__footer"
7865
4964
  }, /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
7866
4965
  "data-cy": "neeto-filters-done-btn",
7867
- label: t("common.done"),
4966
+ label: t("neetoFilters.common.done"),
7868
4967
  onClick: onClose
7869
4968
  }), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
7870
4969
  "data-cy": "neeto-filters-clear-btn",
7871
4970
  disabled: isClearFiltersDisabled,
7872
- label: t("common.clearFilters"),
4971
+ label: t("neetoFilters.common.clearFilters"),
7873
4972
  style: "text",
7874
4973
  onClick: handleClearAll
7875
4974
  })))));
@@ -7914,7 +5013,7 @@ var Filters = reactUtils.withT(function (_ref) {
7914
5013
  className: classnames__default["default"](_defineProperty({}, className, className))
7915
5014
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, _extends$1({
7916
5015
  "data-cy": "neeto-filters-toggle-btn",
7917
- label: t("common.filter"),
5016
+ label: t("neetoFilters.common.filter"),
7918
5017
  style: "secondary",
7919
5018
  onClick: function onClick() {
7920
5019
  return setIsOpen(true);
@@ -7940,7 +5039,7 @@ var DeleteAlert = function DeleteAlert(_ref) {
7940
5039
  onClose = _ref.onClose,
7941
5040
  segment = _ref.segment,
7942
5041
  columns = _ref.columns;
7943
- var _useTranslation = useTranslation(),
5042
+ var _useTranslation = reactI18next.useTranslation(),
7944
5043
  t = _useTranslation.t;
7945
5044
  var history = reactRouterDom.useHistory();
7946
5045
  var _getQueryParams = utils.getQueryParams(),
@@ -7966,16 +5065,16 @@ var DeleteAlert = function DeleteAlert(_ref) {
7966
5065
  };
7967
5066
  return /*#__PURE__*/React__default["default"].createElement(neetoui.Alert, {
7968
5067
  isOpen: isOpen,
5068
+ onClose: onClose,
7969
5069
  isSubmitting: isDeleting,
7970
- submitButtonLabel: t("common.delete"),
7971
- title: t("segments.deleteAlertTitle"),
7972
- message: /*#__PURE__*/React__default["default"].createElement(Trans, {
7973
- i18nKey: "segments.deleteAlertMessage",
5070
+ submitButtonLabel: t("neetoFilters.common.delete"),
5071
+ title: t("neetoFilters.segments.deleteAlertTitle"),
5072
+ message: /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
5073
+ i18nKey: "neetoFilters.segments.deleteAlertMessage",
7974
5074
  values: {
7975
5075
  entity: segment.name
7976
5076
  }
7977
5077
  }),
7978
- onClose: onClose,
7979
5078
  onSubmit: handleDelete
7980
5079
  });
7981
5080
  };
@@ -7991,7 +5090,7 @@ var Card = function Card(_ref) {
7991
5090
  _useState4 = _slicedToArray(_useState3, 2),
7992
5091
  isDeleteAlertOpen = _useState4[0],
7993
5092
  setIsDeleteAlertOpen = _useState4[1];
7994
- var _useTranslation = useTranslation(),
5093
+ var _useTranslation = reactI18next.useTranslation(),
7995
5094
  t = _useTranslation.t;
7996
5095
  var Menu = neetoui.Dropdown.Menu,
7997
5096
  MenuItem = neetoui.Dropdown.MenuItem;
@@ -8008,7 +5107,7 @@ var Card = function Card(_ref) {
8008
5107
  });
8009
5108
  };
8010
5109
  return /*#__PURE__*/React__default["default"].createElement(formik.Form, {
8011
- className: "flex w-full items-center justify-between rounded-md border p-2",
5110
+ className: "neeto-ui-rounded-md flex w-full items-center justify-between border p-2",
8012
5111
  formProps: {
8013
5112
  noValidate: true
8014
5113
  },
@@ -8025,7 +5124,7 @@ var Card = function Card(_ref) {
8025
5124
  autoFocus: true,
8026
5125
  nakedInput: true,
8027
5126
  name: "name",
8028
- placeholder: t("segments.name")
5127
+ placeholder: t("neetoFilters.segments.name")
8029
5128
  }), /*#__PURE__*/React__default["default"].createElement(formik.ActionBlock, {
8030
5129
  cancelButtonProps: {
8031
5130
  icon: neetoIcons.Close,
@@ -8052,14 +5151,14 @@ var Card = function Card(_ref) {
8052
5151
  setIsEditing(true);
8053
5152
  resetForm();
8054
5153
  }
8055
- }, t("common.rename")), /*#__PURE__*/React__default["default"].createElement(MenuItem.Button, {
5154
+ }, t("neetoFilters.common.rename")), /*#__PURE__*/React__default["default"].createElement(MenuItem.Button, {
8056
5155
  onClick: function onClick() {
8057
5156
  return setIsDeleteAlertOpen(true);
8058
5157
  }
8059
- }, t("common.delete"))))), /*#__PURE__*/React__default["default"].createElement(DeleteAlert, {
5158
+ }, t("neetoFilters.common.delete"))))), /*#__PURE__*/React__default["default"].createElement(DeleteAlert, {
8060
5159
  columns: columns,
8061
- isOpen: isDeleteAlertOpen,
8062
5160
  segment: segment,
5161
+ isOpen: isDeleteAlertOpen,
8063
5162
  onClose: function onClose() {
8064
5163
  return setIsDeleteAlertOpen(false);
8065
5164
  }
@@ -8078,7 +5177,7 @@ var ManagePane = function ManagePane(_ref) {
8078
5177
  searchTerm = _useState2[0],
8079
5178
  setSearchTerm = _useState2[1];
8080
5179
  var inputRef = React.useRef(null);
8081
- var _useTranslation = useTranslation(),
5180
+ var _useTranslation = reactI18next.useTranslation(),
8082
5181
  t = _useTranslation.t;
8083
5182
  var debouncedSearchTerm = reactUtils.useDebounce(searchTerm);
8084
5183
  var _useFetchSegments = useFetchSegments({
@@ -8089,16 +5188,16 @@ var ManagePane = function ManagePane(_ref) {
8089
5188
  segments = _useFetchSegments$dat === void 0 ? [] : _useFetchSegments$dat,
8090
5189
  isLoading = _useFetchSegments.isLoading;
8091
5190
  return /*#__PURE__*/React__default["default"].createElement(neetoui.Pane, {
8092
- initialFocusRef: inputRef,
8093
5191
  isOpen: isOpen,
8094
- onClose: onClose
5192
+ onClose: onClose,
5193
+ initialFocusRef: inputRef
8095
5194
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Header, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
8096
5195
  style: "h2"
8097
- }, t("segments.manageSegments"))), /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Body, {
5196
+ }, t("neetoFilters.segments.manageSegments"))), /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Body, {
8098
5197
  className: "max-h-full gap-4 overflow-scroll"
8099
5198
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Input, {
8100
5199
  className: "w-full flex-grow-0",
8101
- placeholder: t("segments.searchSegments"),
5200
+ placeholder: t("neetoFilters.segments.searchSegments"),
8102
5201
  prefix: /*#__PURE__*/React__default["default"].createElement(neetoIcons.Search, null),
8103
5202
  ref: inputRef,
8104
5203
  type: "search",
@@ -8112,16 +5211,16 @@ var ManagePane = function ManagePane(_ref) {
8112
5211
  }) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, ramda.isEmpty(segments) ? /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
8113
5212
  className: "mx-auto",
8114
5213
  style: "body2"
8115
- }, t("segments.noSegmentsFound")) : segments.map(function (segment) {
5214
+ }, t("neetoFilters.segments.noSegmentsFound")) : segments.map(function (segment) {
8116
5215
  return /*#__PURE__*/React__default["default"].createElement(Card$1, {
8117
5216
  columns: columns,
8118
- key: segment.id,
8119
- segment: segment
5217
+ segment: segment,
5218
+ key: segment.id
8120
5219
  });
8121
5220
  }))));
8122
5221
  };
8123
5222
 
8124
- var ITEMS_MAX_COUNT = 3;
5223
+ var ITEMS_MAX_COUNT = 20;
8125
5224
 
8126
5225
  var MenuBlocks = function MenuBlocks(_ref) {
8127
5226
  var entity = _ref.entity,
@@ -8133,7 +5232,7 @@ var MenuBlocks = function MenuBlocks(_ref) {
8133
5232
  setShowAll = _useState2[1];
8134
5233
  var location = reactRouterDom.useLocation();
8135
5234
  var history = reactRouterDom.useHistory();
8136
- var _useTranslation = useTranslation(),
5235
+ var _useTranslation = reactI18next.useTranslation(),
8137
5236
  t = _useTranslation.t;
8138
5237
  var _Object$fromEntries = Object.fromEntries(new URLSearchParams(location.search)),
8139
5238
  segmentId = _Object$fromEntries.segmentId;
@@ -8171,12 +5270,12 @@ var MenuBlocks = function MenuBlocks(_ref) {
8171
5270
  if (ramda.isEmpty(segments)) {
8172
5271
  return /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
8173
5272
  style: "body2"
8174
- }, t("segments.noSegmentsFound"));
5273
+ }, t("neetoFilters.segments.noSegmentsFound"));
8175
5274
  }
8176
5275
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, segments.length > ITEMS_MAX_COUNT && /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
8177
5276
  icon: neetoIcons.Down,
8178
5277
  style: "link",
8179
- label: showAll ? t("segments.showLess") : t("segments.showMoreNumbers", {
5278
+ label: showAll ? t("neetoFilters.segments.showLess") : t("neetoFilters.segments.showMoreNumbers", {
8180
5279
  entity: segments.length - ITEMS_MAX_COUNT
8181
5280
  }),
8182
5281
  onClick: function onClick() {
@@ -8215,7 +5314,7 @@ var Segments = function Segments(_ref) {
8215
5314
  _useState6 = _slicedToArray(_useState5, 2),
8216
5315
  isSegmentsPaneOpen = _useState6[0],
8217
5316
  setIsSegmentsPaneOpen = _useState6[1];
8218
- var _useTranslation = useTranslation(),
5317
+ var _useTranslation = reactI18next.useTranslation(),
8219
5318
  t = _useTranslation.t;
8220
5319
  var debouncedSearchTerm = reactUtils.useDebounce(searchTerm);
8221
5320
  var iconProps = [{
@@ -8227,7 +5326,7 @@ var Segments = function Segments(_ref) {
8227
5326
  });
8228
5327
  },
8229
5328
  tooltipProps: {
8230
- content: t("segments.searchSegments"),
5329
+ content: t("neetoFilters.segments.searchSegments"),
8231
5330
  position: "top"
8232
5331
  }
8233
5332
  }, {
@@ -8237,7 +5336,7 @@ var Segments = function Segments(_ref) {
8237
5336
  setIsSegmentsPaneOpen(true);
8238
5337
  },
8239
5338
  tooltipProps: {
8240
- content: t("segments.manageSegments"),
5339
+ content: t("neetoFilters.segments.manageSegments"),
8241
5340
  position: "top"
8242
5341
  }
8243
5342
  }];
@@ -8248,10 +5347,10 @@ var Segments = function Segments(_ref) {
8248
5347
  style: "h5",
8249
5348
  textTransform: "uppercase",
8250
5349
  weight: "bold"
8251
- }, t("common.segments"))), /*#__PURE__*/React__default["default"].createElement(MenuBar__default["default"].Search, {
5350
+ }, t("neetoFilters.common.segments"))), /*#__PURE__*/React__default["default"].createElement(MenuBar__default["default"].Search, {
8252
5351
  autoFocus: true,
8253
5352
  isCollapsed: isSearchCollapsed,
8254
- placeholder: t("segments.searchSegments"),
5353
+ placeholder: t("neetoFilters.segments.searchSegments"),
8255
5354
  value: searchTerm,
8256
5355
  onChange: function onChange(_ref2) {
8257
5356
  var value = _ref2.target.value;
@@ -8276,7 +5375,75 @@ var Segments = function Segments(_ref) {
8276
5375
  };
8277
5376
  var index = /*#__PURE__*/React__default["default"].memo(Segments);
8278
5377
 
8279
- instance.use(initReactI18next).init({
5378
+ var neetoFilters = {
5379
+ common: {
5380
+ clearFilters: "Clear filters",
5381
+ columns: "Columns",
5382
+ "delete": "Delete",
5383
+ done: "Done",
5384
+ filter: "Filter",
5385
+ filters: "Filters",
5386
+ no: "No",
5387
+ proceed: "Proceed",
5388
+ rename: "Rename",
5389
+ segments: "Segments",
5390
+ userCount: "{{count}} Users",
5391
+ yes: "Yes",
5392
+ update: "Update"
5393
+ },
5394
+ messages: {
5395
+ enterResource: "Enter {{resource}}",
5396
+ noResourcesFound: "No {{resources}} found",
5397
+ searchResources: "Search {{resources}}",
5398
+ selectResource: "Select {{resource}}",
5399
+ selectOption: "Select an option"
5400
+ },
5401
+ rules: {
5402
+ contains: "Contains",
5403
+ doesNotContain: "Does not contain",
5404
+ exactly: "Exactly",
5405
+ notExactly: "Not exactly",
5406
+ startsWith: "Starts with",
5407
+ doesNotStartWith: "Does not start with",
5408
+ endsWith: "Ends with",
5409
+ doesNotEndWith: "Does not end with",
5410
+ greaterThan: "Greater than",
5411
+ lessThan: "Less than"
5412
+ },
5413
+ errors: {
5414
+ cannotPassMultipleModels: "Cannot pass multiple Models except for keyword searching"
5415
+ },
5416
+ shortcuts: {
5417
+ deleteBlock: "Delete block",
5418
+ openFilterPane: "Open filter pane",
5419
+ closePane: "Close pane"
5420
+ },
5421
+ segments: {
5422
+ addNewSegment: "Add new segment",
5423
+ deleteAlertMessage: "You are permanently deleting the segment <strong>{{entity}}</strong>. This can't be undone.",
5424
+ deleteAlertTitle: "Delete segment?",
5425
+ manageSegments: "Manage segments",
5426
+ name: "Segment name",
5427
+ noSegmentsFound: "No segments found",
5428
+ saveSegment: "Save segment",
5429
+ saveAsSegment: "Save as segment",
5430
+ saveAsNewSegment: "Save as new segment",
5431
+ searchSegments: "Search segments",
5432
+ segmentName: "Segment name",
5433
+ showLess: "See less",
5434
+ showMoreNumbers: "See {{entity}} more",
5435
+ updateSegment: "Update segment?",
5436
+ updateSegmentMessage: "You are trying to update the current segment."
5437
+ },
5438
+ labels: {
5439
+ keyword: "Keyword"
5440
+ }
5441
+ };
5442
+ var en = {
5443
+ neetoFilters: neetoFilters
5444
+ };
5445
+
5446
+ i18next__default["default"].use(reactI18next.initReactI18next).init({
8280
5447
  resources: {
8281
5448
  en: {
8282
5449
  translation: en