Spaces:
Running
Running
| import { useTranslation } from 'react-i18next'; | |
| import { Button } from '@/components/ui/button'; | |
| import { Languages } from 'lucide-react'; | |
| export function LanguageSwitcher() { | |
| const { i18n, t } = useTranslation(); | |
| const toggleLanguage = () => { | |
| const nextLang = i18n.language === 'zh' ? 'en' : 'zh'; | |
| i18n.changeLanguage(nextLang); | |
| }; | |
| return ( | |
| <Button | |
| variant="ghost" | |
| size="sm" | |
| onClick={toggleLanguage} | |
| className="w-full justify-start gap-3 text-muted-foreground" | |
| > | |
| <Languages className="h-4 w-4" /> | |
| {i18n.language === 'zh' ? t('language.en') : t('language.zh')} | |
| </Button> | |
| ); | |
| } | |