You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(web): System default responds when browser language preferences change - #46069
A web tab whose language is set to System default stays in the old language when the browser's preferred languages change. startI18n only re-resolves the locale on app settings changes, so the browser's languagechange event is ignored until a reload or an unrelated settings change.
Deterministic repro on origin/main (af4208eb0a13422ea57bb58032ba99b6670426d4): with the real startI18n/whenLocaleReady from apps/web/src/i18n/runtime.ts (called from appInit.tsx and epubPreviewMain.tsx), saved language: "system" and navigator.languages = ["en-US"], start and await readiness. Then set navigator.languages = ["fr-CA", "en-US"], run window.dispatchEvent(new Event("languagechange")), and await whenLocaleReady() again without touching settings.
Observed: the active locale and document.documentElement.lang stay en.
Expected: French loads and lang becomes fr. A fixed language (en) keeps its catalog.
Change
startI18n now also listens for window's languagechange and reruns the existing applyLanguageSetting, which already resolves System default against navigator.languages and ignores stale catalog loads. Fixed languages resolve to the same catalog, so they are unaffected. This covers hosted and locally served web, and the desktop renderer, since they share this runtime. Mobile has its own i18n runtime and is out of scope.
Scope
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification
New apps/web/src/i18n/runtime.test.ts: on base, the system case fails with expected 'en' to be 'fr', and the fixed-en control passes. On head, both pass.
Not shown: no real-browser screenshot or video of changing OS/browser language preferences live, and no scenarios:prove run.
Authored by Claude Opus 5.5 (Model Hub); reviewed by GPT-6.2 Sol (Codex).
Not shown
apps/web/src/i18n/runtime.test.ts:36 — The transcript proves the locale snapshot and document lang change under synthetic input, not a live browser preference change or rendered translation. Add a scenarios:prove run or before/after captures of the same open Settings page switching from English to French without reload.
.github/pull_request_template.md:22 — The draft reports a green check:changed, but the linked transcript contains only the focused tests and the checkout has no passing check cache. Attach a sanitized exit-0 transcript tied to HEAD 3a61719.
apps/web/src/i18n/locales.ts:10 — The fixed-English control proves the catalog stays English, not that formatting stays constant: the existing regional-English formatting rule is also re-evaluated. Say 'fixed-language catalogs are unchanged' rather than 'fixed languages are unaffected'.
Macroscope's review found this PR approvable — Browser language preference changes now refresh the web app’s existing language selection without a reload. Existing defaults and explicit language choices are preserved, with effects limited to localization.
You can add or adjust custom eligibility rules. Learn more.
Reviewing files that changed from the base of the PR and between 3a61719 and 11043d4.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
startI18n now reapplies the language setting when the browser fires languagechange. Tests verify the locale and document language for system and English settings.
Changes: Browser language change handling
Layer / File(s)
Summary
Register and verify language change handling apps/web/src/i18n/runtime.ts, apps/web/src/i18n/runtime.test.ts
startI18n registers applyLanguageSetting for languagechange. Tests check the locale and document language for system and English settings.
Web tabs using System default language will now follow browser language changes without a reload. The change is small and tested, and no merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: System default language now responds to browser language preference changes (the languagechange event). It matches the changeset, which makes startI18n listen for lang…
Description check
The description covers the problem, the change, scope, and verification. It follows the template's section structure and gives a deterministic repro, the base/head test results, and a transcript link.…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: System default language now responds to browser language preference changes (the languagechange event). It matches the changeset, which makes startI18n listen for languagechange and reapply the language setting. The title follows conventional commit format and is a single line of 9 words.
Full details: Description check
Explanation
The description covers the problem, the change, scope, and verification. It follows the template's section structure and gives a deterministic repro, the base/head test results, and a transcript link. It also states what was not shown. Reviewer comments in the PR's Not shown list flag gaps: the transcript is synthetic and not a live browser check, the check:changed run is not tied to the HEAD commit, and the 'fixed languages are unaffected' wording overstates the result because regional-English formatting may be re-evaluated. These gaps do not make the description largely incomplete, so the check passes, but the author should address them.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Reviewing files that changed from the base of the PR and between af4208e and 3a61719.
Files selected for processing: 2
apps/web/src/i18n/runtime.test.ts
apps/web/src/i18n/runtime.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
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
size:XS0-9 changed lines (additions + deletions).vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
1 participant
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.
Problem
A web tab whose language is set to System default stays in the old language when the browser's preferred languages change.
startI18nonly re-resolves the locale on app settings changes, so the browser'slanguagechangeevent is ignored until a reload or an unrelated settings change.Deterministic repro on
origin/main(af4208eb0a13422ea57bb58032ba99b6670426d4): with the realstartI18n/whenLocaleReadyfromapps/web/src/i18n/runtime.ts(called fromappInit.tsxandepubPreviewMain.tsx), savedlanguage: "system"andnavigator.languages = ["en-US"], start and await readiness. Then setnavigator.languages = ["fr-CA", "en-US"], runwindow.dispatchEvent(new Event("languagechange")), and awaitwhenLocaleReady()again without touching settings.document.documentElement.langstayen.langbecomesfr. A fixed language (en) keeps its catalog.Change
startI18nnow also listens forwindow'slanguagechangeand reruns the existingapplyLanguageSetting, which already resolves System default againstnavigator.languagesand ignores stale catalog loads. Fixed languages resolve to the same catalog, so they are unaffected. This covers hosted and locally served web, and the desktop renderer, since they share this runtime. Mobile has its own i18n runtime and is out of scope.Scope
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification
apps/web/src/i18n/runtime.test.ts: on base, thesystemcase fails withexpected 'en' to be 'fr', and the fixed-encontrol passes. On head, both pass.vp run check:changedexited 0 (format, lint, knip, typecheck, tests, react compiler).Not shown: no real-browser screenshot or video of changing OS/browser language preferences live, and no
scenarios:proverun.Authored by Claude Opus 5.5 (Model Hub); reviewed by GPT-6.2 Sol (Codex).
Not shown