feat: add runtime language selector in header (EN/FR toggle)

- Add LanguageSelector component with globe icon + cycle button
- Refactor i18n to support reactive locale switching via useSyncExternalStore
- Locale priority: localStorage > VITE_LOCALE > navigator.language > 'en'
- All components now use useT() hook for reactive re-rendering on locale change
- Persists choice to localStorage (key: pinchchat-locale)
- No page reload needed — instant switch
This commit is contained in:
Nicolas Varrot
2026-02-11 16:18:22 +00:00
parent b6a989bb51
commit 9b3aed4adc
12 changed files with 155 additions and 29 deletions

View File

@@ -1,6 +1,6 @@
import { MessageSquare, X, Sparkles } from 'lucide-react';
import type { Session } from '../types';
import { t } from '../lib/i18n';
import { useT } from '../hooks/useLocale';
interface Props {
sessions: Session[];
@@ -11,6 +11,7 @@ interface Props {
}
export function Sidebar({ sessions, activeSession, onSwitch, open, onClose }: Props) {
const t = useT();
return (
<>
{open && <div className="fixed inset-0 bg-black/60 backdrop-blur-sm z-40 lg:hidden" onClick={onClose} />}