From c43a21adc6c74e366921485a2b86e65c86f0b6ff Mon Sep 17 00:00:00 2001 From: Esteban Date: Sat, 14 Feb 2026 22:48:23 -0500 Subject: [PATCH] added locale json to do fix utls --- src/components/HeroHome.astro | 7 ++++++- src/data/locales/en.json | 5 +++++ src/data/locales/es.json | 5 +++++ src/data/locales/fr.json | 5 +++++ src/data/locales/he.json | 5 +++++ src/utils/i18n.js | 13 +++++++++++++ 6 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/data/locales/en.json create mode 100644 src/data/locales/es.json create mode 100644 src/data/locales/fr.json create mode 100644 src/data/locales/he.json create mode 100644 src/utils/i18n.js diff --git a/src/components/HeroHome.astro b/src/components/HeroHome.astro index e30d69f..a14d9f5 100644 --- a/src/components/HeroHome.astro +++ b/src/components/HeroHome.astro @@ -1,6 +1,11 @@ --- import Header from './Header.astro'; import { Icon } from 'astro-icon/components'; +import { useTranslations } from '../utils/i18n'; + +// Set the language for translations +const lang = 'es'; +const t = useTranslations(lang); ---
@@ -22,7 +27,7 @@ import { Icon } from 'astro-icon/components';
-
LÍDER FUNDADOR
+
{t("hero_section.lider")}
diff --git a/src/data/locales/en.json b/src/data/locales/en.json new file mode 100644 index 0000000..e038793 --- /dev/null +++ b/src/data/locales/en.json @@ -0,0 +1,5 @@ +{ + "hero_section": { + "lider": "LÍDER FUNDADOR" + } +} \ No newline at end of file diff --git a/src/data/locales/es.json b/src/data/locales/es.json new file mode 100644 index 0000000..e038793 --- /dev/null +++ b/src/data/locales/es.json @@ -0,0 +1,5 @@ +{ + "hero_section": { + "lider": "LÍDER FUNDADOR" + } +} \ No newline at end of file diff --git a/src/data/locales/fr.json b/src/data/locales/fr.json new file mode 100644 index 0000000..e038793 --- /dev/null +++ b/src/data/locales/fr.json @@ -0,0 +1,5 @@ +{ + "hero_section": { + "lider": "LÍDER FUNDADOR" + } +} \ No newline at end of file diff --git a/src/data/locales/he.json b/src/data/locales/he.json new file mode 100644 index 0000000..f422d40 --- /dev/null +++ b/src/data/locales/he.json @@ -0,0 +1,5 @@ +{ + "hero_section": { + "lider": "מנהיג מייסד" + } +} \ No newline at end of file diff --git a/src/utils/i18n.js b/src/utils/i18n.js new file mode 100644 index 0000000..98a84ed --- /dev/null +++ b/src/utils/i18n.js @@ -0,0 +1,13 @@ +import es from '../data/locales/es.json'; +import en from '../data/locales/en.json'; +import he from '../data/locales/he.json'; +import fr from '../data/locales/fr.json'; + +const languages = { es, en, he, fr }; + +export function useTranslations(lang) { + return function t(key) { + // return the translation for the given key in the specified language, or fall back to Spanish if the key is not found + return languages[lang][key] || languages['es'][key]; + }; +} \ No newline at end of file