Skip to content

Set the organizer pages' html lang to the organizer's language - #1011

Merged
richshaw merged 3 commits into
mainfrom
claude/issue-938-organizer-html-lang
Nov 16, 2026
Merged

richshaw merged 3 commits into
mainfrom
claude/issue-938-organizer-html-lang

Conversation

@richshaw

@richshaw richshaw commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Fixes #938.

The problem

The organizer app (/app), sign-in (/login) and the AI assistant's consent screen (/oauth) shared one root layout, src/app/(organizer)/layout.tsx, which always rendered <html lang="en">. Once an organizer's screens are in their own language, the page would still tell screen readers and browser translation it's English. The layout's comment about #619 was out of date too.

The fix

How the layout chooses. The one root layout becomes three, one per area, each choosing the language its pages' text is already in:

Root layout <html lang> Reads
(organizer)/app/layout.tsx localeOfOrganizer(session): the organizer's stored language, else the site default, else English getOrganizerSession(), which every /app page already reads (cached per request)
(organizer)/oauth/layout.tsx the same, so OAuth consent is in the organizer's language the same, which the consent page already reads
(organizer)/login/layout.tsx signInLocale(): the site default, else English no session at all

The e2e run's E2E_UNSHIPPED_LOCALES is honoured through localeOfOrganizer, as the screens do.

Why split the layout, rather than one layout that looks at the request. A root layout can't see its path. The other ways to tell /login from /oauth were all worse:

  • reading the session in one layout for every page would start a session read on /login/check and /login/confirm (with a cookie), which read none today;
  • the middleware's ORGANIZER_CALLBACK_HEADER only covers /app, so it can't tell /login from /oauth without changing src/middleware.ts.

Splitting needs no change to src/middleware.ts or src/auth/, and no file moves: three small layout files replace one.

Statements. None added. /app and /oauth pages already call getOrganizerSession() (through requireOrganizerSession or directly), and it's wrapped in React cache(), so the layout shares the page's read. The sign-in layout calls signInLocale(), which reads only the environment. A unit test checks that the sign-in layout never calls getOrganizerSession.

Keeping it current.

  • Saving the account language. I checked this rather than assuming the issue's analysis was right. A server action that redirects renders the whole page it goes to, root layout included: Next 15.5 drops the router-state header for the redirect's render, and React then updates <html lang> in place. So setOrganizerLocaleAction already ends with the new lang and no reload, and I added no forced reload. To check it, I shipped sv locally (not committed) and saved Svenska, then English, in account Settings. <html lang> went en → sv → en, and a marker on window survived, so the page never reloaded.
  • Signing in. Magic link, code and provider sign-in were already top-level navigations. /login/check's SessionWatcher uses router.replace, which used to stay inside the shared layout. Now it crosses into another root layout, so the whole page loads. The new e2e test covers this.
  • Signing out. From the header, sign-out goes to /, a different root layout, so it was already a full load. From the consent screen's "switch account" and from the card for a signup that can't be loaded, it goes to /login, which now crosses root layouts too.

A side effect, fixed here. /login/page.tsx now sits in the same folder as its root layout, and Next doesn't apply a layout's title template to a page in that folder. So the page writes the site name into its tab title itself (title: { absolute: … }), the way s/[slug]/page.tsx already does. The tab still reads "Sign in · OpenSignup". This is the one edit under src/app/(organizer)/login/: a metadata change, nothing about sign-in itself.

Also: comments that said "three root layouts" (root-shell.tsx, global-not-found.tsx, next.config.mjs, root-layouts.spec.ts), CLAUDE.md's Routes paragraph, and the signup header layout's note that cited #938 for a "full page load". There's also a CHANGELOG entry. Nothing changes for anyone while only English ships: every page still says en.

Where the issue was out of date. It was written before #898 and the locale helpers landed. The helper is localeOfOrganizer, the sign-in pages use signInLocale() rather than defaultFor(…), and saving the language didn't need a forced full load (above).

