Skip to content

feat(blog): remember the chosen post language across visits - #42

Merged
leinss merged 1 commit into
releasefrom
feature/langpersist
Aug 18, 2026
Merged

feat(blog): remember the chosen post language across visits#42
leinss merged 1 commit into
releasefrom
feature/langpersist

Conversation

@leinss

@leinss leinss commented Aug 18, 2026

Copy link
Copy Markdown
Owner

What changed

The blog index toggles between English and German panels client-side, but reset
to English on every arrival, so a German reader re-selected the language every
visit. The theme already persisted; the language now does too.

  • The choice is stored under blogLang on click and restored on init.
  • Only a language that still has a panel is restored. A stored value can
    outlive the posts it pointed at, and restoring it blindly would hide every
    panel and leave an empty page.
  • Reads and writes are guarded, because localStorage throws rather than
    returning null when a browser blocks storage, and a toggle that stops
    working is a worse outcome than one that forgets.

Test plan

  • pnpm build succeeds, 82 pages, internal link check clean
  • pnpm lint clean
  • Switch to German on the blog index, reload, and confirm German is still
    selected; clear the key and confirm it falls back to English

The blog index toggles between English and German panels client-side but
reset to English on every visit, so a German reader re-selected the
language on every arrival. The theme already persists; the language now
does too.

- Store the choice under `blogLang` on click and restore it on init
- Only restore a language that still has a panel, so a stored value that
  outlives its posts cannot hide every panel and leave an empty page
- Guard reads and writes: localStorage throws rather than returning null
  when a browser blocks storage, and a toggle that stops working is worse
  than one that forgets
@leinss
leinss merged commit 7f26b1f into release Aug 18, 2026
2 checks passed
@leinss
leinss deleted the feature/langpersist branch August 18, 2026 09:37
leinss added a commit that referenced this pull request Aug 19, 2026
The blog index toggles between English and German panels client-side but
reset to English on every visit, so a German reader re-selected the
language on every arrival. The theme already persists; the language now
does too.

- Store the choice under `blogLang` on click and restore it on init
- Only restore a language that still has a panel, so a stored value that
  outlives its posts cannot hide every panel and leave an empty page
- Guard reads and writes: localStorage throws rather than returning null
  when a browser blocks storage, and a toggle that stops working is worse
  than one that forgets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant