2026-04-19 06:39:06 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
|
2026-09-10 11:10:51 +08:00
|
|
|
import { currentLocale, setAppLanguage } from "@/i18n";
|
|
|
|
|
import { supportedLocales, type SupportedLocale } from "@/i18n/config";
|
|
|
|
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
2026-04-19 06:39:06 +00:00
|
|
|
|
|
|
|
|
export function LanguageSwitcher() {
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
return (
|
2026-09-10 11:10:51 +08:00
|
|
|
<Select value={currentLocale()} onValueChange={(value) => { void setAppLanguage(value as SupportedLocale); }}>
|
|
|
|
|
<SelectTrigger className="min-w-40 rounded-full" aria-label={t("sidebar.language.ariaLabel")}>
|
|
|
|
|
<SelectValue />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
{supportedLocales.map((option) => (
|
|
|
|
|
<SelectItem key={option.code} value={option.code}>{option.nativeLabel}</SelectItem>
|
|
|
|
|
))}
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
2026-04-19 06:39:06 +00:00
|
|
|
);
|
|
|
|
|
}
|