Skip to content

Keep the footer language picker on English-only pages - #1988

Merged
David Pine (IEvangelist) merged 1 commit into
mainfrom
aspireagent/fix-footer-language-english-only
Nov 1, 2026
Merged

David Pine (IEvangelist) merged 1 commit into
mainfrom
aspireagent/fix-footer-language-english-only

Conversation

@davidfowl

Copy link
Copy Markdown
Contributor

Summary

On Developer Hub and sample pages, choosing a language in the footer language picker sends readers to a 404. Those pages are generated only in English, but the picker adds a locale prefix to the URL anyway:

Page Pick "Deutsch" → Status
/hub/ /de/hub/ 404
/hub/glossary/apphost/ /de/hub/glossary/apphost/ 404
/reference/samples/aspire-shop/ /de/reference/samples/aspire-shop/ 404
/reference/api/csharp/ /reference/api/csharp/ 200 (already special-cased)
/get-started/install-cli/ /de/get-started/install-cli/ 200 (translated docs, unchanged)

I reproduced this with Playwright against astro dev at main 04ecd1c, and production returns the same 404s for those URLs.

Root cause: FooterPreferences.astro only recognised API reference pages as English-only, using isApiReferencePath. Every other path got a locale prefix.

Fix:

  • The picker's path decision moves into src/utils/language-switch.ts (getLanguageSwitchPath and getSelectedLocaleForPath).
  • Every default-locale-only route (/hub/**, /reference/api/** and /reference/samples/<sample>/) now gets the existing API reference behaviour: store the preferred locale, stay on the English URL, and show the stored preference in the picker.
  • Translated docs routes behave as before.

src/utils/default-locale-only-routes.ts is byte-identical to the file added in #1987 (same git blob, dd363d05). These two PRs merge cleanly in either order and don't depend on each other.

Third-party links and affiliations

None.

Validation

  • New unit test tests/unit/language-switch.vitest.test.ts:
    • Before the fix, the existing logic was extracted unchanged into the new helpers and 7 of the 17 tests failed. All of the failures were on hub and sample routes. The API reference and docs cases passed, which shows the extraction itself didn't change behaviour.
    • After the fix: 17 of 17 pass.
  • New browser test in tests/e2e/ui-regressions.spec.ts ("language selector keeps English-only pages on their English URL"). It picks Deutsch through the real listbox on /hub/ and /reference/samples/aspire-shop/.
    • Before the fix it failed on desktop-chromium and mobile-chromium with Expected: "/hub/" Received: "/de/hub/".
    • After the fix it passes on both.
    • It ran together with the existing footer and language-selector tests: 9 of 9 passed on astro dev.
  • Full unit suite (vitest run): 83 files, 1125 passed and 1 skipped.
  • Lint (astro sync, skill digest check, eslint . --max-warnings 0) and Prettier on the changed files: both pass.
  • tsc: no new errors. The one .astro import resolution error in custom-components.vitest.test.ts is already on main.
  • This changes navigation, not styling, so there are no screenshots.

🤖 Posted by AspireAgent (AI Agent)

Choosing a language in the footer on Developer Hub or sample pages
prefixed the locale (e.g. /de/hub/), but those pages are only generated
in English, so readers landed on a 404. Treat every default-locale-only
route like API reference pages: remember the preference and stay on the
English URL.

Co-authored-by: Copilot <[email protected]>
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Frontend HTML artifact ready

The latest frontend build uploaded the frontend-dist artifact for PR #1988. Use the VS Code button below to open this PR with GitHub Artifacts Explorer and browse the built HTML locally.

VS Code: Open PR #1988 artifacts

This comment updates automatically when a new frontend build artifact is uploaded.

@davidfowl
David Fowler (davidfowl) marked this pull request as ready for review October 30, 2026 07:06
Copilot AI balanced review requested due to automatic review settings October 30, 2026 07:06

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.

🟢 Approval recommended

No active review issues block approval of the language-picker routing changes.

No open issues 🎉

What changed in this PR

This PR prevents the footer language picker from sending readers to nonexistent localized URLs on English-only pages, while preserving language switching for translated documentation.

Changes:

  • Identifies Developer Hub, API reference, and individual sample pages as English-only routes.
  • Extracts language-switching helpers that retain English URLs while displaying the stored language preference.
  • Adds unit and browser regression coverage for English-only routes and translated documentation.
File Description
src/​frontend/​tests/​unit/​language-switch.vitest.test.ts Tests URL selection and displayed locale behavior.
src/​frontend/​tests/​e2e/​ui-regressions.spec.ts Adds browser coverage for language selection on hub and sample pages.
src/​frontend/​src/​utils/​language-switch.ts Centralizes navigation and selected-locale logic.
src/​frontend/​src/​utils/​default-locale-only-routes.ts Identifies routes available only in English.
src/​frontend/​src/​components/​FooterPreferences.astro Connects the footer picker to the new helpers.

Review effort: Balanced

@IEvangelist

Copy link
Copy Markdown
Member

Docs review: not applicable

Reviewed the five changed files against main at PR head 59e67573d306f851618b5658da35941a920f962d using the docs PR reviewer skill.

  • Phase A (claims verification): no documentation prose, Aspire API examples, configuration guidance, or release-version claims changed; 0 claims extracted (all verdict counts 0). No upstream product-source lookup applies.
  • Phase B (doc-tester): not applicable: this diff changes the footer client code, routing helpers, and regression tests, not a documented tutorial or user workflow. No docs-example execution or unrelated docs-page testing was performed.
  • Phase C: applicability recorded here; the applicable code review follows separately. This is not a docs-accuracy approval or a formal GitHub review.

@IEvangelist

Copy link
Copy Markdown
Member

Code review: no high-confidence findings

Reviewed all five changed files against main (04ecd1ce83905d8e37df1933d83ce964e8193581) at head 59e67573d306f851618b5658da35941a920f962d, using the repository code-review skill.

The footer keeps Hub, individual sample, and API routes unprefixed while retaining the stored language selection. Translated docs and the samples index still use locale-prefixed URLs; URL locale precedence, preference normalization/storage, and query/fragment preservation remain wired through the existing helpers. No actionable correctness or accessibility regression was identified in the changed code.

Test coverage and validation limits

  • Unit: npm exec --no -- vitest run --config vitest.config.ts tests/unit/language-switch.vitest.test.ts tests/unit/locale-routes.vitest.test.ts tests/unit/api-reference-routes.vitest.test.ts tests/unit/browser-storage.vitest.test.ts - 27 tests passed.
  • E2E: npm exec --yes [email protected] -- bun run playwright test tests/e2e/ui-regressions.spec.ts --grep 'language selector keeps English-only pages' --workers=1 --reporter=line - tablet and mobile passed; desktop initially timed out waiting for the sample-page navigation after selecting Deutsch. A single isolated desktop rerun with --project=desktop-chromium passed. This is not a claim that the first run was clean or that the timeout's root cause was established.
  • The new browser test covers Hub/sample navigation and the persisted displayed preference across reload/navigation on all three configured viewport projects. Translated routing and API canonicalization have unit coverage; their footer switching flows were not separately exercised in this focused local browser run.
  • Accessibility: markup, keyboard interaction, focus handling, and styling are unchanged; existing shared-footer WCAG audits remain in place. No new local axe run was performed.
  • CI run at the exact reviewed head completed successfully, including frontend validation/build and all six desktop/tablet/mobile E2E shards. No local production build was run.

This is a top-level review report, not a formal approval or change-request review.

@IEvangelist David Pine (IEvangelist) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved following the completed Project docs applicability and clean code review at this unchanged head, approval recommendation, and passing CI. Approval and merge authorized by the user.

@IEvangelist
David Pine (IEvangelist) merged commit 9017410 into main Nov 1, 2026
20 checks passed
@IEvangelist
David Pine (IEvangelist) deleted the aspireagent/fix-footer-language-english-only branch November 1, 2026 20:33
David Pine (IEvangelist) pushed a commit that referenced this pull request Nov 3, 2026
## Summary

The **Get started** sidebar has a Glossary entry (`link:
'/hub/glossary/'` in `config/sidebar/docs.topics.ts`). Starlight adds
the active locale to sidebar links, so every localized docs page links
to `/de/hub/glossary/`, `/ja/hub/glossary/` and so on. The Hub is
English-only and those pages aren't generated, so the link returns a
404. For example, https://aspire.dev/de/get-started/install-cli/
currently renders `href="/de/hub/glossary/"`, and
`https://aspire.dev/de/hub/glossary/` returns **404**.

`route-data-middleware.ts` already removes the locale from sidebar links
to API reference pages. This PR extends that same sidebar pass: when a
localized sidebar href resolves to a default-locale-only route
(`isDefaultLocaleOnlyPath`, covering `/hub/**`, API reference and
individual samples), the locale prefix is stripped. Links to translated
docs pages keep their locale.

`src/utils/default-locale-only-routes.ts` is byte-identical to the copy
in #1987 and #1988, and the import is identical, so the PRs combine
without conflicts. I trial-merged this branch with #1984, #1987 and
#1988 locally: there were no conflicts and all 1143 unit tests passed on
the combined tree.

There is no visual change; only link targets change.

## Third-party links and affiliations

None.

## Validation

- New regression test
`tests/unit/route-data-middleware-sidebar-locale.vitest.test.ts` (3
tests):
- Before the fix: 1 failed (`/de/hub/glossary/`, `/ja/hub/`,
`/zh-cn/reference/samples/aspire-shop/` stayed localized) and 2 passed
(control cases).
  - After the fix: 3 of 3 pass.
- Full unit suite (`vitest run --config vitest.config.ts`): 83 files,
1111 passed, 1 skipped.
- Lint (`astro sync`, `compute-skill-digests --check`, `eslint .
--max-warnings 0`) passes, and Prettier check passes on the changed
files.
- Rendered on `astro dev`:
- `/de/get-started/install-cli/` and `/ja/fundamentals/telemetry/` now
render only `href="/hub/glossary/"`.
  - `/de/get-started/resources/` remains localized.

**🤖 Posted by AspireAgent (AI Agent)**

---------

Co-authored-by: davidfowl <[email protected]>
Co-authored-by: Copilot <[email protected]>
Sébastien Ros (sebastienros) added a commit that referenced this pull request Nov 11, 2026
- TypeScript API parameter descriptions (#2009)
- No locale prefix or hreflang alternates for English-only pages: the footer
  language picker (#1988), hreflang (#1987) and the sidebar Glossary link (#1989)
- Footer link to the Aspire MIT license
- Homepage: environment fade (#1993), stale AppHost animations (#1950), the
  dashboard carousel keeps the selected slide on activation
- Search: first-result highlight with out-of-order renders (#2007), hover cursor
  flicker (#1977)
- Live status over WebSocket (#1942) and twoslash hover, merged into the copies
  of the frontend scripts
- Icon data 5.40.0 and the regenerated sprite
- src/frontend now uses Bun: README and script usage updated
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