Repository navigation
German without du/Sie as an opt-in variant, and inherited fonts on booking controls - #258
portfoliomanufaktur wants to merge 2 commits into
Conversation
Buttons, inputs, selects and textareas take their font family from the UA
stylesheet, so in the booking UI the day cells, time slots, back link and
confirm button rendered in the system UI font next to text in the page font.
It is most visible in the embed widget: an embedder who sets
`calnode-booking { font-family: ... }` got the brand font on headings and
labels but on none of the controls.
Only font-family is inherited. Every control already sets its own size and
weight, and `font: inherit` would also inherit line-height and change control
heights.
German booking pages currently say Sie, which the glossary records as a
deliberate choice. An operator whose own site says du then embeds a widget
that switches register mid-page, and making `de` informal would be wrong for
everyone else. German UI copy is commonly written with no address at all
("Tag auswählen" rather than "Wählen Sie einen Tag"), so this adds that as a
separate catalogue and leaves `de` untouched.
A private-use tag (-x-) is treated as an opt-in wording variant: it is not
listed in the switcher (it would show "Deutsch" twice), not matched from
Accept-Language, and reached only by an explicit code.
To make it reachable from the widget, the `lang` attribute is now sent whole
and the server falls back from an unknown tag to its primary language. The
widget used to trim to the primary subtag itself, which also made
lang="fr-CA" load France French.
|
All contributors have signed the CLA. ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
ℹ️ Two follow-ups worth a look; neither blocks merge.
Approach: sound — a register variant reuses the existing per-request locale plumbing and the one-file-per-catalogue mechanism, is kept out of every visitor-facing list, and the font fix lands once in the shared stylesheet rather than in each of the three surfaces.
Reviewed changes
- Opt-in variants (
internal/i18n/i18n.go) —IsOptInVarianttreats a BCP-47 private-use code (-x-) as a wording variant: complete, but never appended tosupportedand never matched fromAccept-Language, so it is reachable only by an exact code. - Override resolution —
getOverridetries the exact code first, then the primary subtag, sofr-CAselects its own file andde-DEselectsde;embed.jsnow forwards the host page'slangattribute whole instead of trimming it. de-x-neutralcatalogue — a full 169-key copy ofde.jsonwith 38 booker-addressing strings reworded to infinitive/nominal style; date tables and every other string identical.- Guards —
TestGermanNeutralVariant(key parity withde, the pronoun regex plus a non-vacuous control against the formal file, date-table parity),TestOptInVariantIsNotOffered(absent from the switcher, unique display names), newTestResolvecases for regional and variant overrides, andTestBookingCSS_controlsInheritFontFamily. - Shared CSS — I checked the cascade in headless Chromium against a replica of the widget's
:hostblock: with the new rule the controls compute to the host element's font, without it they stayArialwhile the heading is already branded, so the reported bug is real and the rule is what fixes it. - Docs and tooling — CHANGELOG, the glossary's register paragraph, and an
opt-instatus (plus a wider code column) incmd/i18n-coverage.
ℹ️ The neutral register stops at the booking assistant
The variant exists so that no surface addresses the booker as du or Sie, yet the chat assistant is told only to Reply in German — EnglishName() cannot carry a register, and assistantBaseRules says nothing about address. On a de-x-neutral page the greeting is neutral while every assistant reply is whatever register the model happens to pick, which is the mid-page switch the variant is meant to remove.
Technical details
# Assistant reply register is unconstrained for wording variants
## Affected sites
- `internal/handler/booking_assistant.go:298` — `replyLang := i18n.Resolve("", lang).EnglishName()` collapses `de-x-neutral` to "German".
- `internal/handler/booking_assistant.go:301` — the only register-relevant directive is `Reply in %s, regardless of what language the visitor writes in.`
- `internal/handler/booking_assistant.go:63` — `assistantBaseRules` (code-owned) has no address/register rule to lean on.
## Required outcome
- An assistant reply on a `de-x-neutral` page must not address the visitor in du or Sie — or the docs must state that chat is deliberately out of scope for the variant.
- `assistantBaseRules` stays code-owned; the admin's "Additional instructions" remains the only editable hook, and the existing `Reply in %s` path is unchanged for `de`/`es`/….
## Suggested approach (optional)
- Branch the directive on `i18n.IsOptInVariant(loc.Code)` and emit an explicit clause instead of relying on the language name, e.g. "use no second-person address; infinitive or nominal phrasing, matching the page copy".ℹ️ ARCHITECTURE §23 still describes the pre-PR resolution and file rules
docs/ARCHITECTURE.md §23 is what CLAUDE.md points at for the full i18n story, and all three statements this PR changes live there: the override is documented as an exact supported code (no regional or private-use fallback), "Adding a language is adding one file … no Go, no template, no frontend edit" (a -x- file is now silently opt-in), and the guard list names three tests where the file now has five. A maintainer adding a -x- catalogue or debugging ?lang=de-DE will read the old rules.
Technical details
# ARCHITECTURE §23 not updated for opt-in variants
## Affected sites
- `docs/ARCHITECTURE.md` §23, "How a locale is resolved" — step 1 describes `?lang=<code>` only; `getOverride` now also accepts a tag whose primary subtag has a file.
- `docs/ARCHITECTURE.md` §23, "Adding a language is adding one file" — a private-use filename is complete but never offered; that exception (and the switcher / fallback-API consequences the PR already documents) is unmentioned.
- `docs/ARCHITECTURE.md` §23, "Three guards police a new file" — `TestGermanNeutralVariant` and `TestOptInVariantIsNotOffered` are not listed.
## Required outcome
- §23 matches the code: exact-then-primary override semantics, the `-x-` opt-in convention with its `SupportedLocales()` exclusion, and the updated guard list.
## Notes
- The glossary (`docs/i18n-glossary.md`) and CHANGELOG additions are accurate as written.deepseek-v4.1-flash | 𝕏
| if l := Get(code); l != nil { | ||
| return l | ||
| } | ||
| if i := strings.IndexByte(code, '-'); i > 0 { |
There was a problem hiding this comment.
getOverride widens what an explicit override accepts, but persistLangOverride (internal/handler/i18n.go:52) still requires an exact i18n.Get(code), so the new half of the contract is not sticky: ?lang=de-DE now renders German and then flips back on the next navigation, because no cookie was written. Either share this lookup with the persister, or say in the doc comment that regional overrides are deliberately not persisted.
Technical details
# Regional/private-use overrides do not persist
## Affected sites
- `internal/i18n/i18n.go:228` — the new primary-subtag fallback.
- `internal/handler/i18n.go:52` — `if code == "" || i18n.Get(code) == nil { return }` still gates persistence on an exact file.
## Required outcome
- A `?lang=` value that renders a language is the value persisted to `calnode_lang`, or the asymmetry is documented as intentional.
## Suggested approach (optional)
- Export the resolver (e.g. `i18n.LookupOverride`) and use it from both call sites; persist the resolved code (`Resolve("", code).Code`) so `de-DE` stores `de` rather than a tag with no file.
Motivation
We embed the booking widget on a German site and ran into two things.
Register. The German catalogue addresses the booker as Sie. The glossary records
that as a deliberate choice, and it is the right default. On a site that says du,
though, the widget switches register in the middle of the page, and an informal
dewould be just as wrong for the next operator. German UI copy is very often written with
no address at all ("Tag auswählen", "Bitte erneut versuchen"), which fits both kinds of
site. This PR adds that wording as a separate catalogue and leaves
deuntouched.Font. Form controls do not inherit
font-family; the browser stylesheet gives themtheir own. Inside the widget, an embedder who sets
calnode-booking { font-family: … }gets the brand font on headings and labels, while day cells, time slots, the back link
and the confirm button stay in the system font.
Changes
fix(booking):booking.cssgetsbutton, input, select, textarea { font-family: inherit; }next to the reset. I usedfont-familyrather thanfont: inheritonpurpose: every control already sets its own size and weight, and
fontwould alsoinherit
line-heightand change control heights. The rule is shared, so the hostedbooking and manage pages get the same fix.
i18n: newinternal/i18n/locales/de-x-neutral.json. It is a full copy ofde.jsonwith the 38 strings that address the booker reworded (infinitive or nominal style).
Dates, labels and everything else are identical.
-x-) is treated as an opt-in wording variant(
i18n.IsOptInVariant): not listed in the switcher (it would show "Deutsch" twice,since display names ignore private-use subtags), not matched from
Accept-Language,and reached only by code:
?lang=de-x-neutralor<calnode-booking lang="de-x-neutral">. A German browser still getsde.embed.jsnow sends thelangattribute whole, and the server falls back from an unknown tag to its primary language
(
de-DEstill selectsde). The widget used to trim to the primary subtag itself,which also meant
lang="fr-CA"loaded France French.the
opt-instatus inmake i18n-coverage.Examples (
de→de-x-neutral):dede-x-neutralselect_day_hintrequired_fields_errorname_placeholderconfirmation_email_sentemail_confirmed_leadIf you would rather have it differently
de.jsonand drop the variant. That would be a much smaller PR (one JSON file).Known limitations
?lang=de-x-neutralit shows its first option as selected. Partial locales below thecoverage floor already behave this way.
list comes from
SupportedLocales(). The API accepts it.Testing
go test ./...is green (27 packages),go vet ./...andgofmt -lare clean,pnpm buildandgo build ./cmd/calnodesucceed.node --test internal/handler/assets/*.test.jspasses.TestGermanNeutralVariant(the variant covers every key ofde, contains nodu/Sie pronoun, keeps the date data of
de; the pronoun guard is checked against theformal catalogue so it cannot pass vacuously),
TestOptInVariantIsNotOffered(absentfrom the switcher, no duplicate display names), new
TestResolvecases (override bycode,
de-DEoverride falls back tode, plaindeandde-DEbrowsers areunaffected), and
TestBookingCSS_controlsInheritFontFamily.pnpm test:visualwas not run: the change does not touchfrontend/.custom font on the host element and with
lang="de-x-neutral".Screenshots
To be added before/after: the embedded widget on a page with a custom font (calendar,
time slots, form), and the booking page with
?lang=denext to?lang=de-x-neutral.