From 373a4af4b1837b5e125401ad2f98daada0708306 Mon Sep 17 00:00:00 2001 From: juancmandev Date: Wed, 31 Jul 2024 13:41:41 -0600 Subject: [PATCH] config i18n --- src/components/footer.tsx | 9 +- src/components/header.astro | 4 +- src/components/navigation.tsx | 106 ++++++++++----------- src/content/pages/about.mdx | 12 +-- src/content/pages/es/acerca-de.mdx | 22 +++++ src/content/pages/es/contacto.mdx | 36 +++++++ src/content/pages/es/recursos.mdx | 61 ++++++++++++ src/i18n/ui.ts | 16 ++++ src/i18n/utils.ts | 19 ++++ src/layouts/Layout.astro | 15 ++- src/pages/404.astro | 7 +- src/pages/[...slug].astro | 2 +- src/pages/blog/[...slug].astro | 2 +- src/pages/blog/index.astro | 2 +- src/pages/es/[...slug].astro | 28 ++++++ src/pages/es/feed.xml.ts | 129 ++++++++++++++++++++++++++ src/pages/es/index.astro | 6 +- src/pages/es/videos/[...slug].astro | 6 +- src/pages/es/videos/index.astro | 2 +- src/pages/{rss.xml.ts => feed.xml.ts} | 2 +- src/pages/index.astro | 1 - src/pages/microblog.astro | 1 - src/pages/portfolio/[...slug].astro | 6 +- src/pages/portfolio/index.astro | 2 +- 24 files changed, 400 insertions(+), 96 deletions(-) create mode 100644 src/content/pages/es/acerca-de.mdx create mode 100644 src/content/pages/es/contacto.mdx create mode 100644 src/content/pages/es/recursos.mdx create mode 100644 src/i18n/ui.ts create mode 100644 src/i18n/utils.ts create mode 100644 src/pages/es/[...slug].astro create mode 100644 src/pages/es/feed.xml.ts rename src/pages/{rss.xml.ts => feed.xml.ts} (97%) diff --git a/src/components/footer.tsx b/src/components/footer.tsx index 5e82f0e..6f0e1ca 100644 --- a/src/components/footer.tsx +++ b/src/components/footer.tsx @@ -47,7 +47,14 @@ export default function Footer(props: Props) { variant="link" className="flex flex-col justify-center" > - + RSS feed diff --git a/src/components/header.astro b/src/components/header.astro index c1624ac..e8447b9 100644 --- a/src/components/header.astro +++ b/src/components/header.astro @@ -21,7 +21,7 @@ const locales = { top: "Arriba", navigation: "Navevación", }, -} as const; +}; const { lang } = Astro.props; --- @@ -34,7 +34,7 @@ const { lang } = Astro.props; >
- - Blog - - ), + type: "blog", + icon: , + }, + { type: "portfolio", icon: }, + { + type: "videos", + icon: , }, { - to: "/portfolio", - child: ( - <> - - Portfolio - - ), + type: "microblog", + icon: , }, { - to: "es/videos", - child: ( - <> - - Videos - - ), + type: "resources", + icon: , }, { - to: "/microblog", - child: ( - <> - - Microblog - - ), + type: "about", + icon: , }, { - to: "/resources", - child: ( - <> - - Resources - - ), - }, - { - to: "/about", - child: ( - <> - - About - - ), - }, - { - to: "/contact", - child: ( - <> - - Contact - - ), + type: "contact", + icon: , }, ]; @@ -84,19 +47,46 @@ type Props = { lang: "en" | "es"; }; +const locales = { + en: { + navigation: "Navigation", + blog: { label: "Blog", to: "/blog" }, + portfolio: { label: "Portfolio", to: "/portfolio" }, + videos: { label: "Videos", to: "/es/videos" }, + microblog: { label: "Microblog", to: "/microblog" }, + resources: { label: "Resources", to: "/resources" }, + about: { label: "About", to: "/about" }, + contact: { label: "Contact", to: "/contact" }, + }, + es: { + navigation: "Navegación", + blog: { label: "Blog", to: "/es/blog" }, + portfolio: { label: "Portfolio", to: "/es/portfolio" }, + videos: { label: "Videos", to: "/es/videos" }, + microblog: { label: "Microblog", to: "/microblog" }, + resources: { label: "Recursos", to: "/es/recursos" }, + about: { label: "Acerca de", to: "/es/acerca-de" }, + contact: { label: "Contacto", to: "/es/contacto" }, + }, +} as const; + export default function Navigation(props: Props) { + const t = useTranslations(props.lang); + const translatePath = useTranslatedPath(props.lang); + return (