I18n: infrastruktura w panelu admina (i18next+react-i18next, detekcja jezyka PL/EN, przelacznik, testy przymuszone do PL)

This commit is contained in:
tisachi
2026-10-17 09:58:42 +02:00
parent 807d2151a2
commit 3a593feb82
19 changed files with 316 additions and 8 deletions

View File

@@ -0,0 +1,22 @@
import { Languages } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { changeLanguage } from '../../i18n';
import type { Language } from '../../i18n/language';
const OTHER: Record<Language, Language> = { pl: 'en', en: 'pl' };
export function LanguageToggle({ className = '' }: { className?: string }) {
const { t, i18n } = useTranslation();
const current: Language = i18n.language === 'en' ? 'en' : 'pl';
const next = OTHER[current];
return (
<button
onClick={() => changeLanguage(next)}
aria-label={`${t('common:toggleLanguage')} (${current.toUpperCase()} → ${next.toUpperCase()})`}
title={`${current.toUpperCase()} → ${next.toUpperCase()}`}
className={`inline-flex items-center justify-center p-2.5 rounded-[10px] bg-card border border-line text-dim shadow-card hover:text-ink hover:border-accent/45 cursor-pointer transition-all duration-150 ${className}`.trim()}
>
<Languages className="w-5 h-5" />
</button>
);
}

View File

@@ -1,13 +1,16 @@
import { Moon, Sun } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { useTheme } from '../../store/theme';
export function ThemeToggle({ className = '' }: { className?: string }) {
const { theme, toggle } = useTheme();
const { t } = useTranslation();
const label = t('common:toggleTheme');
return (
<button
onClick={toggle}
aria-label="Przełącz motyw"
title="Przełącz motyw"
aria-label={label}
title={label}
className={`inline-flex items-center justify-center p-2.5 rounded-[10px] bg-card border border-line text-dim shadow-card hover:text-ink hover:border-accent/45 cursor-pointer transition-all duration-150 ${className}`.trim()}
>
{theme === 'dark' ? <Sun className="w-5 h-5" /> : <Moon className="w-5 h-5" />}