Tests

  • New unit test, src/app/(organizer)/root-layouts.test.tsx. For each non-English catalog language, it covers the app and consent layouts: signed in with a stored language, signed in with none, signed out with and without a site default, English while unshipped, and an E2E_UNSHIPPED_LOCALES language kept. For the sign-in layout it covers: the site default whoever is signed in, English while unshipped, and no session read. As a check, I swapped the consent layout to signInLocale() and the test failed.
  • e2e, organizer-language.spec.ts:
    • a new test: a Swedish organizer (E2E_UNSHIPPED_LOCALES=sv) gets <html lang="sv"> on /app. Signed in, /login/check says en, the site default. Moving on to /app loads the whole page in sv;
    • the consent test checks <html lang>;
    • the share panel's language check now runs on a phone too (its sheet sits outside the page's wrapper, so it used to be skipped "until Organizer pages say lang="en" on <html> whatever the organizer's language #938").
  • e2e, other specs: sign-in-text.spec.ts checks <html lang="en"> on /login, check and confirm. organizer-language-story.spec.ts checks it on Your signups, and after saving the language once one ships.

Commands run, all passing:

  • pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test: 240 files, 3438 tests.
  • pnpm test:db: 47 files, 857 tests, including query-budget.db.test.ts.
  • pnpm build && pnpm budgets: no page over budget. The layouts are server components, so there's no client JavaScript in them.
  • pnpm test:e2e --project=chromium on organizer-language, organizer-language-story, sign-in-text, oauth-consent, a11y, root-layouts, login-form and login-code: 60 passed. The 2 skips are Magic Compose's questions, which skip with no LLM_BASE_URL.
  • The new and changed organizer-language tests at phone width (Pixel 7 in Chromium; there's no WebKit here): 6 passed.
  • With sv shipped locally (not committed), the story spec's new checks after Save passed. The run then timed out further on, at a dev-server compile.

Repeated runs tripped the per-IP OAuth limit once; I cleared rate_limits in my own test database and reran.

🤖 Generated with Claude Code

https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt

The organizer app, sign-in and the AI assistant's consent screen shared
one root layout that always said lang="en". They now have one each:
/app and /oauth say the organizer's language (localeOfOrganizer, from
the session their pages read anyway, so no new statement), and /login
says the site default (signInLocale), reading no session, so the check
and confirm pages still start no session read. Moving between them is
now a full page load, which also brings the right language after
signing in or out. Saving the language in account Settings already
updates <html lang>: a server action's redirect renders the whole page,
root layout included.

/login now shares its folder with its root layout, which drops the
layout's title template there, so the page writes the site name into
its tab title itself, as a signup's page does.

Fixes #938.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
@richshaw richshaw added pipeline:tophat pipeline:ux Changes what a person using OpenSignup sees or does pipeline:working A session is working on it right now labels Nov 16, 2026 — with Claude
@richshaw
richshaw requested a balanced review from Copilot November 16, 2026 16:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@richshaw richshaw changed the title Give organizer pages the organizer's language on <html lang> Set the organizer pages' html lang to the organizer's language Nov 16, 2026

Copy link
Copy Markdown
Owner Author

Tophat: passed

Ran 4aaf05e locally with pnpm dev (then next start on a build for the e2e run and a repeat of the navigation checks), Postgres 16, Chromium at 1280×900 and 390×844. main at 40f9206 ran beside it on the same database for comparison. A Swedish organizer means sv stored on the account with E2E_UNSHIPPED_LOCALES=sv. To tell a full page load from a client-side one, I set a marker on window before each navigation and checked whether it survived.

