@tolgee/core 5.0.0-alpha.1 → 5.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +174 -0
  2. package/README.njk.md +61 -0
  3. package/dist/tolgee.cjs.js +185 -143
  4. package/dist/tolgee.cjs.js.map +1 -1
  5. package/dist/tolgee.cjs.min.js +1 -1
  6. package/dist/tolgee.cjs.min.js.map +1 -1
  7. package/dist/tolgee.esm.js +185 -143
  8. package/dist/tolgee.esm.js.map +1 -1
  9. package/dist/tolgee.esm.min.mjs +1 -1
  10. package/dist/tolgee.esm.min.mjs.map +1 -1
  11. package/dist/tolgee.umd.js +185 -143
  12. package/dist/tolgee.umd.js.map +1 -1
  13. package/dist/tolgee.umd.min.js +1 -1
  14. package/dist/tolgee.umd.min.js.map +1 -1
  15. package/lib/Controller/Controller.d.ts +8 -4
  16. package/lib/Controller/Events/EventEmitter.d.ts +1 -1
  17. package/lib/Controller/Events/EventEmitterSelective.d.ts +1 -1
  18. package/lib/Controller/Events/Events.d.ts +1 -0
  19. package/lib/Controller/Plugins/Plugins.d.ts +4 -4
  20. package/lib/Controller/State/State.d.ts +2 -1
  21. package/lib/Controller/State/initState.d.ts +13 -2
  22. package/lib/{Tolgee.d.ts → TolgeeCore.d.ts} +13 -4
  23. package/lib/helpers.d.ts +1 -0
  24. package/lib/index.d.ts +1 -1
  25. package/lib/types/events.d.ts +2 -2
  26. package/lib/types/index.d.ts +1 -1
  27. package/lib/types/plugin.d.ts +6 -9
  28. package/package.json +2 -2
  29. package/src/Controller/Controller.ts +5 -4
  30. package/src/Controller/Events/EventEmitter.ts +6 -2
  31. package/src/Controller/Events/EventEmitterSelective.test.ts +23 -0
  32. package/src/Controller/Events/EventEmitterSelective.ts +8 -5
  33. package/src/Controller/Events/Events.ts +19 -8
  34. package/src/Controller/Plugins/Plugins.ts +66 -63
  35. package/src/Controller/State/initState.ts +16 -1
  36. package/src/{Tolgee.ts → TolgeeCore.ts} +12 -3
  37. package/src/__test/backend.test.ts +2 -2
  38. package/src/__test/cache.test.ts +6 -3
  39. package/src/__test/client.test.ts +2 -2
  40. package/src/__test/events.test.ts +30 -5
  41. package/src/__test/format.simple.test.ts +2 -14
  42. package/src/__test/formatError.test.ts +61 -0
  43. package/src/__test/initialization.test.ts +4 -4
  44. package/src/__test/languageDetection.test.ts +8 -8
  45. package/src/__test/languageStorage.test.ts +10 -11
  46. package/src/__test/languages.test.ts +8 -8
  47. package/src/__test/loading.test.ts +2 -2
  48. package/src/__test/namespaces.fallback.test.ts +5 -5
  49. package/src/__test/namespaces.test.ts +4 -4
  50. package/src/__test/options.test.ts +3 -3
  51. package/src/__test/plugins.test.ts +4 -4
  52. package/src/helpers.ts +8 -0
  53. package/src/index.ts +1 -1
  54. package/src/types/events.ts +2 -2
  55. package/src/types/index.ts +1 -1
  56. package/src/types/plugin.ts +12 -12
@@ -45,8 +45,16 @@
45
45
  function sanitizeUrl(url) {
46
46
  return url ? url.replace(/\/+$/, '') : url;
47
47
  }
48
+ function getErrorMessage(error) {
49
+ if (typeof error === 'string') {
50
+ return error;
51
+ }
52
+ else if (typeof (error === null || error === void 0 ? void 0 : error.message) === 'string') {
53
+ return error.message;
54
+ }
55
+ }
48
56
 
