diff --git a/src/components/LangChange.astro b/src/components/LangChange.astro new file mode 100644 index 0000000..8f53834 --- /dev/null +++ b/src/components/LangChange.astro @@ -0,0 +1,11 @@ +--- +import {languages} from "../i18n/ui.ts"; + +const {lang} = Astro.params; +--- + +
+ {Object.keys(languages).map((code) => + code === lang ? "" : {code.toUpperCase()} + )} +
diff --git a/src/i18n/ui.ts b/src/i18n/ui.ts index 6845843..70d28aa 100644 --- a/src/i18n/ui.ts +++ b/src/i18n/ui.ts @@ -1,9 +1,10 @@ export const languages = { - en: 'English', - sk: 'Slovak', + en: "English", + sk: "Slovensky", + de: "Deutsch", }; -export const defaultLang = 'en'; +export const defaultLang = "en"; export const ui = { en: { @@ -186,4 +187,5 @@ export const ui = { "main.note.source.1": "tu", "main.note.source.2": "", }, + de: {}, } as const; diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 10fa103..96de256 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -8,6 +8,8 @@ import "../styles/global.css" + + Daniel's portfolio diff --git a/src/pages/[lang]/index.astro b/src/pages/[lang]/index.astro index b93f768..38dbcf2 100644 --- a/src/pages/[lang]/index.astro +++ b/src/pages/[lang]/index.astro @@ -2,6 +2,7 @@ import Layout from "../../layouts/Layout.astro"; import ArrowLink from "../../components/ArrowLink.astro" import {useTranslations} from "../../i18n/utils.ts"; +import LangChange from "../../components/LangChange.astro"; const now = new Date(); let years = now.getFullYear() - 2006 - 1; @@ -11,12 +12,13 @@ if (now.getMonth() > 7 || (now.getMonth() === 7 && now.getDate() >= 23)) { let a = years === 18 ? "an " : "a "; const {lang} = Astro.params; -const t = useTranslations(lang as "en" | "sk"); +const t = useTranslations(lang as "en" | "sk" | "de"); export function getStaticPaths() { return [ - {params: {lang: "en"}}, + {params: {lang: "en"},}, {params: {lang: "sk"},}, + {params: {lang: "de"},}, ]; } --- @@ -56,7 +58,9 @@ export function getStaticPaths() {
-
+
+ +

{t("main.note.accessibility")}

diff --git a/src/pages/index.astro b/src/pages/index.astro index 05365ff..813eb76 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,6 +1,8 @@ --- import Layout from "../layouts/Layout.astro"; import {defaultLang} from "../i18n/ui.ts"; + +// TODO: get language from Accept-Language header ---