Skip to content

Fix language switcher under /makerspace path prefix - #319

Merged
poojanagvekar merged 3 commits into
mainfrom
fix-locale-switch-prefix
Oct 29, 2026
Merged

poojanagvekar merged 3 commits into
mainfrom
fix-locale-switch-prefix

Conversation

@poojanagvekar

@poojanagvekar poojanagvekar commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Refs #317

Follow-up to #318.

Root cause: in production location.pathname includes the /makerspace prefix, so the language toggle built broken URLs like /fr-CA/makerspace/exercises/... (404).

  • Header strips the path prefix before computing the switch target and active nav link.
  • Switcher falls back to the nearest existing parent page when a translation doesn't exist (e.g. pt-BR Cutebot, fr robotics E1–E7) instead of 404.
  • 404 page redirects malformed locale/prefix URLs to the correct page.
  • Unit tests added in i18n/index.spec.js; README updated.

The content.js ... unload console warning comes from a browser extension, not the site.

Not run locally (no node in this environment); please rely on CI.

Related to #317 (French Cutebot pages / language links).

… repair malformed URLs

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
mimiflynn
mimiflynn previously approved these changes Oct 28, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The route-existence set uses raw MDX slugs instead of generated home-page routes, causing valid repaired URLs such as /fr-CA/ to remain on the 404 page.

1 open issue
What changed in this PR

This PR fixes language switching under the production /makerspace prefix and improves navigation when translated content is unavailable.

Changes:

  • Strip the deployment prefix before computing language-switch targets and active navigation links.
  • Add parent-page fallback for missing translations and 404 recovery for malformed locale URLs.
  • Add helper tests, document routing behavior, and link French Cutebot content.
File Description
site/​src/​pages/​404.js Adds malformed URL repair and redirect handling.
site/​src/​i18n/​index.spec.js Tests prefix stripping, translation fallback, and URL repair.
site/​src/​i18n/​index.js Adds path normalization, fallback, and repair helpers.
site/​src/​components/​header.jsx Uses prefix-aware navigation and translation fallback.
site/​README.md Documents routing behavior and the browser-extension warning.
site/​content/​fr-CA/​exercises/​index.mdx Adds a direct link to French Cutebot content.

Review effort: Balanced

Comment thread site/src/pages/404.js Resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@poojanagvekar
poojanagvekar merged commit 2f1828e into main Oct 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants