Fix custom 404 translations

This commit is contained in:
MartinBraquet
2026-03-07 09:55:13 +01:00
parent 2ea34189a8
commit cc74945371
4 changed files with 17 additions and 6 deletions

View File

@@ -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",

View File

@@ -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": "Cest 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",

View File

@@ -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}) {
<Col className="mx-4">
<Title>{t('404.title', '404: Oops!')}</Title>
{customText ? (
<p>{customText}</p>
<p>
{t(
`custom404.${customText}`,
NOT_FOUND_TEXTS[customText as keyof typeof NOT_FOUND_TEXTS] ?? customText,
)}
</p>
) : (
<p>{t('404.default_message', "I can't find that page.")}</p>
)}

View File

@@ -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) {
<PageBase trackPageView={'user page'} className={'relative p-2 sm:pt-0'}>
<Col className="items-center justify-center h-full">
<div className="text-xl font-semibold text-center mt-8">
{t('userpage.profileNotFound', 'Profile not found')}
{t('custom404.profileNotFound', 'Profile not found.')}
</div>
</Col>
</PageBase>