Skip to content

refactor(www): stabilize locale routing#16402

Open
akronb wants to merge 4 commits intoanomalyco:devfrom
akronb:fix-docs-locale
Open

refactor(www): stabilize locale routing#16402
akronb wants to merge 4 commits intoanomalyco:devfrom
akronb:fix-docs-locale

Conversation

@akronb
Copy link
Contributor

@akronb akronb commented Mar 6, 2026

Issue for this PR

Closes #16278, closes #15984, closes #15194, closes #15904, closes #14997, closes #14409

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This PR fixes the docs locale architecture introduced in #12508, which made routing dependent on ambient locale state and treated English as a special-case root path. Rather than continuing to patch symptoms (#13109, #13608), this change addresses the root cause: docs URLs are now path-authoritative, English is promoted to an explicit en locale.

Key changes:

  • switch Starlight config from defaultLocale: "root" to defaultLocale: "en"
  • move English docs content into packages/web/src/content/docs/en/
  • add shared docs locale helpers in packages/web/src/lib/docs-locale.ts
  • update web middleware to:
    • redirect /docs -> /docs/<locale>/
    • redirect /docs/<slug> -> /docs/<locale>/<slug>
    • normalize legacy /docs/... to /docs/en/...
    • keep explicit locale routes authoritative and refresh oc_locale
  • simplify console docs routing by centralizing proxy logic in packages/console/app/src/lib/docs.ts
  • update docs sync/update workflows and agent prompts to use the new English docs path

How did you verify your code works?

I verified this with targeted regression tests and package checks:

  • added console coverage for docs locale resolution in packages/console/app/test/language.test.ts
  • added web coverage for docs redirects and cookie handling in packages/web/test/middleware.test.ts, including English, non-English, legacy root, and unknown locale-like paths
  • ran bun test test/language.test.ts in packages/console/app
  • ran bun test test/middleware.test.ts in packages/web
  • ran bun run astro check in packages/web
  • ran bun run typecheck in packages/console/app

I also verified that the docs sync workflow and docs/translator agent references now point at the new English docs source path under packages/web/src/content/docs/en/.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@akronb
Copy link
Contributor Author

akronb commented Mar 9, 2026

@adamdotdevin could you take a look?

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