Skip to content

Commit

Permalink
feat: always prefix locales
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierniki committed Nov 9, 2023
1 parent c605a64 commit 28d9e37
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/app/Providers.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
"use client"

import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
import { NextIntlClientProvider } from "next-intl"
import { ReactNode, useState } from "react"
import { TooltipProvider } from "@/components/ui/Tooltip/Tooltip"
import { Locale } from "@/i18n/i18n"
import { GlobalTranslations } from "@/i18n/setTranslations"
import { TranslationsProvider } from "@/i18n/useTranslations"

export default function Providers({
children,
translations,
locale,
}: {
children: ReactNode
translations: GlobalTranslations
locale: Locale
}) {
const [queryClient] = useState(
() =>
Expand All @@ -27,7 +31,9 @@ export default function Providers({
return (
<QueryClientProvider client={queryClient}>
<TranslationsProvider translations={translations}>
<TooltipProvider>{children}</TooltipProvider>
<TooltipProvider>
<NextIntlClientProvider locale={locale}>{children}</NextIntlClientProvider>
</TooltipProvider>
</TranslationsProvider>
</QueryClientProvider>
)
Expand Down
6 changes: 2 additions & 4 deletions src/app/[lang]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ export default async function Layout({ children, params }: { children: React.Rea
return (
<html lang={locale}>
<GoogleAnalytics />
<Providers translations={translations}>
<Providers translations={translations} locale={locale}>
<body className="flex min-h-screen flex-col items-center ">
<div className="z-50 flex w-full justify-center border-b bg-white">
<nav className="flex w-full max-w-[1200px] items-center justify-end gap-4 py-4">
<NextIntlClientProvider locale={locale}>
<Navigation navigation={navigation} />
</NextIntlClientProvider>
<Navigation navigation={navigation} />
</nav>
</div>

Expand Down
1 change: 1 addition & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { i18n } from "./i18n/i18n"
export default createMiddleware({
locales: i18n.locales,
defaultLocale: i18n.defaultLocale,
localePrefix: "always",
})

export const config = {
Expand Down

0 comments on commit 28d9e37

Please sign in to comment.