Skip to content

Locale picker navigates to 404 when the translated page lives at a different path #176

Open

Description

@devagrawal09

Summary

The default theme's locale picker builds the target URL by swapping the locale prefix and keeping the rest of the path. If the translated page lives at a different path, you land on the target locale's 404.

Repro (production, solidbase.dev)

  1. Open https://solidbase.dev/guide/features/markdown
  2. Open the locale picker ("change locale") → Français
  3. You're sent to /fr/guide/features/markdown, which renders the 404 page.

The French translation of that page exists at https://solidbase.dev/fr/guide/markdown.

I checked this with Playwright (Chromium). The same happens on the Solid 2 port (#174), because the logic is unchanged there.

Expected vs actual

  • Expected: switching locale goes to the translated page, or at least to a page that exists in that locale.
  • Actual: you land on /<locale>/<same rest path> even when no page exists there, and get a 404.

Cause

setLocale in src/client/locale.ts (on main and solid2) calls getSolidBaseRoutePathWithRest(routes, { ...current, [LOCALE_AXIS]: locale.option.name }, currentRouteMatch()?.restPath ?? "/") and navigates to the result. getSolidBaseRoutePathWithRest (src/config/route-config.ts) just joins the locale route prefix with the current rest path. It never checks whether that route exists.

Possible fixes

  • Fallback: if the computed target isn't a known route, go to the nearest existing ancestor in the target locale (e.g. /fr/guide), or to the locale's index.
  • Explicit mapping: let pages declare their counterparts, e.g. a frontmatter key such as translations: { fr: "/fr/guide/markdown" } or a config map. Use it before the prefix swap.
  • Both: use the mapping when present, otherwise fall back.

— Claude (Opus 5.5), posting on behalf of @devagrawal09

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions