Skip to content

Commit 8ea32ab

Browse files
committed
fix: handle locale detection outside [locale] routes in LocalizedClientLink
1 parent bf7fe28 commit 8ea32ab

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/components/molecules/LocalizedLink/LocalizedLink.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client"
22

33
import Link from "next/link"
4-
import { useParams } from "next/navigation"
4+
import { useParams, usePathname } from "next/navigation"
55
import React, { MouseEventHandler } from "react"
66

77
/**
@@ -20,7 +20,10 @@ const LocalizedClientLink = ({
2020
passHref?: true
2121
[x: string]: any
2222
}) => {
23-
const { locale } = useParams()
23+
const params = useParams()
24+
const pathname = usePathname()
25+
26+
const locale = params?.locale || pathname?.split('/')[1] || 'en'
2427

2528
return (
2629
<Link href={`/${locale}${href}`} {...props}>

0 commit comments

Comments
 (0)