mirror of
https://github.com/beilunyang/moemail.git
synced 2026-05-11 18:11:27 +08:00
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
"use client"
|
|
|
|
import { useLocaleSwitcher } from "@/hooks/use-locale-switcher"
|
|
import { LOCALE_LABELS } from "@/i18n/config"
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu"
|
|
import { Button } from "@/components/ui/button"
|
|
import { Languages } from "lucide-react"
|
|
|
|
export function LanguageSwitcher() {
|
|
const { locale, locales, switchLocale } = useLocaleSwitcher()
|
|
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button variant="ghost" size="icon" aria-label="Switch language">
|
|
<Languages className="h-5 w-5" />
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end">
|
|
{locales.map((loc) => (
|
|
<DropdownMenuItem
|
|
key={loc}
|
|
onClick={() => switchLocale(loc)}
|
|
className={locale === loc ? "bg-accent" : ""}
|
|
>
|
|
{LOCALE_LABELS[loc]}
|
|
</DropdownMenuItem>
|
|
))}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)
|
|
}
|