fix(web): set locale cookie on language picker change#31577
Conversation
|
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 |
|
hey, just wanted to check if this is still something you'd like fixed or if I should close the PR? happy to make changes if needed |
|
hey, bumping this again. still hoping to get some eyes on it, its a really small change (11 lines) and the cookie fix makes the language picker actually work. happy to adjust if needed. |
|
closing this one, looks like #32551 already fixed this with a slightly different approach. thanks anyway! |
Issue for this PR
Closes #29326
Type of change
What does this PR do?
The language picker in the docs footer navigates to the correct URL but never sets the
oc_localecookie. So on the next visit to/docs, the middleware readsAccept-Languageinstead of the user's choice and redirects back to whatever language the browser prefers.Added a small
<script>toFooter.astrothat listens for changes on the Starlight language select and writes theoc_localecookie 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 toen.How did you verify your code works?
Ran
astro checkandoxlint, no new errors. Traced the cookie format againstmiddleware.ts:cookie()to confirm they match (same name, encoding, path, max-age, samesite).Screenshots / recordings
N/A, no visual change, just cookie behavior.
Checklist