'use client'; import clsx from 'clsx'; import { createSharedPathnamesNavigation } from 'next-intl/navigation'; export type SupportedLocale = 'en' | 'ja'; const locales = ['en', 'ja'] as const; function removeItem(arr: Array, value: T): Array { const index = arr.indexOf(value); if (index > -1) { arr.splice(index, 1); } return arr; } export const LanguageControl = ({ lang }: { lang?: SupportedLocale }) => { const { Link, usePathname } = createSharedPathnamesNavigation({ locales }); const pathName = usePathname(); const basePathName = () => { const unjoined = pathName.split('/'); const unjoinedWithoutLocale = removeItem(unjoined, 'en'); return unjoinedWithoutLocale.join('/') || '/'; }; return (
JP / EN
); };