VetNet-LCPS / vetcopilot-app /src /components /LanguageSwitcher.tsx
thomasm291678
VetCopilot-LCPS: LCPS 2.0 本地推理引擎替换 DeepSeek API
793e953
Raw History Blame Contribute Delete
952 Bytes
import React from 'react'
import { useTranslation } from '../i18n'
/**
* LanguageSwitcher - A compact language toggle button
*
* Displays the current language (中/EN) and switches between Chinese and English on click.
* Designed to be placed in the Layout header, next to the user avatar.
*/
export default function LanguageSwitcher() {
const { locale, setLocale } = useTranslation()
const toggle = () => {
setLocale(locale === 'zh' ? 'en' : 'zh')
}
return (
<button
onClick={toggle}
title={locale === 'zh' ? 'Switch to English' : 'Switch to Chinese'}
className="text-xs font-medium px-2 py-1 rounded-md border border-gray-200 bg-white hover:bg-gray-50 text-gray-600 hover:text-gray-800 transition-colors min-h-[32px] min-w-[40px] flex items-center justify-center"
aria-label={locale === 'zh' ? 'Switch to English' : 'Switch to Chinese'}
>
{locale === 'zh' ? '中' : 'EN'}
</button>
)
}