lecom-ui 4.0.1 → 4.0.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.
Files changed (2) hide show
  1. package/dist/i18n/index.js +47 -23
  2. package/package.json +1 -1
@@ -20,31 +20,55 @@ const i18nConfig = {
20
20
  }
21
21
  };
22
22
  const initializeI18n = (options) => {
23
- const { resources, lng } = options || {};
24
- const mappedResources = {
25
- resources: {
26
- ["pt_BR" /* PT_BR */]: {
27
- translations: {
28
- ...translations["pt_BR" /* PT_BR */].translations,
29
- ...resources?.["pt_BR" /* PT_BR */]?.translations ?? {}
30
- }
31
- },
32
- ["en_US" /* EN_US */]: {
33
- translations: {
34
- ...translations["en_US" /* EN_US */].translations,
35
- ...resources?.["en_US" /* EN_US */]?.translations ?? {}
36
- }
37
- },
38
- ["es_ES" /* ES_ES */]: {
39
- translations: {
40
- ...translations["es_ES" /* ES_ES */].translations,
41
- ...resources?.["es_ES" /* ES_ES */]?.translations ?? {}
23
+ const { resources, lng } = options || {
24
+ lng: "pt_BR" /* PT_BR */
25
+ };
26
+ if (!i18n.isInitialized) {
27
+ console.log("i18n.isInitialized if", i18n.isInitialized);
28
+ const mappedResources = {
29
+ resources: {
30
+ ["pt_BR" /* PT_BR */]: {
31
+ translations: {
32
+ ...translations["pt_BR" /* PT_BR */].translations,
33
+ ...resources?.["pt_BR" /* PT_BR */]?.translations ?? {}
34
+ }
35
+ },
36
+ ["en_US" /* EN_US */]: {
37
+ translations: {
38
+ ...translations["en_US" /* EN_US */].translations,
39
+ ...resources?.["en_US" /* EN_US */]?.translations ?? {}
40
+ }
41
+ },
42
+ ["es_ES" /* ES_ES */]: {
43
+ translations: {
44
+ ...translations["es_ES" /* ES_ES */].translations,
45
+ ...resources?.["es_ES" /* ES_ES */]?.translations ?? {}
46
+ }
42
47
  }
43
48
  }
44
- }
45
- };
46
- console.log("i18n.isInitialized", i18n.isInitialized);
47
- i18n.use(initReactI18next).init({ ...i18nConfig, ...mappedResources, lng });
49
+ };
50
+ i18n.use(initReactI18next).init({
51
+ ...i18nConfig,
52
+ ...mappedResources,
53
+ lng
54
+ });
55
+ } else {
56
+ console.log("i18n.isInitialized else", i18n.isInitialized);
57
+ const languages = [
58
+ "pt_BR" /* PT_BR */,
59
+ "en_US" /* EN_US */,
60
+ "es_ES" /* ES_ES */
61
+ ];
62
+ languages.forEach((language) => {
63
+ i18n.addResourceBundle(
64
+ language,
65
+ "translations",
66
+ resources?.[language]?.translations ?? {},
67
+ true,
68
+ true
69
+ );
70
+ });
71
+ }
48
72
  };
49
73
 
50
74
  export { Translations, initializeI18n };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lecom-ui",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",