"use client"; import { Globe } from "lucide-react"; import { useI18n } from "@/i18n/i18n-context"; import { LOCALES, LOCALE_LABELS, LOCALE_NAMES } from "@/i18n/config"; import { cn } from "@/lib/utils"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip"; interface LanguageToggleProps { /** When true the tooltip anchors to the right (collapsed rail); otherwise * it anchors above so it doesn't collide with the sidebar edge. */ collapsed?: boolean; } /** * Clicking cycles through the available locales. The expanded sidebar shows * the current language as text; the collapsed rail keeps the compact badge. */ export function LanguageToggle({ collapsed }: LanguageToggleProps) { const { locale, setLocale, t } = useI18n(); const nextIndex = (LOCALES.indexOf(locale) + 1) % LOCALES.length; const nextLocale = LOCALES[nextIndex]; return ( {t("common.switchLanguageTo", { name: LOCALE_NAMES[nextLocale] })} ); }