diff --git a/src/app/Providers.tsx b/src/app/Providers.tsx index 698e32c5..05ff2646 100644 --- a/src/app/Providers.tsx +++ b/src/app/Providers.tsx @@ -3,8 +3,16 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query" import { ReactNode, useState } from "react" import { TooltipProvider } from "@/components/ui/Tooltip/Tooltip" +import { GlobalTranslations } from "@/i18n/setTranslations" +import { TranslationsProvider } from "@/i18n/useTranslations" -export default function Providers({ children }: { children: ReactNode }) { +export default function Providers({ + children, + translations, +}: { + children: ReactNode + translations: GlobalTranslations +}) { const [queryClient] = useState( () => new QueryClient({ @@ -18,7 +26,9 @@ export default function Providers({ children }: { children: ReactNode }) { ) return ( - {children} + + {children} + ) } diff --git a/src/app/[lang]/category/[slug]/page.tsx b/src/app/[lang]/category/[slug]/page.tsx index 3a93f2e4..c1974eee 100644 --- a/src/app/[lang]/category/[slug]/page.tsx +++ b/src/app/[lang]/category/[slug]/page.tsx @@ -1,6 +1,8 @@ import { Metadata } from "next/types" +import { unstable_setRequestLocale } from "next-intl/server" import { CategoryArticles } from "@/components/CategoryArticles/CategoryArticles" import { Locale } from "@/i18n/i18n" +import { setTranslations } from "@/i18n/setTranslations" import { getMatadataObj } from "@/utils/getMetadataObj" type ArticlePageProps = { params: { slug: string; lang: Locale } } @@ -9,6 +11,9 @@ export async function generateMetadata({ params: { slug } }: ArticlePageProps): return getMatadataObj({ title: `Category - ${slug}` }) } -export default async function Web({ params: { slug } }: ArticlePageProps) { +export default async function Web({ params: { slug, lang } }: ArticlePageProps) { + unstable_setRequestLocale(lang) + await setTranslations(lang) + return } diff --git a/src/app/[lang]/layout.tsx b/src/app/[lang]/layout.tsx index 6df2dd1a..36b49878 100644 --- a/src/app/[lang]/layout.tsx +++ b/src/app/[lang]/layout.tsx @@ -6,6 +6,7 @@ import { Navigation } from "@/components/Navigation/Navigation" import { env } from "@/env.mjs" import { i18n, type Locale } from "@/i18n/i18n" import "@/styles/tailwind.css" +import { setTranslations } from "@/i18n/setTranslations" import { getNavigation } from "@/lib/client" import { GoogleAnalytics } from "../GoogleAnalytics" import Providers from "../Providers" @@ -40,13 +41,13 @@ export default async function Layout({ children, params }: { children: React.Rea const isValidLocale = i18n.locales.some((cur) => cur === locale) if (!isValidLocale) notFound() unstable_setRequestLocale(locale) - + const translations = await setTranslations(locale) const { navigation, footer, logo } = await getNavigation(locale) return ( - +