30 lines
895 B
TypeScript
30 lines
895 B
TypeScript
'use client';
|
|
|
|
import {useLocale, useTranslations} from 'next-intl';
|
|
import {usePathname, useRouter} from 'next/navigation';
|
|
import {Globe} from 'lucide-react';
|
|
|
|
export default function LanguageSwitcher() {
|
|
const locale = useLocale();
|
|
const t = useTranslations('language');
|
|
const router = useRouter();
|
|
const pathname = usePathname();
|
|
|
|
const switchLocale = () => {
|
|
const newLocale = locale === 'en' ? 'ka' : 'en';
|
|
const newPath = pathname.replace(`/${locale}`, `/${newLocale}`);
|
|
router.push(newPath);
|
|
};
|
|
|
|
return (
|
|
<div className="fixed top-4 right-4 z-50">
|
|
<button
|
|
onClick={switchLocale}
|
|
className="flex items-center gap-2 bg-white border border-gray-200 rounded-lg px-3 py-2 shadow-sm hover:shadow-md transition-shadow text-sm"
|
|
>
|
|
<Globe className="w-4 h-4" />
|
|
<span>{t('current')}</span>
|
|
</button>
|
|
</div>
|
|
);
|
|
} |