"use client";
import { useLocale } from 'next-intl';
import { Link } from 'next-view-transitions';
interface LocaleLinkProps {
href: string;
children: React.ReactNode;
className?: string;
[key: string]: any;
}
export function LocaleLink({ href, children, ...props }: LocaleLinkProps) {
const locale = useLocale();
if (href.startsWith('http') || href.startsWith('//')) {
return {children};
}
const normalizedHref = href.startsWith('/') ? href : `/${href}`;
if (
normalizedHref === `/${locale}` ||
normalizedHref.startsWith(`/${locale}/`)
) {
return {children};
}
const localizedHref = `/${locale}${normalizedHref === '/' ? '' : normalizedHref}`;
return {children};
}