Skip to content

Language switcher returns to locale root, losing the current page #60

Closed

Description

@DataDave-Dev

🇪🇸 Español

El toggle de locale enlaza a /${locale} incondicionalmente, así que cambiar de idioma desde /en/docs/getting-started o /en/app devuelve al usuario a la home en vez del equivalente traducido de la página actual.

Archivo: src/components/layout/Header.tsx:84-86

Solución sugerida: Construir el href destino intercambiando solo el segmento de locale inicial de usePathname(), con fallback a la raíz si no mapea.


🇬🇧 English

The locale toggle links to /${locale} unconditionally, so switching language from /en/docs/getting-started or /en/app drops the user back to the home page instead of the translated equivalent.

File: src/components/layout/Header.tsx:84-86

Suggested fix: Build the target href by swapping only the leading locale segment of usePathname(), falling back to root if unmapped.

Activity

  1. added
    bug
    help wanted
    accessibility
    i18n
    on Jun 16, 2026
  2. rue-eru commented on Jun 17, 2026

    @rue-eru
    Contributor

    Hi! I'd like to work on this. I have experience with Next.js and i18n. The fix looks clear: use usePathname() to swap only the leading locale segment, falling back to / if it's not mapped. Could you assign it to me?

  3. DataDave-Dev commented on Jun 17, 2026

    @DataDave-Dev
    OwnerAuthor

    🇪🇸 Español

    ¡Asignado, gracias por ofrecerte! 🙌

    Aviso importante: al revisar main, el fix que describe esta issue ya parece estar implementado en el commit 03d1694 (feature de i18n extensible). El componente ya usa getRedirectPath en src/components/layout/Header.tsx:38-46, que intercambia solo el segmento de locale de usePathname() con fallback a la raíz, y el dropdown enlaza a href={getRedirectPath(locale)} en vez de /${locale}.

    Casos que funcionan: /en/docs/getting-started → /es/docs/getting-started, /en/app → /es/app, / → /es (fallback).

    ¿Podrías verificarlo en tu entorno? Si confirmas que ya funciona, cerramos la issue. Si encuentras algún caso que aún falle (query string, hash, rutas sin locale, etc.), adelante con el PR. 🚀


    🇬🇧 English

    Assigned, thanks for volunteering! 🙌

    Heads up: looking at main, the fix described here appears to already be implemented in commit 03d1694 (extensible i18n feature). The component already uses getRedirectPath at src/components/layout/Header.tsx:38-46, which swaps only the leading locale segment of usePathname() with a root fallback, and the dropdown links to href={getRedirectPath(locale)} instead of /${locale}.

    Working cases: /en/docs/getting-started → /es/docs/getting-started, /en/app → /es/app, / → /es (fallback).

    Could you verify it on your end? If you confirm it already works, we can close the issue. If you find an edge case that still fails (query string, hash, locale-less routes, etc.), go ahead with the PR. 🚀

  4. rue-eru commented on Jun 18, 2026

    @rue-eru
    Contributor

    @DataDave-Dev, I checked both the code in main and the live site at weftmap.vercel.app. The language switcher now correctly stays on the current page (e.g., /en/docs → /es/docs). The fix is already working. I think this issue can be closed.

  5. DataDave-Dev commented on Jun 18, 2026

    @DataDave-Dev
    OwnerAuthor

    Excellent @rue-eru, thank you very much for the review, if you like to continue contributing you could see the other issues and if you like one I can assign it to you without problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

accessibilitybughelp wantedi18n

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions