Skip to content

fix(web): System default responds when browser language preferences change - #46069

Open
saphid wants to merge 1 commit into
pingdotgg:mainfrom
saphid:hunter/c-55f47b33e6
Open

saphid wants to merge 1 commit into
pingdotgg:mainfrom
saphid:hunter/c-55f47b33e6

Conversation

@saphid

@saphid saphid commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Problem

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

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'.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 30, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 3a61719

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.

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

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.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · previous review 3a617

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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
Recent review info

Run configuration

Commits

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.

@saphid
saphid force-pushed the hunter/c-55f47b33e6 branch from 3a61719 to 11043d4 Compare November 30, 2026 13:11

This branch has not been deployed

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

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant