o2o-triple-pick/frontend/src/components/LangSwitch.tsx

25 lines
791 B
TypeScript

import { Link, useLocation } from "react-router-dom";
import type { Lang } from "@/lib/i18n";
// KO / EN 토글. 현재 경로 유지 + ?lang 토글.
export default function LangSwitch({ lang }: { lang: Lang }) {
const { pathname } = useLocation();
const href = (l: Lang) => (l === "en" ? `${pathname}?lang=en` : pathname);
const langs: Lang[] = ["ko", "en"];
return (
<div className="flex items-center overflow-hidden rounded-full border border-white/15 text-[11px] font-extrabold">
{langs.map((l) => (
<Link
key={l}
to={href(l)}
className={`px-2.5 py-1 transition ${
lang === l ? "bg-white text-[#14171C]" : "text-white/65"
}`}
>
{l.toUpperCase()}
</Link>
))}
</div>
);
}