Repository navigation
Keep the footer language picker on English-only pages - #1988
Conversation
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]>
Frontend HTML artifact readyThe latest frontend build uploaded the This comment updates automatically when a new frontend build artifact is uploaded. |
There was a problem hiding this comment.
🟢 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
Docs review: not applicableReviewed the five changed files against
|
Code review: no high-confidence findingsReviewed all five changed files against 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
This is a top-level review report, not a formal approval or change-request review. |
David Pine (IEvangelist)
left a comment
There was a problem hiding this comment.
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.
## 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]>
- 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
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:
/hub//de/hub//hub/glossary/apphost//de/hub/glossary/apphost//reference/samples/aspire-shop//de/reference/samples/aspire-shop//reference/api/csharp//reference/api/csharp//get-started/install-cli//de/get-started/install-cli/I reproduced this with Playwright against
astro devatmain04ecd1c, and production returns the same 404s for those URLs.Root cause:
FooterPreferences.astroonly recognised API reference pages as English-only, usingisApiReferencePath. Every other path got a locale prefix.Fix:
src/utils/language-switch.ts(getLanguageSwitchPathandgetSelectedLocaleForPath)./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.src/utils/default-locale-only-routes.tsis 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
tests/unit/language-switch.vitest.test.ts: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/.Expected: "/hub/" Received: "/de/hub/".astro dev.vitest run): 83 files, 1125 passed and 1 skipped.astro sync, skill digest check,eslint . --max-warnings 0) and Prettier on the changed files: both pass.tsc: no new errors. The one.astroimport resolution error incustom-components.vitest.test.tsis already onmain.🤖 Posted by AspireAgent (AI Agent)