lecom-ui 4.0.2 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
- import { I18nextProvider } from 'react-i18next';
3
- import i18n from 'i18next';
2
+ import { initializeI18n } from '../../i18n/index.js';
4
3
  import { getCookie } from '../../utils/cookie.js';
5
4
  import '../CustomIcon/Icons/CadastroFacil.js';
6
5
  import '../CustomIcon/Icons/LogoLecom.js';
@@ -11,10 +10,11 @@ import { Header } from '../Header/Header.js';
11
10
  import { SidebarProvider, Sidebar, SidebarContent, SidebarGroup, SidebarGroupContent, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarFooter } from '../Sidebar/Sidebar.js';
12
11
  import { Typography } from '../Typography/Typography.js';
13
12
 
13
+ initializeI18n();
14
14
  const Layout = ({ children, header, sideBar }) => {
15
15
  const { items, info } = sideBar;
16
16
  const sidebarState = getCookie("sidebar:state") === "true";
17
- return /* @__PURE__ */ React.createElement(SidebarProvider, { className: "flex-col", defaultOpen: sidebarState }, /* @__PURE__ */ React.createElement(I18nextProvider, { i18n }, /* @__PURE__ */ React.createElement(Header, { ...header })), /* @__PURE__ */ React.createElement("div", { className: "flex grow" }, /* @__PURE__ */ React.createElement(Sidebar, { collapsible: "icon", variant: "sidebar" }, /* @__PURE__ */ React.createElement(SidebarContent, null, /* @__PURE__ */ React.createElement(SidebarGroup, null, /* @__PURE__ */ React.createElement(SidebarGroupContent, null, /* @__PURE__ */ React.createElement(SidebarMenu, null, items.map((item) => /* @__PURE__ */ React.createElement(SidebarMenuItem, { key: item.title }, /* @__PURE__ */ React.createElement(
17
+ return /* @__PURE__ */ React.createElement(SidebarProvider, { className: "flex-col", defaultOpen: sidebarState }, /* @__PURE__ */ React.createElement(Header, { ...header }), /* @__PURE__ */ React.createElement("div", { className: "flex grow" }, /* @__PURE__ */ React.createElement(Sidebar, { collapsible: "icon", variant: "sidebar" }, /* @__PURE__ */ React.createElement(SidebarContent, null, /* @__PURE__ */ React.createElement(SidebarGroup, null, /* @__PURE__ */ React.createElement(SidebarGroupContent, null, /* @__PURE__ */ React.createElement(SidebarMenu, null, items.map((item) => /* @__PURE__ */ React.createElement(SidebarMenuItem, { key: item.title }, /* @__PURE__ */ React.createElement(
18
18
  SidebarMenuButton,
19
19
  {
20
20
  asChild: true,
@@ -20,34 +20,44 @@ 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 ?? {}
42
- }
43
- }
44
- }
23
+ const { resources, lng } = options || {
24
+ lng: "pt_BR" /* PT_BR */
45
25
  };
26
+ const languages = [
27
+ "pt_BR" /* PT_BR */,
28
+ "en_US" /* EN_US */,
29
+ "es_ES" /* ES_ES */
30
+ ];
46
31
  if (!i18n.isInitialized) {
47
- console.log("i18n.isInitialized if", i18n.isInitialized);
48
- i18n.use(initReactI18next).init({ ...i18nConfig, ...mappedResources, lng });
49
- } else {
50
- console.log("i18n.isInitialized else", i18n.isInitialized);
32
+ const mappedResources = {
33
+ resources: {}
34
+ };
35
+ languages.forEach((language) => {
36
+ mappedResources.resources = {
37
+ ...mappedResources.resources,
38
+ [language]: {
39
+ translations: {
40
+ ...translations[language].translations,
41
+ ...resources?.[language]?.translations ?? {}
42
+ }
43
+ }
44
+ };
45
+ });
46
+ i18n.use(initReactI18next).init({
47
+ ...i18nConfig,
48
+ ...mappedResources,
49
+ lng
50
+ });
51
+ } else if (resources) {
52
+ languages.forEach((language) => {
53
+ i18n.addResourceBundle(
54
+ language,
55
+ "translations",
56
+ resources?.[language]?.translations ?? {},
57
+ true,
58
+ true
59
+ );
60
+ });
51
61
  }
52
62
  };
53
63
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lecom-ui",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",