'use client'; import { useRouter, usePathname } from 'next/navigation'; import { Locale, locales, localeNames, localeFlags } from '../lib/i18n'; import { getTranslations } from '../lib/translations'; interface FooterProps { locale: Locale; } export default function Footer({ locale }: FooterProps) { const router = useRouter(); const pathname = usePathname(); const t = getTranslations(locale); const switchLanguage = (newLocale: Locale) => { // Get the current path segments const pathSegments = pathname.split('/').filter(Boolean); // Remove the current locale from the beginning if it exists if (pathSegments[0] && locales.includes(pathSegments[0] as Locale)) { pathSegments.shift(); } // Construct the new path with the new locale const newPath = `/${newLocale}${pathSegments.length > 0 ? '/' + pathSegments.join('/') : ''}`; router.push(newPath); }; return ( ); }