fix(pad): restore Accept-Language auto-detect on pad UI (#7586)#7588
Merged
JohnMcLear merged 1 commit intoether:developfrom Apr 23, 2026
Merged
fix(pad): restore Accept-Language auto-detect on pad UI (#7586)#7588JohnMcLear merged 1 commit intoether:developfrom
JohnMcLear merged 1 commit intoether:developfrom
Conversation
ether#7586) `Pad.normalizePadSettings()` was defaulting `lang` to the literal string 'en' when `rawPadSettings.lang` was not a string. That value flowed into `clientVars.padOptions.lang` and then into `getParams()` in pad.ts, which calls `html10n.localize([serverValue, 'en'])` as a callback for the `lang` setting. The result: every pad forced English on load, overriding the browser's Accept-Language and the existing auto-detect chain in l10n.ts (cookie -> navigator.language -> 'en'). The regression was introduced in ether#7545 ("Add creator-owned pad settings defaults", commit e0ccdb4). 2.6.1 did not have this default, so auto-detect worked there. 2.7.0 broke it. Fix: default `lang` to null. The client's existing flow already handles null correctly — getParams() at pad.ts:172 has `if (serverValue == null) continue;`, so the forced-localize callback simply does not fire, and l10n.ts's browser-language auto-detect runs. Pad-settings dropdown consumer at pad.ts:489 already uses `padOptions.lang || 'en'` so null renders fine there too. `PadSettings.lang` is now typed `string | null` to match. Added three backend regression tests under `normalizePadSettings lang`: * defaults to null when lang is absent (so client auto-detects) * preserves an explicit string lang (creator override still works) * drops non-string lang values to null rather than coercing to 'en' Manual verification: with Firefox set to German, loading a fresh pad now renders the UI in German. Index and timeslider continued to work as before. Setting `?lang=de` or a language cookie continues to override browser detection, as intended. Fixes ether#7586
Review Summary by QodoRestore Accept-Language auto-detect on pad UI
WalkthroughsDescription• Restore browser locale auto-detection on pad UI by defaulting lang to null • Prevent hardcoded English from overriding Accept-Language and cookie settings • Add three regression tests for normalizePadSettings lang handling • Widen PadSettings.lang type to string | null for proper null handling Diagramflowchart LR
A["Pad.normalizePadSettings()"] -->|"lang default changed"| B["lang: null instead of 'en'"]
B -->|"client-side flow"| C["getParams() skips callback"]
C -->|"l10n auto-detect runs"| D["cookie → navigator.language → 'en'"]
E["Creator override lang='de'"] -->|"preserved as string"| F["Works as before"]
File Changes1. src/node/db/Pad.ts
|
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.
Summary
Fixes #7586. In v2.7.0 the pad UI stopped honouring the browser's Accept-Language / locale, always rendering English regardless of system language. The index page and the timeslider were unaffected; only the pad route regressed.
Root cause
The regression was introduced by #7545 ("Add creator-owned pad settings defaults"), which added this line to
Pad.normalizePadSettings():That default propagates into
clientVars.padOptions.lang. On the client,getParams()insrc/static/js/pad.tsreadspadOptions.langand fires the per-setting callback, which ishtml10n.localize([val, 'en']). So every pad forced English at load time, defeating the existing auto-detect chain insrc/static/js/l10n.ts:Fix
Default
langtonullinstead of'en'. The client-side flow already handles null correctly —getParams()atpad.ts:172short-circuits withif (serverValue == null) continue;, so the forced-localize callback simply doesn't fire, andl10n.ts's browser-language chain takes over. The pad-settings dropdown consumer atpad.ts:489already usespadOptions.lang || 'en'so it renders'en'visually when no override is set, matching prior behaviour.PadSettings.langis widened fromstringtostring | nullto match.Creator override (explicit
rawPadSettings.lang = 'de') continues to work — that's still a string, so it's preserved verbatim.Tests
Added three backend regression tests under
normalizePadSettings langintests/backend/specs/Pad.ts:nullwhenlangis absent (so client auto-detects)lang(creator override still works)langvalues tonullrather than coercing to'en'Test plan
mocha tests/backend/specs/Pad.ts— 23 passingtsc --noEmitclean in our code?lang=deURL param andlanguagecookie continue to override browser detection.🤖 Generated with Claude Code