Skip to content

fix(web): set locale cookie on language picker change#31577

Open
JustSidus wants to merge 1 commit into
anomalyco:devfrom
JustSidus:fix/issue-29326-language-picker-cookie
Open

fix(web): set locale cookie on language picker change#31577
JustSidus wants to merge 1 commit into
anomalyco:devfrom
JustSidus:fix/issue-29326-language-picker-cookie

Conversation

@JustSidus

Copy link
Copy Markdown

Issue for this PR

Closes #29326

Type of change

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

What does this PR do?

The language picker in the docs footer navigates to the correct URL but never sets the oc_locale cookie. So on the next visit to /docs, the middleware reads Accept-Language instead of the user's choice and redirects back to whatever language the browser prefers.

Added a small <script> to Footer.astro that listens for changes on the Starlight language select and writes the oc_locale cookie with the same format the middleware expects. It checks the URL path segment against the known locale list so English (which has no path prefix) correctly maps to en.

How did you verify your code works?

Ran astro check and oxlint, no new errors. Traced the cookie format against middleware.ts:cookie() to confirm they match (same name, encoding, path, max-age, samesite).

Screenshots / recordings

N/A, no visual change, just cookie behavior.

Checklist

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

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

The search results only return the current PR (#31577) and one older PR from 2024 that appears to be about locale routing in general. Since the current PR is fixing a specific issue (#29326) with the language picker not setting the locale cookie, and there are no other open PRs addressing this exact functionality, I can provide the following assessment:

No duplicate PRs found

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.

Language picker in docs does nothing

1 participant