49
- const EventEmitter = () => {
57
+ const EventEmitter = (isActive) => {
50
58
  let handlers = [];
51
59
  const listen = (handler) => {
52
60
  const handlerWrapper = (e) => {
@@ -60,12 +68,14 @@
60
68
  };
61
69
  };
62
70
  const emit = (data) => {
63
- handlers.forEach((handler) => handler({ value: data }));
71
+ if (isActive()) {
72
+ handlers.forEach((handler) => handler({ value: data }));
73
+ }
64
74
  };
65
75
  return Object.freeze({ listen, emit });
66
76
  };
67
77
 
68
- const EventEmitterSelective = (getFallbackNs, getDefaultNs) => {
78
+ const EventEmitterSelective = (isActive, getFallbackNs, getDefaultNs) => {
69
79
  const listeners = new Set();
70
80
  const partialListeners = new Set();
71
81
  const listen = (handler) => {
@@ -139,26 +149,32 @@
139
149
  callHandlers(namespacesArray);
140
150
  };
141
151
  const emit = (ns, delayed) => {
142
- queue.push(ns);
143
- if (!delayed) {
144
- solveQueue();
145
- }
146
- else {
147
- setTimeout(solveQueue, 0);
152
+ if (isActive()) {
153
+ queue.push(ns);
154
+ if (!delayed) {
155
+ solveQueue();
156
+ }
157
+ else {
158
+ setTimeout(solveQueue, 0);
159
+ }
148
160
  }
149
161
  };
150
162
  return Object.freeze({ listenSome, listen, emit });
151
163
  };
152
164
 
153
165
  const Events = (getFallbackNs, getDefaultNs) => {
154
- const onPendingLanguageChange = EventEmitter();
155
- const onLanguageChange = EventEmitter();
156
- const onLoadingChange = EventEmitter();
157
- const onFetchingChange = EventEmitter();
158
- const onInitialLoaded = EventEmitter();
159
- const onRunningChange = EventEmitter();
160
- const onCacheChange = EventEmitter();
161
- const onUpdate = EventEmitterSelective(getFallbackNs, getDefaultNs);
166
+ let emitterActive = true;
167
+ function isActive() {
168
+ return emitterActive;
169
+ }
170
+ const onPendingLanguageChange = EventEmitter(isActive);
171
+ const onLanguageChange = EventEmitter(isActive);
172
+ const onLoadingChange = EventEmitter(isActive);
173
+ const onFetchingChange = EventEmitter(isActive);
174
+ const onInitialLoaded = EventEmitter(isActive);
175
+ const onRunningChange = EventEmitter(isActive);
176
+ const onCacheChange = EventEmitter(isActive);
177
+ const onUpdate = EventEmitterSelective(isActive, getFallbackNs, getDefaultNs);
162
178
  onInitialLoaded.listen(() => onUpdate.emit());
163
179
  onLanguageChange.listen(() => onUpdate.emit());
164
180
  onCacheChange.listen(({ value }) => {
@@ -184,6 +200,9 @@
184
200
  return onUpdate.listen(handler);
185
201
  }
186
202
  };
203
+ function setEmmiterActive(active) {
204
+ emitterActive = active;
205
+ }
187
206
  return Object.freeze({
188
207
  onPendingLanguageChange,
189
208
  onLanguageChange,
@@ -193,6 +212,7 @@
193
212
  onRunningChange,
194
213
  onCacheChange,
195
214
  onUpdate,
215
+ setEmmiterActive,
196
216
  on,
197
217
  });
198
218
  };
@@ -432,9 +452,78 @@
432
452
  });
433
453
  };
434
454
 
