Initial commit

This commit is contained in:
Zdeněk Burda
2026-01-09 21:26:40 +01:00
parent e83aec6dca
commit 41e3ce6f25
404 changed files with 61250 additions and 28 deletions

View File

@@ -0,0 +1,38 @@
import { ChangeEvent } from 'react';
import { useTranslation } from 'react-i18next';
import { useLanguageStore, type Locale } from '@/stores/languageStore';
const AVAILABLE_LOCALES: { code: Locale; label: string }[] = [
{ code: 'cs', label: 'Čeština' },
{ code: 'en', label: 'English' },
];
export default function LanguageSwitcher() {
const { i18n } = useTranslation();
const locale = useLanguageStore((s) => s.locale);
const setLocale = useLanguageStore((s) => s.setLocale);
const handleChange = async (event: ChangeEvent<HTMLSelectElement>) => {
const newLocale = event.target.value as Locale;
// 1) přepni i18next
await i18n.changeLanguage(newLocale);
// 2) aktualizuj globální store (ten nastaví <html lang> + cookie)
setLocale(newLocale);
};
return (
<select
value={locale}
onChange={handleChange}
className="border rounded px-2 py-1 text-sm bg-white dark:bg-gray-900"
>
{AVAILABLE_LOCALES.map((l) => (
<option key={l.code} value={l.code}>
{l.label}
</option>
))}
</select>
);
}