/** * Author: Simon-Pierre Boucher * Contact: contact@spboucher.ai * Project: Hilmacorp.ai — Web Platform * File: components/LocaleSwitcher.tsx * Description: Client component toggling between FR and EN, preserving the current path */ "use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; export default function LocaleSwitcher({ locale, label, }: { locale: "fr" | "en"; label: string; }) { const pathname = usePathname() ?? `/${locale}`; const target = locale === "fr" ? "en" : "fr"; const switched = pathname.replace(new RegExp(`^/${locale}(?=/|$)`), `/${target}`); return ( { document.cookie = `NEXT_LOCALE=${target};path=/;max-age=31536000;samesite=lax`; }} className="rounded-full border border-line-strong px-3.5 py-1.5 font-mono text-xs uppercase tracking-widest text-ink-soft transition-colors hover:border-accent hover:text-accent" aria-label={label} > {label} ); }