Check Result What I saw
English organizer, every organizer page ✅ Desktop and phone, 13 signed-in pages: Your signups, New signup, Settings, Connected apps, a signup's Build, Edit, Responses, Settings and Preview, a missing signup's card, /login/confirm and an expired consent request. Signed out: /login, /login/check, /login/confirm and the redirects from /app and /oauth. Every page says lang="en", and each tab title and h1 matches main. I pixel-diffed 52 screenshot pairs against main. The only differences are the commit hash in the footer and the dev server's badge. /login still reads "Sign in · OpenSignup (local)".
Swedish organizer, /app ✅ Every /app page above says lang="sv" on desktop and on phone. On main the same Swedish screens say lang="en", so the bug reproduces there and is gone here (1011-before-sv-desktop-app, 1011-after-sv-desktop-app). /login/confirm while signed in stays en, the language its text is in.
Saving the account language ✅ With sv shipped locally (not committed), I saved English, then Svenska, then English in account Settings, on desktop and phone. <html lang> and the header went en → sv → en, the notice read "Saved" / "Sparat", the tab title followed, and the window marker survived, so nothing reloaded. A link on to Your signups afterwards kept the saved language.
Sign-in pages and DEFAULT_LOCALE ✅ With no DEFAULT_LOCALE, all three pages say en. With DEFAULT_LOCALE=sv and sv unshipped but listed in E2E_UNSHIPPED_LOCALES, /login, /login/check and /login/confirm still say en, with English text, on desktop and phone. That's signInLocale(): the site default counts only once it has shipped, and the PR's unit test "are English while only English has shipped" says the same. The PR's table says "the site default, else English" without "once shipped", but the CHANGELOG entry covers it. With sv shipped locally and DEFAULT_LOCALE=sv, all three say sv, the text is Swedish and the tab title is "Logga in · OpenSignup (local)". An organizer with no stored language got en on /app in the first setup and sv in the second.
OAuth consent ✅ Reached through /api/oauth/authorize with the e2e-client static client, as oauth-consent.spec.ts does it. A Swedish organizer gets lang="sv" and an English one en, on desktop and phone. main says en for both. Signed out, the request goes to /login (en). After the magic link it lands on the consent screen in sv, in both the tab that waited and the tab with the link.
Navigation across the new root layouts ✅ Each of these is a full load, lands in the right language and logs no console error. Every one except the magic-link sign-in also passed on the production build. Signing in from /login: the tab that waits moves on to /app (on main the marker survived this move). /login/check while signed in: moves on to /app/settings. Signed out on /app/signups/<id>/build?from=…: goes to /login?callbackUrl=…, then after sign-in back to that exact page with its query. Sign out from the header: goes to / (desktop, and the phone header). "Sign in with a different email" on a missing signup's card and "Sign in as someone else" on consent: both go to /login?callbackUrl=…. /oauth → /app: the consent screen's Connected apps link exists and does a full load, and Back returns to the consent screen in sv. Within /app: the breadcrumb stays a client-side navigation. Flash: I captured 142 frames across /login/check → /app on the build. The old page stays painted until the new one, with no blank frame and no layout jump.
Statements ✅ I logged statements for this database in Postgres and sent the same requests to the PR and to main. With a session cookie, /login/check, /login/confirm and signed-out /login sent 0 statements on both. Other pages, PR / main: /app 3 / 3, /app/settings 2 / 2, Build 9 / 9, Preview 8 / 8, expired consent 2 / 2.
e2e ✅ Ran a11y, organizer-language, organizer-language-story, sign-in-text, oauth-consent, root-layouts, login-form and login-code in Chromium against the build: 60 passed, and the 2 skips are Magic Compose's questions (no LLM_BASE_URL). At phone width (Pixel 7, 390 wide), organizer-language, sign-in-text, root-layouts and login-form: 45 passed, 2 skipped (the same Magic Compose questions). pnpm budgets passes, and root-layouts.test.tsx plus the /login unit tests pass (69).
Unmatched addresses ✅ /app/x, /login/x, /oauth/x and /oauth each get the site's 404 page with lang="en".

For the owner. Nothing looks different today. Only English has shipped, so every organizer page still says en, and the screens and tab titles are pixel-identical to main. One thing does change. Going between the organizer app, sign-in and the consent screen is now a full page load: when the sign-in tab moves on, when signing out to /login, and on the consent screen's Connected apps link. I couldn't see it happen: no blank flash, no error, no lost place. Once a second language ships, the organizer app and the consent screen tell screen readers and browser translation the organizer's language. The sign-in pages use the site's default language. The PR also edits src/app/(organizer)/login/page.tsx, the tab title's metadata only. The issue's gate sends any edit to sign-in code to you. Screenshots: 1011-after-sv-desktop-app and 1011-before-sv-desktop-app show <html lang> printed on the page, after and before. 1011-after-sv-phone-settings, 1011-after-sv-phone-consent, 1011-after-en-desktop-app and 1011-after-signedout-phone-login show the other pages.

Screenshots are in https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt


Generated by Claude Code

@richshaw richshaw added pipeline:review pipeline:working A session is working on it right now and removed pipeline:tophat pipeline:working A session is working on it right now labels Nov 16, 2026 — with Claude

@richshaw richshaw left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: passed (round 1)

