RDoc-3454 Persist selected language in URL#2561
Open
poissoncorp wants to merge 1 commit into
Open
Conversation
…l+Click Make the "?lang=" query parameter the per-tab source of truth for the selected API language, so a page can be shared/linked in a specific language and two tabs can show different languages side-by-side. - LanguageStore: the useSyncExternalStore snapshot reads the URL first, then the stored (localStorage) cross-session default, then csharp; the server snapshot is the default so the first render matches the prerendered HTML. setLanguage writes both localStorage and the URL (default kept out of the URL) and notifies same-tab only (a custom event, not the native "storage" event), so switching in one tab no longer flips other tabs. - LanguageUrlSync (new): mounted on pages with supported_languages; persists an incoming "?lang=" and re-stamps it after navigation (internal links drop the query string). - LanguageSwitcher: options are anchors to the current page with an explicit "?lang="; plain click switches in place, Ctrl/Cmd/Shift/middle click opens the language in a new tab/window (RDoc-3454).
Lwiel
approved these changes
Jul 16, 2026
kalczur
suggested changes
Jul 17, 2026
| setLanguage: (newLanguage: DocsLanguage) => void; | ||
| } => { | ||
| const language = useSyncExternalStore(subscribe, getLanguageFromLocalStorage, () => DEFAULT_LANGUAGE); | ||
| const history = useHistory(); |
Contributor
There was a problem hiding this comment.
URL hash changes (TOC clicks) now re-render every language block
| const { setLanguage } = useLanguage(); | ||
| const location = useLocation(); | ||
|
|
||
| useEffect(() => { |
Contributor
There was a problem hiding this comment.
Now you can remove useEffect from LanguageSwitcher.tsx
Contributor
|
@poissoncorp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue link
RDoc-3583 Persist selected language state in the URL
RDoc-3454 Language switcher should open the article in a new tab on Ctrl+Click
Additional description
Make the "?lang=" query parameter the per-tab source of truth for the selected API language, so a page can be shared/linked in a specific language and two tabs can show different languages side-by-side. On Ctrl+Click, a new tab appears with the clicked language.
Type of change
/templatesor readme)Changes in docs URLs
/scripts/redirects.jsonfile, setDocuments MovedPR label)Changes in UX/UI