diff --git a/src/components/Header.astro b/src/components/Header.astro index b300f1d..12e91d6 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -3,6 +3,7 @@ interface Props {} import { useTranslations } from "../i18n/utils"; import type { Params } from "../i18n/utils"; +import { languages } from "../i18n/ui"; import { Image } from "astro:assets"; import aux from "../../public/aux.svg"; @@ -33,6 +34,27 @@ const translation = useTranslations(lang); >
  • GitHub
  • + + + + diff --git a/src/i18n/utils.ts b/src/i18n/utils.ts index d10e23e..1f4fc3e 100644 --- a/src/i18n/utils.ts +++ b/src/i18n/utils.ts @@ -11,6 +11,12 @@ export function useTranslations(lang: keyof typeof ui) { }; } +export function switchLang(lang: keyof typeof ui) { + const parts = location.pathname.split("/"); + parts[1] = lang; + location.href = parts.join("/"); +} + export const getStaticPaths = (async () => { return Object.keys(languages).map((name) => ({ params: { lang: name as keyof typeof languages },