Files
jsonPrism/src/components/common/LanguageSwitcher.tsx
T
2026-05-13 09:43:37 +07:00

33 lines
886 B
TypeScript

import { useTranslation } from 'react-i18next';
import { cn } from '@/lib/utils';
const LANGUAGES = [
{ code: 'en', label: 'EN' },
{ code: 'vi', label: 'VI' },
] as const;
export function LanguageSwitcher() {
const { i18n } = useTranslation();
const current = i18n.resolvedLanguage ?? 'en';
return (
<div className="border-border/60 flex items-center gap-0.5 rounded-md border p-0.5">
{LANGUAGES.map((lang) => (
<button
key={lang.code}
type="button"
onClick={() => void i18n.changeLanguage(lang.code)}
className={cn(
'rounded px-2 py-0.5 text-xs font-medium transition',
current === lang.code
? 'bg-muted text-foreground'
: 'text-muted-foreground hover:text-foreground',
)}
>
{lang.label}
</button>
))}
</div>
);
}