Skip to content

German without du/Sie as an opt-in variant, and inherited fonts on booking controls - #258

Open
portfoliomanufaktur wants to merge 2 commits into
Calnode:mainfrom
portfoliomanufaktur:de-neutral-and-button-font
Open

portfoliomanufaktur wants to merge 2 commits into
Calnode:mainfrom
portfoliomanufaktur:de-neutral-and-button-font

Conversation

@portfoliomanufaktur

Copy link
Copy Markdown

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 de
would 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 de untouched.

Font. Form controls do not inherit font-family; the browser stylesheet gives them
their 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

  1. fix(booking): booking.css gets button, input, select, textarea { font-family: inherit; } next to the reset. I used font-family rather than font: inherit on
    purpose: every control already sets its own size and weight, and font would also
    inherit line-height and change control heights. The rule is shared, so the hosted
    booking and manage pages get the same fix.
  2. i18n: new internal/i18n/locales/de-x-neutral.json. It is a full copy of de.json
    with the 38 strings that address the booker reworded (infinitive or nominal style).
    Dates, labels and everything else are identical.
  3. A private-use tag (-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-neutral or
    <calnode-booking lang="de-x-neutral">. A German browser still gets de.
  4. To make the variant reachable from the widget, embed.js now sends the lang
    attribute whole, and the server falls back from an unknown tag to its primary language
    (de-DE still selects de). The widget used to trim to the primary subtag itself,
    which also meant lang="fr-CA" loaded France French.
  5. Docs: the glossary's register section, CHANGELOG, and
    the opt-in status in make i18n-coverage.

Examples (de → de-x-neutral):

Key de de-x-neutral
select_day_hint Wählen Sie einen Tag, um verfügbare Zeiten zu sehen. Tag auswählen, um verfügbare Zeiten zu sehen.
required_fields_error Bitte füllen Sie alle Pflichtfelder aus. Bitte alle Pflichtfelder ausfüllen.
name_placeholder Ihr vollständiger Name Vollständiger Name
confirmation_email_sent Wir haben Ihnen eine Bestätigungs-E-Mail gesendet. Eine Bestätigungs-E-Mail wurde gesendet.
email_confirmed_lead Ihre Buchung ist bestätigt. Die Buchung ist bestätigt.

If you would rather have it differently

  • If you prefer the neutral wording as the German default, I am happy to fold it into
    de.json and drop the variant. That would be a much smaller PR (one JSON file).
  • The two commits are independent. The font fix can be merged on its own.

Known limitations

  • On the hosted pages, the footer language switcher has no entry for the variant, so with
    ?lang=de-x-neutral it shows its first option as selected. Partial locales below the
    coverage floor already behave this way.
  • The variant cannot be picked as fallback language in Settings → Branding, because that
    list comes from SupportedLocales(). The API accepts it.
  • The German wording has not been independently reviewed yet.

Testing

  • go test ./... is green (27 packages), go vet ./... and gofmt -l are clean,
    pnpm build and go build ./cmd/calnode succeed. node --test internal/handler/assets/*.test.js passes.
  • New tests: TestGermanNeutralVariant (the variant covers every key of de, contains no
    du/Sie pronoun, keeps the date data of de; the pronoun guard is checked against the
    formal catalogue so it cannot pass vacuously), TestOptInVariantIsNotOffered (absent
    from the switcher, no duplicate display names), new TestResolve cases (override by
    code, de-DE override falls back to de, plain de and de-DE browsers are
    unaffected), and TestBookingCSS_controlsInheritFontFamily.
  • pnpm test:visual was not run: the change does not touch frontend/.
  • Not yet verified in a browser. Before merging, the widget should be checked once with a
    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=de next to ?lang=de-x-neutral.

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.
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@portfoliomanufaktur

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Nov 18, 2026

@pullfrog pullfrog Bot 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.

ℹ️ 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) — IsOptInVariant treats a BCP-47 private-use code (-x-) as a wording variant: complete, but never appended to supported and never matched from Accept-Language, so it is reachable only by an exact code.
  • Override resolution — getOverride tries the exact code first, then the primary subtag, so fr-CA selects its own file and de-DE selects de; embed.js now forwards the host page's lang attribute whole instead of trimming it.
  • de-x-neutral catalogue — a full 169-key copy of de.json with 38 booker-addressing strings reworded to infinitive/nominal style; date tables and every other string identical.
  • Guards — TestGermanNeutralVariant (key parity with de, the pronoun regex plus a non-vacuous control against the formal file, date-table parity), TestOptInVariantIsNotOffered (absent from the switcher, unique display names), new TestResolve cases for regional and variant overrides, and TestBookingCSS_controlsInheritFontFamily.
  • Shared CSS — I checked the cascade in headless Chromium against a replica of the widget's :host block: with the new rule the controls compute to the host element's font, without it they stay Arial while 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-in status (plus a wider code column) in cmd/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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash | 𝕏

Comment thread internal/i18n/i18n.go
if l := Get(code); l != nil {
return l
}
if i := strings.IndexByte(code, '-'); i > 0 {

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.

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.

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