I18n: infrastruktura w panelu admina (i18next+react-i18next, detekcja jezyka PL/EN, przelacznik, testy przymuszone do PL)
This commit is contained in:
22
admin/src/components/ui/language-toggle.tsx
Normal file
22
admin/src/components/ui/language-toggle.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
@@ -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" />}
|
||||
|
||||
Reference in New Issue
Block a user