'use client'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { HoverShineOverlay } from '@/components/ui/HoverShineOverlay'; interface LanguageSwitcherProps { mobile?: boolean; isSolidMode?: boolean; } export function LanguageSwitcher({ mobile = false, isSolidMode = false }: LanguageSwitcherProps) { const pathname = usePathname() || '/'; const currentLocale = pathname.startsWith('/en') ? 'en' : 'de'; const getSwitchedUrl = (newLocale: string) => { const pathWithoutLocale = pathname.replace(/^\/(en|de)/, ''); return `/${newLocale}${pathWithoutLocale === '' ? '' : pathWithoutLocale}`; }; const locales = [ { code: 'de', label: 'DE', fullLabel: 'Deutsch', flag: '🇩🇪' }, { code: 'en', label: 'EN', fullLabel: 'English', flag: '🇬🇧' }, ] as const; if (mobile) { return (
{locales.map((loc) => ( {loc.fullLabel} {currentLocale === loc.code && ( )} ))}
); } // Desktop styles dependent on isSolidMode const containerClass = isSolidMode ? 'bg-neutral-100 border-neutral-200' : 'bg-white/10 backdrop-blur-sm border-white/10'; return (
{locales.map((loc) => { const isActive = currentLocale === loc.code; let linkClass = ''; if (isActive) { linkClass = 'bg-white text-primary shadow-sm'; } else { linkClass = isSolidMode ? 'text-text-secondary hover:text-primary' : 'text-white/70 hover:text-white'; } return ( {loc.label} ); })}
); }