From 76932dfe3a0b747bde1d2a1bb4eea7ac39a3656f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 21 May 2026 21:30:19 +0200 Subject: [PATCH] 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. --- messages/de.json | 7 +++++++ messages/en.json | 7 +++++++ messages/es.json | 7 +++++++ messages/fr.json | 7 +++++++ messages/it.json | 7 +++++++ messages/pl.json | 7 +++++++ src/app/not-found.tsx | 18 +++++++++++++----- 7 files changed, 55 insertions(+), 5 deletions(-) diff --git a/messages/de.json b/messages/de.json index 71214dc44..2ba830c05 100644 --- a/messages/de.json +++ b/messages/de.json @@ -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", diff --git a/messages/en.json b/messages/en.json index b07f3d193..1032b65d4 100644 --- a/messages/en.json +++ b/messages/en.json @@ -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", diff --git a/messages/es.json b/messages/es.json index a4b42fd9f..56a1ad844 100644 --- a/messages/es.json +++ b/messages/es.json @@ -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", diff --git a/messages/fr.json b/messages/fr.json index ea3dfcf96..bde36a015 100644 --- a/messages/fr.json +++ b/messages/fr.json @@ -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", diff --git a/messages/it.json b/messages/it.json index a026bb38c..3f2201b77 100644 --- a/messages/it.json +++ b/messages/it.json @@ -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", diff --git a/messages/pl.json b/messages/pl.json index 4d36e8d6e..9a4c2827e 100644 --- a/messages/pl.json +++ b/messages/pl.json @@ -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", diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index 8138b0d63..efb4f6c97 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -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 (

- Page not found + {t("errors.notFound.title")}

- 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. + {t("errors.notFound.body")}

- Back to dashboard + {t("errors.notFound.backToDashboard")}
);