The PR replaces the one (organizer) root layout with three, so /app and /oauth put the organizer's language on <html lang> (localeOfOrganizer, from the session their pages already read) and /login puts the site default there (signInLocale(), no session). It does what #938 asks, and I found nothing that has to change.

  • The split is the simple way. Each layout is one line of code plus the shared rootMetadata and rootViewport. One layout that read the session would start a session read on /login/check and /login/confirm, which #938's "Watch for" rules out. Telling the areas apart by path would mean editing src/middleware.ts. No file moved, so the path lists in eslint.config.mjs and no-hard-coded-text.test.ts still cover everything (the new layouts hold no text).
  • <html lang> is right in each case. Signed in with a stored language, signed in with none, signed out (site default once shipped, else en), and the e2e run's unshipped languages all go through localeOfOrganizer, the same function the screens use, so the attribute can't disagree with the text. root-layouts.test.tsx covers each case for the app and consent layouts, and that the sign-in layout calls getOrganizerSession zero times.
  • Full page loads. The moves that now cross a root layout are SessionWatcher's router.replace on /login/check, the redirect to /login?callbackUrl=… from requireOrganizerSession and from the consent page, sign-out to /login, and the consent screen's two <Link>s to /app and /app/settings/connected-apps. Next turns each into a full load. Code redemption already used window.location.assign, the magic link was already a top-level navigation, and the send-link action's move from /login to /login/check stays inside the sign-in layout. No callbackUrl handling changed.
  • /login's tab title. { absolute: ${t('tabTitle')} · ${INSTANCE_NAME} } gives the same string the template %s · ${INSTANCE_NAME} gave. It's the only edit to an existing file under login/, and it's metadata only. /login/check, /login/confirm, (chrome)/page.tsx and the consent page sit below their layouts, so they keep the template.
  • Issue outline. Every "Fix" and "Done when" item is done. The one departure is explained and tested: saving the language needs no forced reload, because the action's redirect renders the root layout again.

Blocking (0): none.

Optional (2):

  • src/app/(organizer)/app/layout.tsx and src/app/(organizer)/oauth/layout.tsx are the same code under different comments. A (organizer)/(signed-in)/ group holding both would make it one file and keep the consent screen's links to /app client-side, but it moves two folders and every path list with them. Not worth it now.
  • The tab title's · ${INSTANCE_NAME} is now written in three places: root-shell.tsx's template, tabTitle in src/app/s/[slug]/page.tsx:31 and src/app/(organizer)/login/page.tsx:29. One exported helper beside rootMetadata would stop them drifting.

Earlier threads: none. Copilot answered that it couldn't review (quota).

Checks: CI is green on 4aaf05e (lint-type-test, e2e, CodeQL). Locally on 4aaf05e: pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test passed (240 files, 3438 tests); pnpm test:db passed on a fresh migrated database (47 files, 857 tests); pnpm build && pnpm budgets passed, with /login at 109.1 kB of 110 and no budget changed. The tophat passed on this same commit, so no runtime code has changed since.

Gate: owner. Two reasons. It's a UX change (pipeline:ux): moving between the organizer app, sign-in and the consent screen is now a full page load, and once a second language ships these pages announce it. And it edits src/app/(organizer)/login/page.tsx, a sign-in path, which #938's own gate sends to the owner. There is no pipeline-owner-approved marker on this PR, so the review doesn't assume one. Worth a look: the tophat's 1011-before-sv-desktop-app and 1011-after-sv-desktop-app, and its navigation row (sign-in tab moving on, sign-out, the consent screen's Connected apps link).

https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt


Generated by Claude Code

@richshaw richshaw added pipeline:owner Passed; waits for the owner (UX or high-risk) and removed pipeline:review pipeline:working A session is working on it right now labels Nov 16, 2026 — with Claude

Copy link
Copy Markdown
Owner Author

The owner approved building and merging this with the rest of the launch work under #619, in the orchestrating session on 16 November 2026: "Build #938, the participant <html lang>, #935/#952 through tophat and review, merge them as they pass."

The tophat (6923578922) and the review (5924356797) both passed on 4aaf05e. Next I bring the branch up to date with main (merges only), then squash it once CI is green.

https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt


Generated by Claude Code

@richshaw richshaw added pipeline:merge pipeline:working A session is working on it right now and removed pipeline:owner Passed; waits for the owner (UX or high-risk) labels Nov 16, 2026 — with Claude
@richshaw
richshaw merged commit d226aa7 into main Nov 16, 2026
5 checks passed
@richshaw
richshaw deleted the claude/issue-938-organizer-html-lang branch November 16, 2026 17:38
@richshaw richshaw removed pipeline:merge pipeline:ux Changes what a person using OpenSignup sees or does pipeline:working A session is working on it right now labels Nov 16, 2026 — with Claude
richshaw pushed a commit that referenced this pull request Nov 16, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
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.

Organizer pages say lang="en" on <html> whatever the organizer's language

3 participants