i18n(not-found): localize 404 page using server-resolved locale

The branded 404 splash hard-coded its three strings in English, ignoring the cookie/Accept-Language locale resolution the rest of the app uses. Switches to getServerTranslator + resolveServerLocale and adds an errors.notFound.{title,body,backToDashboard} block to every locale bundle.
This commit is contained in:
Marc-André Bombeck committed 2026-05-21 21:45:45 +02:00
1 parent 58f484ad08
commit 76932dfe3a
7 files changed
+55 -5

No files matched your search

+7
View File
@@ -152,6 +152,13 @@
"title": "Da ist etwas schiefgelaufen",
"description": "Ein unerwarteter Fehler ist aufgetreten. Du kannst es erneut versuchen, die technischen Details kopieren oder einen Bug-Report öffnen."
},
"errors": {
"notFound": {
"title": "Seite nicht gefunden",
"body": "Die gesuchte Seite existiert nicht oder wurde verschoben. Kehr zum Dashboard zurück, um dort weiterzumachen, wo du aufgehört hast.",
"backToDashboard": "Zurück zum Dashboard"
}
},
"nav": {
"dashboard": "Dashboard",
"measurements": "Messungen",
+7
View File
@@ -152,6 +152,13 @@
"title": "Something went wrong",
"description": "An unexpected error occurred. You can retry, copy the technical details, or open a bug report."
},
"errors": {
"notFound": {
"title": "Page not found",
"body": "The page you were looking for doesn't exist or has been moved. Head back to the dashboard to pick up where you left off.",
"backToDashboard": "Back to dashboard"
}
},
"nav": {
"dashboard": "Dashboard",
"measurements": "Measurements",
+7
View File
@@ -152,6 +152,13 @@
"title": "Algo ha salido mal",
"description": "Se ha producido un error inesperado. Puedes reintentar, copiar los detalles técnicos o abrir un reporte de bug."
},
"errors": {
"notFound": {
"title": "Página no encontrada",
"body": "La página que buscas no existe o se ha movido. Vuelve al panel para continuar donde lo dejaste.",
"backToDashboard": "Volver al panel"
}
},
"nav": {
"dashboard": "Panel",
"measurements": "Mediciones",
+7
View File
@@ -152,6 +152,13 @@
"title": "Une erreur est survenue",
"description": "Une erreur inattendue est survenue. Tu peux réessayer, copier les détails techniques ou ouvrir un rapport de bug."
},
"errors": {
"notFound": {
"title": "Page introuvable",
"body": "La page que tu cherches n’existe pas ou a été déplacée. Reviens au tableau de bord pour reprendre où tu en étais.",
"backToDashboard": "Retour au tableau de bord"
}
},
"nav": {
"dashboard": "Tableau de bord",
"measurements": "Mesures",
+7
View File
@@ -152,6 +152,13 @@
"title": "Qualcosa è andato storto",
"description": "Si è verificato un errore inatteso. Puoi riprovare, copiare i dettagli tecnici o aprire una segnalazione di bug."
},
"errors": {
"notFound": {
"title": "Pagina non trovata",
"body": "La pagina che cercavi non esiste o è stata spostata. Torna alla dashboard per riprendere da dove eri rimasto.",
"backToDashboard": "Torna alla dashboard"
}
},
"nav": {
"dashboard": "Dashboard",
"measurements": "Misurazioni",
+7
View File
@@ -152,6 +152,13 @@
"title": "Coś poszło nie tak",
"description": "Wystąpił nieoczekiwany błąd. Możesz spróbować ponownie, skopiować szczegóły techniczne lub otworzyć zgłoszenie błędu."
},
"errors": {
"notFound": {
"title": "Nie znaleziono strony",
"body": "Strona, której szukasz, nie istnieje lub została przeniesiona. Wróć do panelu, aby kontynuować od miejsca, w którym przerwałeś.",
"backToDashboard": "Powrót do panelu"
}
},
"nav": {
"dashboard": "Panel",
"measurements": "Pomiary",
+13 -5
View File
@@ -1,6 +1,8 @@
import Link from "next/link";
import { Logo } from "@/components/ui/logo";
import { resolveServerLocale } from "@/lib/i18n/server-locale";
import { getServerTranslator } from "@/lib/i18n/server-translator";
/**
* v1.4.27 MB6 — branded 404 page. Next.js mounts this file for any
@@ -11,12 +13,19 @@ import { Logo } from "@/components/ui/logo";
* application error and doesn't need the bug-report path. Just a
* branded splash with one link home.
*
* v1.4.43 H4 — the copy is locale-resolved server-side from the same
* cookie / Accept-Language path the rest of the app uses, so a German
* visitor no longer hits an English-only splash on a typo URL.
*
* Mobile-first: `min-h-dvh` follows the dynamic viewport so the
* panel anchors centred under iOS Safari's animated URL bar;
* `safe-area-inset-top` keeps the headline clear of the notch or
* Dynamic Island.
*/
export default function NotFound() {
export default async function NotFound() {
const locale = await resolveServerLocale();
const { t } = getServerTranslator(locale);
return (
<main
id="main-content"
@@ -30,18 +39,17 @@ export default function NotFound() {
404
</p>
<h1 className="text-2xl font-bold tracking-tight md:text-3xl">
Page not found
{t("errors.notFound.title")}
</h1>
<p className="text-muted-foreground text-sm leading-relaxed">
The page you were looking for doesn&apos;t exist or has been moved.
Head back to the dashboard to pick up where you left off.
{t("errors.notFound.body")}
</p>
</div>
<Link
href="/"
className="bg-primary text-primary-foreground hover:bg-primary/90 inline-flex min-h-11 items-center justify-center rounded-md px-5 text-sm font-medium transition-colors"
>
Back to dashboard
{t("errors.notFound.backToDashboard")}
</Link>
</main>
);