Skip to content

Commit af44cda

Browse files
committed
chore: default-spanish-locale
1 parent 685e90f commit af44cda

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/app/[locale]/components/Navbar.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ const Navbar: React.FC<INavbar> = ({ locale }) => {
4141
>
4242
<div className="max-w-6xl mx-auto">
4343
<div className="flex items-center justify-between">
44-
<Link href="/" className="flex items-center space-x-4 cursor-pointer">
44+
<Link
45+
href={`/${locale}`}
46+
className="flex items-center space-x-4 cursor-pointer"
47+
>
4548
<img
4649
src="/kleros.svg"
4750
alt="Kleros"

src/i18n/routing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { createNavigation } from "next-intl/navigation";
22
import { defineRouting } from "next-intl/routing";
33

4-
export const locales = ["en", "es", "ar"];
4+
export const locales = ["es", "en", "ar"];
55

66
export const routing = defineRouting({
77
// A list of all locales that are supported
88
locales,
99

1010
// Used when no locale matches
11-
defaultLocale: "en",
11+
defaultLocale: "es",
1212
});
1313

1414
// Lightweight wrappers around Next.js' navigation APIs

src/middleware.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import createMiddleware from "next-intl/middleware";
2-
import { NextRequest } from "next/server";
2+
import { NextRequest, NextResponse } from "next/server";
33

44
import { locales, routing } from "@/i18n/routing";
55

@@ -13,5 +13,10 @@ export default function middleware(request: NextRequest) {
1313
new RegExp(`^/(${locales.join("|")})(/.*)?$`).test(pathname);
1414
if (!shouldHandle) return;
1515

16+
// Redirect root path to Spanish locale
17+
if (pathname === "/") {
18+
return NextResponse.redirect(new URL("/es", request.url));
19+
}
20+
1621
return handleI18nRouting(request);
1722
}

0 commit comments

Comments
 (0)