455
+ /******************************************************************************
456
+ Copyright (c) Microsoft Corporation.
457
+
458
+ Permission to use, copy, modify, and/or distribute this software for any
459
+ purpose with or without fee is hereby granted.
460
+
461
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
462
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
463
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
464
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
465
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
466
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
467
+ PERFORMANCE OF THIS SOFTWARE.
468
+ ***************************************************************************** */
469
+
470
+ function __rest(s, e) {
471
+ var t = {};
472
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
473
+ t[p] = s[p];
474
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
475
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
476
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
477
+ t[p[i]] = s[p[i]];
478
+ }
479
+ return t;
480
+ }
481
+
482
+ const defaultObserverOptions = {
483
+ tagAttributes: {
484
+ textarea: ['placeholder'],
485
+ input: ['value', 'placeholder'],
486
+ img: ['alt'],
487
+ '*': ['aria-label', 'title'],
488
+ },
489
+ restrictedElements: ['script', 'style'],
490
+ highlightKeys: ['Alt'],
491
+ highlightColor: 'rgb(255, 0, 0)',
492
+ highlightWidth: 5,
493
+ inputPrefix: '%-%tolgee:',
494
+ inputSuffix: '%-%',
495
+ passToParent: ['option', 'optgroup'],
496
+ };
497
+
498
+ const DEFAULT_FORMAT_ERROR = 'invalid';
499
+ const defaultValues = {
500
+ defaultNs: '',
501
+ observerOptions: defaultObserverOptions,
502
+ observerType: 'invisible',
503
+ onFormatError: DEFAULT_FORMAT_ERROR,
504
+ };
505
+ const combineOptions = (...states) => {
506
+ let result = {};
507
+ states.forEach((state) => {
508
+ result = Object.assign(Object.assign(Object.assign({}, result), state), { observerOptions: Object.assign(Object.assign({}, result.observerOptions), state === null || state === void 0 ? void 0 : state.observerOptions) });
509
+ });
510
+ return result;
511
+ };
512
+ const initState = (options, previousState) => {
513
+ const initialOptions = combineOptions(defaultValues, previousState === null || previousState === void 0 ? void 0 : previousState.initialOptions, options);
514
+ // remove extra '/' from url end
515
+ initialOptions.apiUrl = sanitizeUrl(initialOptions.apiUrl);
516
+ return {
517
+ initialOptions,
518
+ activeNamespaces: (previousState === null || previousState === void 0 ? void 0 : previousState.activeNamespaces) || new Map(),
519
+ language: previousState === null || previousState === void 0 ? void 0 : previousState.language,
520
+ pendingLanguage: previousState === null || previousState === void 0 ? void 0 : previousState.language,
521
+ isInitialLoading: false,
522
+ isRunning: false,
523
+ };
524
+ };
525
+
435
526
  const Plugins = (getLanguage, getInitialOptions, getAvailableLanguages, getTranslationNs, getTranslation, changeTranslation) => {
436
- let prepared = false;
437
- let onPrepareQueue = [];
438
527
  const plugins = {
439
528
  ui: undefined,
440
529
  observer: undefined,
@@ -495,7 +584,7 @@
495
584
  instances.finalFormatter = formatter;
496
585
  };
497
586
  const setUi = (ui) => {
498
- plugins.ui = (ui === null || ui === void 0 ? void 0 : ui.UI) || ui;
587
+ plugins.ui = ui;
499
588
  };
500
589
  const hasUi = () => {
501
590
  return Boolean(plugins.ui);
@@ -503,6 +592,9 @@
503
592
  const setLanguageStorage = (storage) => {
504
593
  instances.languageStorage = storage;
505
594
  };
595
+ const getLanguageStorage = () => {
596
+ return instances.languageStorage;
597
+ };
506
598
  const setStoredLanguage = (language) => {
507
599
  var _a;
508
600
  (_a = instances.languageStorage) === null || _a === void 0 ? void 0 : _a.setLanguage(language);
@@ -542,11 +634,11 @@
542
634
  const setDevBackend = (backend) => {
543
635
  instances.devBackend = backend;
544
636
  };
545
- const run = (isDev) => {
546
- var _a, _b;
547
- if (!instances.ui && plugins.ui) {
637
+ const run = () => {
638
+ var _a, _b, _c;
639
+ if (!instances.ui) {
548
640
  const { apiKey, apiUrl, projectId } = getInitialOptions();
549
- instances.ui = new plugins.ui({
641
+ instances.ui = (_a = plugins.ui) === null || _a === void 0 ? void 0 : _a.call(plugins, {
550
642
  apiKey: apiKey,
551
643
  apiUrl: apiUrl,
552
644
  projectId,
@@ -555,13 +647,13 @@
555
647
  });
556
648
  }
557
649
  if (!instances.observer) {
558
- instances.observer = (_a = plugins.observer) === null || _a === void 0 ? void 0 : _a.call(plugins, {
650
+ instances.observer = (_b = plugins.observer) === null || _b === void 0 ? void 0 : _b.call(plugins, {
559
651
  translate,
560
652
  onClick,
561
653
  options: getInitialOptions().observerOptions,
562
654
  });
563
655
  }
564
- (_b = instances.observer) === null || _b === void 0 ? void 0 : _b.run({ mouseHighlight: isDev });
656
+ (_c = instances.observer) === null || _c === void 0 ? void 0 : _c.run({ mouseHighlight: true });
565
657
  };
566
658
  const getDevBackend = () => {
567
659
  return instances.devBackend;
@@ -604,9 +696,6 @@
604
696
  var _a;
605
697
  (_a = instances.observer) === null || _a === void 0 ? void 0 : _a.retranslate();
606
698
  };
607
- const onPrepare = (callback) => {
608
- onPrepareQueue.push(callback);
609
- };
610
699
  function addPlugin(tolgeeInstance, plugin) {
611
700
  const pluginTools = Object.freeze({
612
701
  setFinalFormatter,
@@ -619,46 +708,68 @@
619
708
  addBackend,
620
709
  setLanguageDetector,
621
710
  setLanguageStorage,
622
- onPrepare,
623
711
  });
624
712
  plugin(tolgeeInstance, pluginTools);
625
- if (prepared) {
626
- prepare();
627
- }
628
713
  }
629
- function formatTranslation({ key, translation, defaultValue, noWrap, params, orEmpty, ns, formatEnabled, }) {
630
- var _a;
714
+ function formatTranslation(_a) {
715
+ var _b;
716
+ var { formatEnabled } = _a, props = __rest(_a, ["formatEnabled"]);
717
+ const { key, translation, defaultValue, noWrap, params, orEmpty, ns } = props;
631
718
  const formattableTranslation = translation || defaultValue;
632
719
  let result = formattableTranslation || (orEmpty ? '' : key);
633
- if (instances.observer && !noWrap) {
634
- result = instances.observer.wrap({
635
- key,
636
- translation: result,
637
- defaultValue,
638
- params,
639
- ns,
640
- });
641
- }
642
720
  const language = getLanguage();
643
- const isFormatEnabled = formatEnabled || !((_a = instances.observer) === null || _a === void 0 ? void 0 : _a.outputNotFormattable);
644
- if (formattableTranslation && language && isFormatEnabled) {
645
- for (const formatter of instances.formatters) {
646
- result = formatter.format({
721
+ const isFormatEnabled = formatEnabled || !((_b = instances.observer) === null || _b === void 0 ? void 0 : _b.outputNotFormattable);
722
+ const wrap = (result) => {
723
+ if (instances.observer && !noWrap) {
724
+ return instances.observer.wrap({
725
+ key,
726
+ translation: result,
727
+ defaultValue,
728
+ params,
729
+ ns,
730
+ });
731
+ }
732
+ return result;
733
+ };
734
+ result = wrap(result);
735
+ try {
736
+ if (formattableTranslation && language && isFormatEnabled) {
737
+ for (const formatter of instances.formatters) {
738
+ result = formatter.format({
739
+ translation: result,
740
+ language,
741
+ params,
742
+ });
743
+ }
744
+ }
745
+ if (instances.finalFormatter &&
746
+ formattableTranslation &&
747
+ language &&
748
+ isFormatEnabled) {
749
+ result = instances.finalFormatter.format({
647
750
  translation: result,
648
751
  language,
649
752
  params,
650
753
  });
651
754
  }
652
755
  }
653
- if (instances.finalFormatter &&
654
- formattableTranslation &&
655
- language &&
656
- isFormatEnabled) {
657
- result = instances.finalFormatter.format({
658
- translation: result,
659
- language,
660
- params,
661
- });
756
+ catch (e) {
757
+ // eslint-disable-next-line no-console
758
+ console.error(e);
759
+ const errorMessage = getErrorMessage(e) || DEFAULT_FORMAT_ERROR;
760
+ const onFormatError = getInitialOptions().onFormatError;
761
+ const formatErrorType = typeof onFormatError;
762
+ if (formatErrorType === 'string') {
763
+ result = onFormatError;
764
+ }
765
+ else if (formatErrorType === 'function') {
766
+ result = onFormatError(errorMessage, props);
767
+ }
768
+ else {
769
+ result = DEFAULT_FORMAT_ERROR;
770
+ }
771
+ // wrap error message, so it's detectable
772
+ result = wrap(result);
662
773
  }
663
774
  return result;
664
775
  }
@@ -672,22 +783,14 @@
672
783
  }
673
784
  return params.translation;
674
785
  };
675
- function prepare() {
676
- prepared = true;
677
- while (onPrepareQueue.length) {
678
- const queue = onPrepareQueue;
679
- onPrepareQueue = [];
680
- queue.forEach((callback) => callback());
681
- }
682
- }
683
786
  return Object.freeze({
684
- prepare,
685
787
  addPlugin,
686
788
  formatTranslation,
687
789
  getDevBackend,
688
790
  getBackendRecord,
689
791
  getBackendDevRecord,
690
792
  getLanguageDetector,
793
+ getLanguageStorage,
691
794
  getInitialLanguage,
692
795
  setStoredLanguage,
693
796
  run,
@@ -718,48 +821,6 @@
718
821
  });
719
822
  };
720
823
 
721
- const defaultObserverOptions = {
722
- tagAttributes: {
723
- textarea: ['placeholder'],
724
- input: ['value', 'placeholder'],
725
- img: ['alt'],
726
- '*': ['aria-label', 'title'],
727
- },
728
- restrictedElements: ['script', 'style'],
729
- highlightKeys: ['Alt'],
730
- highlightColor: 'rgb(255, 0, 0)',
731
- highlightWidth: 5,
732
- inputPrefix: '%-%tolgee:',
733
- inputSuffix: '%-%',
734
- passToParent: ['option', 'optgroup'],
735
- };
736
-
737
- const defaultValues = {
738
- defaultNs: '',
739
- observerOptions: defaultObserverOptions,
740
- observerType: 'invisible',
741
- };
742
- const combineOptions = (...states) => {
743
- let result = {};
744
- states.forEach((state) => {
745
- result = Object.assign(Object.assign(Object.assign({}, result), state), { observerOptions: Object.assign(Object.assign({}, result.observerOptions), state === null || state === void 0 ? void 0 : state.observerOptions) });
746
- });
747
- return result;
748
- };
749
- const initState = (options, previousState) => {
750
- const initialOptions = combineOptions(defaultValues, previousState === null || previousState === void 0 ? void 0 : previousState.initialOptions, options);
751
- // remove extra '/' from url end
752
- initialOptions.apiUrl = sanitizeUrl(initialOptions.apiUrl);
753
- return {
754
- initialOptions,
755
- activeNamespaces: (previousState === null || previousState === void 0 ? void 0 : previousState.activeNamespaces) || new Map(),
756
- language: previousState === null || previousState === void 0 ? void 0 : previousState.language,
757
- pendingLanguage: previousState === null || previousState === void 0 ? void 0 : previousState.language,
758
- isInitialLoading: false,
759
- isRunning: false,
760
- };
761
- };
762
-
763
824
  const State = (onLanguageChange, onPendingLanguageChange, onRunningChange) => {
764
825
  let state = initState();
765
826
  let devCredentials = undefined;
@@ -897,33 +958,6 @@
897
958
  });
898
959
  };
899
960
 
900
- /******************************************************************************
901
- Copyright (c) Microsoft Corporation.
902
-
903
- Permission to use, copy, modify, and/or distribute this software for any
904
- purpose with or without fee is hereby granted.
905
-
906
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
907
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
908
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
909
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
910
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
911
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
912
- PERFORMANCE OF THIS SOFTWARE.
913
- ***************************************************************************** */
914
-
915
- function __rest(s, e) {
916
- var t = {};
917
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
918
- t[p] = s[p];
919
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
920
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
921
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
922
- t[p[i]] = s[p[i]];
923
- }
924
- return t;
925
- }
926
-
927
961
  function parseCombinedOptions(_a) {
928
962
  var { ns, noWrap, orEmpty, params } = _a, rest = __rest(_a, ["ns", "noWrap", "orEmpty", "params"]);
929
963
  const options = {
@@ -1121,15 +1155,15 @@
1121
1155
  return cache.loadRecords(descriptors, isDev());
1122
1156
  }
1123
1157
  const checkCorrectConfiguration = () => {
1124
- const languageDetector = pluginService.getLanguageDetector();
1125
- if (languageDetector) {
1158
+ const languageComputable = pluginService.getLanguageDetector() || pluginService.getLanguageStorage();
1159
+ if (languageComputable) {
1126
1160
  const availableLanguages = state.getAvailableLanguages();
1127
1161
  if (!availableLanguages) {
1128
1162
  throw new Error(missingOptionError('availableLanguages'));
1129
1163
  }
1130
1164
  }
1131
1165
  if (!state.getLanguage() && !state.getInitialOptions().defaultLanguage) {
1132
- if (languageDetector) {
1166
+ if (languageComputable) {
1133
1167
  throw new Error(missingOptionError('defaultLanguage'));
1134
1168
  }
1135
1169
  else {
@@ -1145,7 +1179,7 @@
1145
1179
  cache.invalidate();
1146
1180
  }
1147
1181
  state.setRunning(true);
1148
- pluginService.run(isDev());
1182
+ pluginService.run();
1149
1183
  result = loadInitial();
1150
1184
  }
1151
1185
  return Promise.resolve(result);
@@ -1207,6 +1241,10 @@
1207
1241
  * ```
1208
1242
  */
1209
1243
  onNsUpdate: controller.onUpdate.listenSome,
1244
+ /**
1245
+ * Turn off/on events emitting. Is on by default.
1246
+ */
1247
+ setEmmiterActive: controller.setEmmiterActive,
1210
1248
  /**
1211
1249
  * @return current language if set.
1212
1250
  */
@@ -1321,13 +1359,17 @@
1321
1359
  */
1322
1360
  unwrap: controller.unwrap,
1323
1361
  /**
1324
- * Override creadentials passed on initialization
1362
+ * Override creadentials passed on initialization.
1363
+ *
1364
+ * When called in running state, tolgee stops and runs again.
1325
1365
  */
1326
1366
  overrideCredentials(credentials) {
1327
1367
  withRestart(() => controller.overrideCredentials(credentials));
1328
1368
  },
1329
1369
  /**
1330
- * Add tolgee plugin.
1370
+ * Add tolgee plugin after initialization.
1371
+ *
1372
+ * When called in running state, tolgee stops and runs again.
1331
1373
  */
1332
1374
  addPlugin(plugin) {
1333
1375
  if (plugin) {
@@ -1356,7 +1398,7 @@
1356
1398
  * const tolgee = Tolgee().use(...).init(...)
1357
1399
  * ```
1358
1400
  */
1359
- const Tolgee = () => {
1401
+ const TolgeeCore = () => {
1360
1402
  const state = {
1361
1403
  plugins: [],
1362
1404
  options: {},
@@ -1534,7 +1576,7 @@
1534
1576
  };
1535
1577
 
1536
1578
  exports.FormatSimple = FormatSimple;
1537
- exports.Tolgee = Tolgee;
1579
+ exports.TolgeeCore = TolgeeCore;
1538
1580
  exports.getFallback = getFallback;
1539
1581
  exports.getFallbackArray = getFallbackArray;
1540
1582
  exports.getTranslateProps = getTranslateProps;