Repository navigation
Description
Needs your OK: this adds a language to each organizer's account, used for their new signups now and for the app itself later. Nothing shows until Swedish ships; the privacy page says we store it. Swap pipeline:proposed for pipeline:ready to have it built.
What happens
New signups should start in their organizer's language (the next step in #619), and later the app should use it too. There's nowhere to keep it:
- The browser's
Accept-Languageis a weak guess. Many Swedes run their phones in English. - AI assistants have no browser at all. They create signups through MCP.
Fix, in outline
-
organizers.locale: a nullable text column, added with a Drizzle migration. It's lenient like the signup's (A signup has no language, and an instance has no default language #625). -
getOrganizerLocale(session, acceptLanguage | null)insrc/i18n/organizer.tsworks out the effective language, in this order:- the saved value;
DEFAULT_LOCALE, when the operator set it (A signup has no language, and an instance has no default language #625);- on a browser request, the browser's top-ranked
Accept-Languagelanguage, if it's shipped (only the top one: normal negotiation would matchsv,en;q=0.8to English); - English.
Each step is filtered by the audience's
SHIPPEDlist. -
No new query.
OrganizerSessiongainslocale, selected in the queryloadOrganizerSessionByIdalready runs (src/auth/organizer-session.ts). It travels throughgetOrganizerSession()to routes, and throughBearerResolution(src/auth/bearer.ts) into the MCPToolContext(src/mcp/context.ts), because tool handlers may not query the database themselves. -
MCP passes
nullfor the browser. An assistant'sAccept-Languageis the vendor's, not the organizer's. -
updateOrganizerLocale(db, actor, locale)lets an organizer change only their own. The value must be inSHIPPED.participant. -
Account Settings gets "Language for new signups", rendered only when
SHIPPED.participanthas more than one entry. -
The privacy page says we store the organizer's language setting, and its "Last updated" date moves.
Watch for
- Keep it out of
src/i18n/server.ts. The worker imports that file undertsx, andgetOrganizerLocalemay neednext/headers. - Sign-in and bearer code go to the owner as high risk.
- Tests that build
OrganizerSessionby hand gain the field:src/auth/bearer.test.ts,src/oauth/flow.db.test.tsandsrc/app/app/signups/[id]/preview/page.test.tsx. - The Auth.js adapter and the e2e seed's organizer insert are unaffected by a nullable column.
Choices this makes
- Store it on the organizer, not in a cookie. Default: a column. It works without a browser, follows them across devices, and needs no cookies-page change.
- One setting for new signups now and the app later. Default: one. Someone who wants the app in English but signups in Swedish changes each signup's language in its Settings tab; a second setting can come if people ask for it.
- The order: saved →
DEFAULT_LOCALE→ the browser's first language → English.
Order
After #625, because defaultFor, DEFAULT_LOCALE and the lenient-language rule come from it.
Done when
- Unit tests cover every step of the order, including MCP's
nulland asv,en;q=0.8browser before Swedish ships. - A db test shows
loadOrganizerSessionByIdreturnslocalewith no extra statement. pnpm lint && pnpm typecheck && pnpm knip && pnpm testandpnpm test:dbpass.
Planned with the owner in https://claude.ai/code/session_01EFKmj716ZY3b3SwR8TV8Y2 and checked against the code on main at 35288fa. The full plan is private to the owner's account: https://claude.ai/artifact/VgQH6U2s2EVx3LX991fJi8 (a Claude session on that account can open it with the Artifact tool's read action). This is part of step 1.1 there.
Activity