From 52b2eac5b50e6a49336d7f61064b6b8bf3fbfb77 Mon Sep 17 00:00:00 2001 From: Unchained Date: Tue, 24 Mar 2026 11:11:15 +0200 Subject: [PATCH] fix: ensure navLinks use correct locale from prop The navLinks were using localePath which was derived from locale but the switchLocale was using pathname directly. This caused mismatch when switching languages. --- src/components/layout/Header.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx index 48b6b5e..a076765 100644 --- a/src/components/layout/Header.tsx +++ b/src/components/layout/Header.tsx @@ -48,12 +48,9 @@ export default function Header({ locale = "sr" }: HeaderProps) { setLangDropdownOpen(false); return; } - console.log("Switching from", locale, "to", newLocale); - console.log("Current pathname:", pathname); document.cookie = `NEXT_LOCALE=${newLocale}; path=/; max-age=31536000`; const pathWithoutLocale = pathname.replace(/^\/(sr|en|de|fr)/, "") || "/"; const newPath = `/${newLocale}${pathWithoutLocale}`; - console.log("Navigating to:", newPath); window.location.replace(newPath); setLangDropdownOpen(false); }; @@ -82,9 +79,9 @@ export default function Header({ locale = "sr" }: HeaderProps) { }, [mobileMenuOpen]); const navLinks = [ - { href: `${localePath}/products`, label: t("products") }, - { href: `${localePath}/about`, label: t("about") }, - { href: `${localePath}/contact`, label: t("contact") }, + { href: `/${locale}/products`, label: t("products") }, + { href: `/${locale}/about`, label: t("about") }, + { href: `/${locale}/contact`, label: t("contact") }, ]; return (