'use client'; import { useState } from 'react'; import { useLocale } from 'next-intl'; import { useRouter, usePathname } from '@/i18n/navigation'; import { locales } from '@/i18n/routing'; export function LocaleSwitcher() { const locale = useLocale(); const router = useRouter(); const pathname = usePathname(); const [currentLocale, setCurrentLocale] = useState(locale); function switchLocale(next: string) { setCurrentLocale(next); router.replace(pathname, { locale: next }); } return (
{/* eslint-disable-next-line @next/next/no-img-element */} {currentLocale}
); }