mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-13 04:38:00 +08:00
feat: add i18n language toggle and bilingual docs
This commit is contained in:
18
webui/src/components/LanguageToggle.jsx
Normal file
18
webui/src/components/LanguageToggle.jsx
Normal file
@@ -0,0 +1,18 @@
|
||||
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>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user