"use client"; import { useLocale, useTranslations } from 'next-intl'; import { cn } from '@/lib/utils'; import { useLocaleStore } from '@/stores/locale-store'; export function LanguageSwitcher({ className }: { className?: string }) { const currentLocale = useLocale(); const t = useTranslations('language'); const setLocale = useLocaleStore((state) => state.setLocale); const handleLanguageChange = (newLocale: string) => { if (newLocale === currentLocale) return; // Update locale in store (persisted to localStorage via Zustand) // IntlProvider handles the translation switch setLocale(newLocale); }; const languages = [ { value: 'en', label: 'English' }, { value: 'fr', label: 'Français' } ]; return (
{languages.map((lang) => ( ))}
); }