"use client"; import { usePathname } from "next/navigation"; import { useLocale } from "next-intl"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Globe } from "lucide-react"; const languages = [ { code: "ko", label: "ν•œκ΅­μ–΄", flag: "πŸ‡°πŸ‡·" }, { code: "en", label: "English", flag: "πŸ‡ΊπŸ‡Έ" }, { code: "ja", label: "ζ—₯本θͺž", flag: "πŸ‡―πŸ‡΅" }, ]; interface LanguageSelectProps { native?: boolean; } export function LanguageSelect({ native = true }: LanguageSelectProps) { const pathname = usePathname(); const locale = useLocale(); const handleLanguageChange = (newLocale: string) => { // Remove current locale from pathname const pathnameWithoutLocale = pathname.replace(`/${locale}`, ""); // Force full page reload to ensure clean state and proper i18n loading window.location.href = `/${newLocale}${pathnameWithoutLocale}`; }; const currentLanguage = languages.find((lang) => lang.code === locale); // λ„€μ΄ν‹°λΈŒ select if (native) { return (
); } // Radix UI λͺ¨λ‹¬ select return ( ); }