diff --git a/gatsby-browser.js b/gatsby-browser.js
new file mode 100644
index 0000000..0e4e9c8
--- /dev/null
+++ b/gatsby-browser.js
@@ -0,0 +1,10 @@
+import React from 'react';
+import LanguageProvider from './src/context/LanguageContext';
+
+export const wrapRootElement = ({ element }) => {
+ return (
+
+ {element}
+
+ );
+};
\ No newline at end of file
diff --git a/gatsby-ssr.js b/gatsby-ssr.js
index 7baf090..c9ce0aa 100644
--- a/gatsby-ssr.js
+++ b/gatsby-ssr.js
@@ -1,7 +1,8 @@
import React from "react";
+import LanguageProvider from './src/context/LanguageContext';
const HtmlAttributes = {
- lang: "en"
+ lang: "es"
}
const HeadComponents = [
@@ -28,3 +29,11 @@ export const onRenderBody = ({ setHeadComponents, setHtmlAttributes }) => {
setHtmlAttributes(HtmlAttributes);
setHeadComponents(HeadComponents);
}
+
+export const wrapRootElement = ({ element }) => {
+ return (
+
+ {element}
+
+ );
+}
diff --git a/src/components/IntlProviderWrapper.jsx b/src/components/IntlProviderWrapper.jsx
new file mode 100644
index 0000000..fdab298
--- /dev/null
+++ b/src/components/IntlProviderWrapper.jsx
@@ -0,0 +1,12 @@
+import React from 'react';
+import LanguageProvider from '../../../context/LanguageContext';
+
+const IntlProviderWrapper = ({ children }) => {
+ return (
+
+ {children}
+
+ );
+};
+
+export default IntlProviderWrapper;
\ No newline at end of file
diff --git a/src/components/Navbars/LanguageSelector/LanguageSwitcher.jsx b/src/components/Navbars/LanguageSelector/LanguageSwitcher.jsx
index 15fd732..623b491 100644
--- a/src/components/Navbars/LanguageSelector/LanguageSwitcher.jsx
+++ b/src/components/Navbars/LanguageSelector/LanguageSwitcher.jsx
@@ -1,52 +1,29 @@
-import React, { useEffect, useState } from 'react';
-import { IntlProvider, useIntl } from 'gatsby-plugin-intl';
-import { navigate } from 'gatsby';
+import React, { useContext } from 'react';
+import { LanguageContext } from '../../../context/LanguageContext';
const LanguageSwitcher = () => {
- const [messages, setMessages] = useState({});
- const [languages, setLanguages] = useState([]);
- const intl = useIntl();
- const currentLanguage = intl.locale;
+ const { languages, currentLanguage, changeLanguage } = useContext(LanguageContext);
- useEffect(() => {
- const fetchMessages = async () => {
- try {
- const response = await fetch('/data/language/languages.json');
- const data = await response.json();
- setMessages(data);
- setLanguages(Object.keys(data));
- } catch (error) {
- console.error('Error fetching texts:', error);
- }
- };
-
- fetchMessages();
- }, []);
-
- const handleLanguageChange = (newLanguage) => {
- const path = window.location.pathname;
- const newPath = `/${newLanguage}${path.substring(3)}`;
- navigate(newPath);
- };
+ if (!languages || languages.length === 0) {
+ return
Loading...
;
+ }
return (
-
-
+
+
+ {languages.map((lang) => (
+
-
- {languages.map((lang) => (
-
- ))}
-
-
-
+ ))}
+
+
);
};
diff --git a/src/components/Software/About.jsx b/src/components/Software/About.jsx
index 3cc0b9d..eeb9769 100644
--- a/src/components/Software/About.jsx
+++ b/src/components/Software/About.jsx
@@ -35,7 +35,7 @@ const About = () => {
{ number.value }
- { number.title }
+ {intl.locale === 'en' ? number.title2 : number.title }
))
@@ -78,7 +78,7 @@ const About = () => {
{
- dataAbout.features.map((feature, index) => (- { feature }
))
+ dataAbout.features.map((feature, index) => (- {intl.locale === 'en' ? feature.titleEn : feature.titleEs}
))
}
diff --git a/src/components/Software/Blog.jsx b/src/components/Software/Blog.jsx
index e316604..733f8c0 100644
--- a/src/components/Software/Blog.jsx
+++ b/src/components/Software/Blog.jsx
@@ -7,9 +7,9 @@ import api from '../../common/api';
const Blog = () => {
const intl = useIntl();
- const blog_title1= DOMPurify.sanitize(intl.formatMessage({ id: "blog_title1" }).trim().replace(/^"|"$/g, ''));
-
- const [dataBlog, setBlogs] = useState({blogs: [], faq: [],clients: []});
+ //const blog_title1= DOMPurify.sanitize(intl.formatMessage({ id: "blog_title1" }).trim().replace(/^"|"$/g, ''));
+ const [dataBlog, setBlogs] = useState({blogs: [], faq: [],clients: [],text_traductions:[]});
+ const blog_titleResult = intl.locale === 'es' ? dataBlog.text_traductions.blog_title1_es : dataBlog.text_traductions.en.blog_title1_en;
useEffect(() => {
const fetchData = async () => {
@@ -30,8 +30,8 @@ const Blog = () => {
-
-
{intl.formatMessage({ id: "all_articles" })}
+
+
{intl.locale === 'es' ? dataBlog.text_traductions.all_articles_es : dataBlog.text_traductions.all_articles_en}
{
dataBlog.blogs.map((post, i) => (
@@ -45,18 +45,18 @@ const Blog = () => {
- { post.type }
+ { intl.locale === 'es' ? post.type.es : post.type.en }
- { post.time }
+ { intl.locale === 'es' ? post.time_es : post.time_en }
-
{ post.title }
+
{ intl.locale === 'es' ? post.title_es : post.title_en }
@@ -97,7 +97,7 @@ const Blog = () => {
))
}
- See More
+ {intl.locale === 'es' ? dataBlog.text_traductions.see_more_es : dataBlog.text_traductions.see_more_en}
diff --git a/src/components/Software/Header.jsx b/src/components/Software/Header.jsx
index 0c456e7..075f3e3 100644
--- a/src/components/Software/Header.jsx
+++ b/src/components/Software/Header.jsx
@@ -1,39 +1,55 @@
-import React from 'react';
-import DOMPurify from 'dompurify';
+import React, { useEffect, useState } from 'react';
import { useIntl } from "gatsby-plugin-intl";
+import api from '../../common/api';
const Header = () => {
const intl = useIntl();
- const header_1= DOMPurify.sanitize(intl.formatMessage({ id: "header_1" }).trim().replace(/^"|"$/g, ''));
-
+ const [headers, setHeaders] = useState({es:[], en:[]});
+ //const header_1= DOMPurify.sanitize(intl.formatMessage({ id: "header_1" }).trim().replace(/^"|"$/g, ''));
+ const header_1Result = intl.locale === 'es' ? headers.es.header_1 : headers.en.header_1
+
+ useEffect(() => {
+ const fetchData = async () => {
+ try {
+ const response = await api.get('headers', 'header.json');
+ setHeaders(response);
+ } catch (error) {
+ console.error(error);
+ }
+ };
+
+ fetchData();
+ }, []);
+
return (
+
-
-
{intl.formatMessage({ id: "header_2" })}
-
{intl.formatMessage({ id: "get_free_quotes" })} {intl.formatMessage({ id: "header_3" })}
+
+
+
{intl.locale === 'es' ? headers.es.header_2 : headers.en.header_2}{intl.locale === 'es' ? headers.es.header_3 : headers.en.header_3}