diff --git a/src/i18n/ui/en.json b/src/i18n/ui/en.json index 0347fe4ad1..f8d50c91b8 100644 --- a/src/i18n/ui/en.json +++ b/src/i18n/ui/en.json @@ -183,7 +183,8 @@ "description": "The page you are looking for could not be found.", "heading": "Page Not Found", "message": "The page you are looking for does not exist or has been moved.", - "goHome": "Go to Home" + "goHome": "Go to Home", + "reportIssue": "Report an issue" }, "common": { "download": "Download" diff --git a/src/pages/404.astro b/src/pages/404.astro index 3b472c4bec..24c2884c78 100644 --- a/src/pages/404.astro +++ b/src/pages/404.astro @@ -2,28 +2,75 @@ import Layout from '@/layouts/Layout.astro'; import { Icon } from 'astro-icon/components'; import { Container, H1, H2, Body, Button, Flex } from '@components/primitives'; +import { defaultLang, languageCodes, languages, type LanguageCode } from '@/i18n/locales'; +import { getHomePath, useTranslations } from '@/i18n/utils'; + +// The host serves this single `404.html` for every missing URL, whatever its +// language, so the page can't be localized at build time. It is rendered in +// English, and the inline script below switches it to the language of the +// requested URL (e.g. `/de/…`) using the strings collected here. +const translations = Object.fromEntries( + (languageCodes as LanguageCode[]).map((lang) => { + const t = useTranslations(lang); + return [ + lang, + { + direction: languages[lang].direction, + title: t('error404.title'), + heading: t('error404.heading'), + message: t('error404.message'), + goHome: t('error404.goHome'), + reportIssue: t('error404.reportIssue'), + homePath: getHomePath(lang), + }, + ]; + }) +); +const strings = translations[defaultLang]; +const description = useTranslations(defaultLang)('error404.description'); --- - +

404

-

Page Not Found

- The page you are looking for does not exist or has been moved. +

{strings.heading}

+ + {strings.message} + -
+