'use client'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { getLocaleFromPath, getLocalizedPath, type Locale } from '@/lib/i18n'; import { Button } from '@/components/ui'; export function LocaleSwitcher() { const pathname = usePathname(); const currentLocale = getLocaleFromPath(pathname); const locales: Locale[] = ['en', 'de']; return (
{locales.map((locale) => { const isActive = currentLocale === locale; const label = locale === 'en' ? 'English' : 'Deutsch'; const flag = locale === 'en' ? 'πŸ‡ΊπŸ‡Έ' : 'πŸ‡©πŸ‡ͺ'; // Get the current path without locale const currentPath = pathname.replace(/^\/(de|en)/, '') || '/'; const href = getLocalizedPath(currentPath, locale); return ( ); })}
); }