From 3f47fc5e0e6f0b8747cae67188e8fcbeb60d5734 Mon Sep 17 00:00:00 2001 From: Parsa Aghayi Date: Mon, 2 Nov 2026 08:30:18 +0000 Subject: [PATCH] fix(404): read lang from searchParams for dynamic localization on 404 pages --- src/app/(routes)/(website)/[...notFound]/page.tsx | 7 ++++++- src/app/(routes)/blog/[...notFound]/page.tsx | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/(routes)/(website)/[...notFound]/page.tsx b/src/app/(routes)/(website)/[...notFound]/page.tsx index 37155ea..9269354 100644 --- a/src/app/(routes)/(website)/[...notFound]/page.tsx +++ b/src/app/(routes)/(website)/[...notFound]/page.tsx @@ -9,13 +9,18 @@ interface PropsType { params: Promise<{ notFound: string[]; }>; + searchParams?: Promise<{ + lang?: string; + }>; } export default async function NotFound(props: PropsType) { const params = await props.params; + const searchParams = props.searchParams ? await props.searchParams : {}; const requestedPath = "/" + params.notFound.join("/"); const imageUrl = `/images/404/${pickStableIndex(requestedPath, NOT_FOUND_ILLUSTRATIONS) + 1}.jpg`; - const locale = await getDefaultLocale(); + const defaultLocale = await getDefaultLocale(); + const locale = searchParams?.lang || defaultLocale; const isFa = locale === "fa"; return ( diff --git a/src/app/(routes)/blog/[...notFound]/page.tsx b/src/app/(routes)/blog/[...notFound]/page.tsx index 1674362..a8853ab 100644 --- a/src/app/(routes)/blog/[...notFound]/page.tsx +++ b/src/app/(routes)/blog/[...notFound]/page.tsx @@ -9,13 +9,18 @@ interface PropsType { params: Promise<{ notFound: string[]; }>; + searchParams?: Promise<{ + lang?: string; + }>; } export default async function NotFound(props: PropsType) { const params = await props.params; + const searchParams = props.searchParams ? await props.searchParams : {}; const requestedPath = params.notFound.join("/"); const imageUrl = `/images/404/${pickStableIndex(requestedPath, NOT_FOUND_ILLUSTRATIONS) + 1}.jpg`; - const locale = await getDefaultLocale(); + const defaultLocale = await getDefaultLocale(); + const locale = searchParams?.lang || defaultLocale; const isFa = locale === "fa"; return (