mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-06 01:15:29 +08:00
19 lines
670 B
JavaScript
19 lines
670 B
JavaScript
import { useI18n } from '../i18n'
|
|
|
|
export default function LanguageToggle({ className = '' }) {
|
|
const { lang, setLang, t } = useI18n()
|
|
const nextLang = lang === 'zh' ? 'en' : 'zh'
|
|
const label = nextLang === 'zh' ? t('language.chinese') : t('language.english')
|
|
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={() => setLang(nextLang)}
|
|
className={`text-xs font-semibold px-2 py-1 rounded-md border border-border bg-secondary/50 text-muted-foreground hover:text-foreground hover:bg-secondary transition-colors ${className}`}
|
|
title={t('language.label')}
|
|
>
|
|
{label}
|
|
</button>
|
|
)
|
|
}
|