From cc74945371e33a74ed28cda894692777fcb73bc8 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Sat, 7 Mar 2026 09:55:13 +0100 Subject: [PATCH] Fix custom 404 translations --- common/messages/de.json | 2 +- common/messages/fr.json | 2 +- web/pages/404.tsx | 11 ++++++++++- web/pages/[username]/index.tsx | 8 +++++--- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/common/messages/de.json b/common/messages/de.json index cae78495..720dacc7 100644 --- a/common/messages/de.json +++ b/common/messages/de.json @@ -1268,7 +1268,7 @@ "profile.connect.tips": "- Wählen Sie den Verbindungstyp, für den Sie offen sind.\n- Sie sehen dies nicht, es sei denn, sie wählen denselben Typ wie Sie.\n- Wenn Sie beide denselben Typ wählen, werden Sie beide benachrichtigt.", "notifications.connection.mutual_title": "Es ist gegenseitig 🎉", "notifications.connection.mutual_body": "Du und {name} sind beide an einem {type} interessiert. Beginnen Sie das Gespräch.", - "userpage.profileNotFound": "Profil nicht gefunden", + "custom404.profileNotFound": "Profil nicht gefunden", "share_profile.on_x": "Auf X teilen", "share_profile.on_linkedin": "Auf LinkedIn teilen", "share_profile.view_profile_card": "Profilkarte ansehen", diff --git a/common/messages/fr.json b/common/messages/fr.json index b8204056..32261fbb 100644 --- a/common/messages/fr.json +++ b/common/messages/fr.json @@ -1267,7 +1267,7 @@ "profile.connect.tips": "- Vous choisissez le type de relation auquel vous êtes ouvert.\n- Ils ne verront pas ceci à moins qu'ils ne choisissent le même type que vous.\n- Si vous choisissez tous les deux le même type de relation, vous serez tous les deux notifiés.", "notifications.connection.mutual_title": "C’est mutuel 🎉", "notifications.connection.mutual_body": "{name} et vous êtes tous deux intéressés par un(e) {type}. Commencez la conversation.", - "userpage.profileNotFound": "Profil introuvable", + "custom404.profileNotFound": "Profil introuvable.", "share_profile.on_x": "Partager sur X", "share_profile.on_linkedin": "Partager sur LinkedIn", "share_profile.view_profile_card": "Voir la carte de profil", diff --git a/web/pages/404.tsx b/web/pages/404.tsx index 5fd1e7a6..5126debd 100644 --- a/web/pages/404.tsx +++ b/web/pages/404.tsx @@ -5,6 +5,10 @@ import {SEO} from 'web/components/SEO' import {Title} from 'web/components/widgets/title' import {useT} from 'web/lib/locale' +export const NOT_FOUND_TEXTS = { + profileNotFound: 'Profile not found.', +} as const + export default function Custom404(props: {customText?: string}) { // console.log('props:', props) return ( @@ -24,7 +28,12 @@ export function Custom404Content(props: {customText?: string}) { {t('404.title', '404: Oops!')} {customText ? ( -

{customText}

+

+ {t( + `custom404.${customText}`, + NOT_FOUND_TEXTS[customText as keyof typeof NOT_FOUND_TEXTS] ?? customText, + )} +

) : (

{t('404.default_message', "I can't find that page.")}

)} diff --git a/web/pages/[username]/index.tsx b/web/pages/[username]/index.tsx index 2a29d723..9a6411c3 100644 --- a/web/pages/[username]/index.tsx +++ b/web/pages/[username]/index.tsx @@ -65,6 +65,7 @@ export const getStaticProps = async ( return { props: { notFoundCustomText: null, + username, }, revalidate: 1, } @@ -96,6 +97,7 @@ export const getStaticProps = async ( return { props: { notFoundCustomText: null, + username, }, revalidate: 1, } @@ -132,7 +134,7 @@ export default function UserPage(props: UserPageProps) { const nativeMobile = isNativeMobile() const router = useRouter() const t = useT() - const username = (nativeMobile ? router.query.username : props.username) as string + const username = (props.username ?? router.query.username) as string const fromSignup = router?.query?.fromSignup === 'true' // Hydrate from localStorage if coming from registration, @@ -188,7 +190,7 @@ export default function UserPage(props: UserPageProps) { // All fallbacks exhausted setFetchedProps({ ...props, - notFoundCustomText: t('userpage.profileNotFound', 'Profile not found.'), + notFoundCustomText: 'profileNotFound', }) setLoading(false) return @@ -257,7 +259,7 @@ export default function UserPage(props: UserPageProps) {
- {t('userpage.profileNotFound', 'Profile not found')} + {t('custom404.profileNotFound', 'Profile not found.')}