debug: add console logs to switchLocale

This commit is contained in:
Unchained
2026-03-24 11:01:28 +02:00
parent 75b258330a
commit bd95705d72

View File

@@ -48,10 +48,13 @@ export default function Header({ locale = "sr" }: HeaderProps) {
setLangDropdownOpen(false); setLangDropdownOpen(false);
return; return;
} }
console.log("Switching from", locale, "to", newLocale);
console.log("Current pathname:", pathname);
document.cookie = `NEXT_LOCALE=${newLocale}; path=/; max-age=31536000`; document.cookie = `NEXT_LOCALE=${newLocale}; path=/; max-age=31536000`;
const pathWithoutLocale = pathname.replace(/^\/(sr|en|de|fr)/, "") || "/"; const pathWithoutLocale = pathname.replace(/^\/(sr|en|de|fr)/, "") || "/";
const newPath = `/${newLocale}${pathWithoutLocale}`; const newPath = `/${newLocale}${pathWithoutLocale}`;
window.location.href = newPath; console.log("Navigating to:", newPath);
window.location.replace(newPath);
setLangDropdownOpen(false); setLangDropdownOpen(false);
}; };