Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ exact tag (`ghcr.io/calnode/calnode:0.1.0`) if you need stability between upgrad

### Added

- **German for the admin interface.** The SvelteKit admin now ships `de` alongside `en`
and `fr` (`frontend/src/lib/i18n/de.json`, formal *Sie*, terse). Like every non-English
catalogue it is a translation without a separate native review. Only English is bundled
now; `fr` and `de` are fetched when selected, so an English admin no longer downloads
them. The event-type preview's
end time now uses a 24-hour clock for every non-English admin locale, not only French.
- **Operator- and host-facing emails follow the configured fallback language.** The host
notifications (new booking, cancellation, reschedule), the login link, password reset,
team invitation and the email-settings test message now read their text from the booker
catalogue in the operator's fallback language (`server_settings.fallback_locale`). With no
fallback set, or English, the output is byte-identical to before. Attendee emails still
follow the attendee's own locale.
The new copy exists in English and German only. Where the fallback language is another
shipped locale (`fr`, `fr-CA`, `es`, `it`, `nl`, `pl`, `pt`, `sv`, `el`), these emails
mix languages: the greeting and field labels are translated, while the subject and lead
sentence fall back to English until that locale adds the 22 new keys (`email_host_*`,
`email_magic_*`, `email_reset_*`, `email_invite_*`, `email_test_*`, `email_link_paste`,
`email_ignore_unrequested`). Before, they were English throughout.
- **Delete a booking for an erasure request.** Owners and admins can now permanently remove a
booking from the Bookings list (trash icon, confirmation dialog; `DELETE /v1/bookings/{id}`).
It removes the booking with its attendees, answers, manage links and host assignments, plus the
Expand All @@ -49,14 +67,19 @@ exact tag (`ghcr.io/calnode/calnode:0.1.0`) if you need stability between upgrad
and an informal one would be wrong for everyone else. `de` is unchanged and stays formal.
The variant is never offered in the language switcher or matched from `Accept-Language`;
select it with `?lang=de-x-neutral` or `<calnode-booking lang="de-x-neutral">`.

- **Next available time on the booking page.** A per-event-type setting, off by default,
adds a button above the time list, such as "Next available: Wed, Nov 18, 10:00 AM", that
opens that day. It is worked out from the free times only, walks forward month by month
but never past `max_future_days`, and shows nothing when the availability check failed or
was degraded, rather than implying there is none. It appears on the booking and reschedule
pages and in the embed widget. Proposed in discussion #254.

### Changed

- **German booker wording.** A booking is now *verschoben* (moved) rather than *umgebucht*,
which reads as travel rebooking; a few other strings were made more idiomatic. The same
changes are mirrored in `de-x-neutral`.

### Fixed

- **Buttons and inputs in the booking UI now use the surrounding font.** Form controls
Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ one.
every key and any `{placeholders}` (including `{console}` / `{email}`-style link
slots rendered by `LinkedText` — do not turn catalog values into HTML). English is
the source of truth; missing keys fall back to English at runtime.
2. Register the new file in `frontend/src/lib/i18n/catalog.ts` (`catalogs` + `ADMIN_LOCALES`).
2. Register the new file in `frontend/src/lib/i18n/catalog.ts`: a dynamic import in
`loaders` (only English is bundled; the others load when the operator selects them)
and the display name in `ADMIN_LOCALES`.
3. Name the code the same way as booker locales: BCP-47 primary tag (`fr`, `de`).
4. The operator picks the language in Settings → Profile → Preferences (stored in
`localStorage`, with `navigator.languages` as the first-visit fallback).
Expand Down
26 changes: 20 additions & 6 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1303,23 +1303,30 @@ catalog. It deliberately stops at the LiveKit room and at content the operator w
| Booking page (`book.html`) | yes |
| Manage page (`manage.html`) - reschedule/cancel | yes |
| Embed widget (`embed.js`) | yes |
| The four emails (confirm / cancel / reschedule / reminder) | yes |
| The four emails (confirm / cancel / reschedule / reminder) | yes - in the booker's language |
| Host and operator emails (new-booking, cancellation and reschedule notices to the host; login link, password reset, team invitation, email-settings test) | yes - in the operator's fallback language |
| Calendar invite title + description | yes |
| Conversational booking assistant | yes (replies in the visitor's language) |
| **Admin SPA** (`frontend/`) | **yes** - `en` + `fr` (`frontend/src/lib/i18n/`); English is source of truth |
| **Admin SPA** (`frontend/`) | **yes** - `en` + `fr` + `de` (`frontend/src/lib/i18n/`); English is source of truth |
| **LiveKit room** (`livekit-room.html` + `livekit-room.js`) | **no** - see below |
| **Admin-authored content** (event names, descriptions, intake questions, custom email copy) | **no** - stored as the operator typed it |
| IANA timezone identifiers | no - shown as `Europe/Berlin`, not localized |

The admin SPA is a separate catalog from the booker locales. `frontend/src/lib/i18n/`
ships nested JSON (`en.json` source of truth, `fr.json` a native-speaker translation).
ships nested JSON (`en.json` source of truth, `fr.json` a native-speaker translation,
`de.json` a contributed translation without a separate native review).
`t` / `tr` look up a dotted key, interpolate `{placeholders}`, and fall back to English
then to the key itself. Locale resolution is client-side: a stored preference
then to the key itself. Only English is bundled; every other catalogue is a dynamic import
(`loadCatalog`) fetched when that locale is first selected, so an English admin never
downloads French or German. The locale store only switches once the catalogue is in, and the
root `+layout.ts` holds the first render until the starting locale's catalogue has loaded,
so nothing flashes in the wrong language. If the import fails, the locale still applies and
every string reads as English. Locale resolution is client-side: a stored preference
(`localStorage` key `calnode-admin-locale`, set from Settings → Profile → Preferences)
wins, then `navigator.languages` (`fr-CA` → `fr`), then English. Dates and times in the
admin use `Intl` with that tag; the operator's existing `date_format` / `time_format` /
`week_start` prefs still apply. Adding an admin locale is copy-the-JSON plus two
registrations in `catalog.ts` — see CONTRIBUTING.md.
registrations in `catalog.ts` (a loader and a display name) — see CONTRIBUTING.md.

**The LiveKit room is the remaining hole.** ~45 strings in the in-browser meeting UI
(join/leave, mute, screen share, recording banner, consent prompts, chat) are hardcoded
Expand Down Expand Up @@ -1349,7 +1356,14 @@ Per request, in `internal/handler/i18n.go`, highest priority first:
The booker's resolved locale is **persisted on the booking** (`booking_attendees.locale`,
migration 00051) so that later emails - reminders, cancellations, the reschedule notice -
arrive in the language they booked in, not the language of whoever triggered the send.
Host-facing sends deliberately pass a nil locale and stay English.
Host-facing sends never use the attendee's locale: the host notifications use the
**operator's language**, which is `server_settings.fallback_locale` (Settings → Branding).
`applyHostInvite`
sets it on `BookingData.HostLocale` for every host send (new booking, reschedule,
reassignment, cancellation), and the mailer swaps it in for `Locale`. The login link,
password reset, team invitation and the email-settings test message use it too
(`operatorLocale`). With no or an unknown fallback setting the locale is nil and these
emails are English.

Pages that vary on this send `Vary: Accept-Language, Cookie`; the public event-type JSON
endpoint adds it with `Header().Add` so it does not clobber the CORS middleware's
Expand Down
37 changes: 20 additions & 17 deletions docs/i18n-glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ not have to invent terminology that is already decided.

## Core terms

| Concept | English | French (booker) | French (admin) | Notes |
|---|---|---|---|---|
| booking (the object) | booking | réservation | réservation | Never "rendez-vous" for the object. |
| to book (verb) | book | réserver | réserver | |
| event type | event type | - | type de rendez-vous | **divergent**: the booker has no public name for it. |
| host | host | - | hôte | The booker addresses the booker, not the host. |
| attendee / booker | attendee | - | participant | Use "participant" in admin; the booker is "vous". |
| team | team | équipe | équipe | |
| team member | team member | membre de l'équipe | membre | |
| availability | availability | disponibilités | disponibilités | Plural in French. |
| slot / time slot | slot | créneau | créneau | |
| timezone | timezone | fuseau horaire | fuseau horaire | |
| reschedule | reschedule | reprogrammer | reprogrammer | Noun: "reprogrammation". |
| cancel | cancel | annuler | annuler | Noun: "annulation". |
| round robin | round robin | - | tourniquet | French admin uses "tourniquet"; do not calque "tourner entre eux". |
| reminder | reminder | rappel | rappel | |
| directory | directory | - | annuaire | Only the person and team pages. |
| Concept | English | French (booker) | French (admin) | German (booker) | German (admin) | Notes |
|---|---|---|---|---|---|---|
| booking (the object) | booking | réservation | réservation | Buchung | Buchung | Never "rendez-vous" for the object. |
| to book (verb) | book | réserver | réserver | buchen | buchen | |
| event type | event type | - | type de rendez-vous | - | Terminart | **divergent**: the booker has no public name for it. |
| host | host | - | hôte | Gastgeber | Gastgeber | The booker addresses the booker, not the host. |
| attendee / booker | attendee | - | participant | - | Teilnehmer | Use "participant" in admin; the booker is "vous". |
| team | team | équipe | équipe | Team | Team | |
| team member | team member | membre de l'équipe | membre | Teammitglied | Mitglied | |
| availability | availability | disponibilités | disponibilités | Verfügbarkeit | Verfügbarkeit | Plural in French. |
| slot / time slot | slot | créneau | créneau | Termin / Zeit | Zeitfenster | |
| timezone | timezone | fuseau horaire | fuseau horaire | Zeitzone | Zeitzone | |
| reschedule | reschedule | reprogrammer | reprogrammer | verschieben | verschieben | Noun: "reprogrammation". |
| cancel | cancel | annuler | annuler | stornieren | stornieren | Noun: "annulation". |
| round robin | round robin | - | tourniquet | - | Round Robin | French admin uses "tourniquet"; do not calque "tourner entre eux". |
| reminder | reminder | rappel | rappel | Erinnerung | Erinnerung | |
| directory | directory | - | annuaire | - | Verzeichnis | Only the person and team pages. |

## Register

Expand All @@ -46,6 +46,9 @@ not have to invent terminology that is already decided.
The existing booker locales are deliberately split by market: `fr`/`de`/`it`/`pt` formal,
`es`/`nl`/`sv` informal. Match the language, not the English.

German follows the same split: booker `de` formal (*Sie*), admin `de` formal and terse. A booking is
*verschoben* (moved), not *umgebucht*: the latter reads as travel rebooking.

`de-x-neutral` is the one exception, and it is a third option rather than a change of side:
German with no address at all (infinitive and nominal style, "Tag auswählen"), for
operators whose own site does not say *Sie*. It is opt-in and never offered to visitors, so
Expand Down
103 changes: 71 additions & 32 deletions frontend/src/lib/i18n/catalog.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import assert from 'node:assert/strict';
import { describe, test } from 'node:test';
import { before, describe, test } from 'node:test';
import en from './en.json' with { type: 'json' };
import fr from './fr.json' with { type: 'json' };
import de from './de.json' with { type: 'json' };

const TRANSLATIONS = { fr, de } as const;
import {
isAdminLocale,
loadCatalog,
loaders,
matchAdminLocale,
pluralForm,
resolveInitialLocale,
Expand All @@ -13,6 +18,12 @@ import {
translatePluralPair
} from './catalog.ts';

// Node cannot `import('./fr.json')` without an import attribute (and Vite's dev server
// rejects one with it), so hand the statically imported catalogues to the loader table.
// The real dynamic imports are exercised by store.test.ts in the browser suite.
loaders.fr = async () => ({ default: fr });
loaders.de = async () => ({ default: de });

const LINKED_SENTENCES: Record<string, string[]> = {
'calendar.noProvider.body': ['google'],
'settings.google.setup.step1': ['console'],
Expand Down Expand Up @@ -63,32 +74,55 @@ function flatten(obj: unknown, prefix = ''): Record<string, string> {
return out;
}

describe('admin i18n catalogs', () => {
test('French has the same keys as English', () => {
const enKeys = Object.keys(flatten(en)).sort();
const frKeys = Object.keys(flatten(fr)).sort();
assert.deepEqual(frKeys, enKeys);
/** Every [key, value] of English and all translations, keys prefixed with the catalog index. */
function allEntries(): [string, string][] {
return [en, ...Object.values(TRANSLATIONS)].flatMap((catalog, i) =>
Object.entries(flatten(catalog)).map(([k, v]): [string, string] => [`${i}:${k}`, v])
);
}

describe('lazy catalogues', () => {
// Runs before any other test loads `de`, so it sees the unloaded state.
test('a locale that is not loaded yet reads as English, then as itself once loaded', async () => {
assert.equal(translate('de', 'layout.nav.settings'), translate('en', 'layout.nav.settings'));
assert.equal(await loadCatalog('de'), true);
assert.equal(translate('de', 'layout.nav.settings'), de.layout.nav.settings);
assert.notEqual(translate('de', 'layout.nav.settings'), translate('en', 'layout.nav.settings'));
});

test('placeholders match between English and French', () => {
const ph = /\{(\w+)\}/g;
const names = (s: string) => new Set([...s.matchAll(ph)].map((m) => m[1]));
const enFlat = flatten(en);
const frFlat = flatten(fr);
const mismatches: string[] = [];
for (const [key, value] of Object.entries(enFlat)) {
const a = names(value);
const b = names(frFlat[key] ?? '');
if (a.size !== b.size || [...a].some((n) => !b.has(n))) {
mismatches.push(key);
}
}
assert.deepEqual(mismatches, []);
test('English needs no load', async () => {
assert.equal(await loadCatalog('en'), true);
});
});

describe('admin i18n catalogs', () => {
for (const [code, catalog] of Object.entries(TRANSLATIONS)) {
Comment thread
pullfrog[bot] marked this conversation as resolved.
Resolved
test(`${code} has the same keys as English`, () => {
const enKeys = Object.keys(flatten(en)).sort();
const keys = Object.keys(flatten(catalog)).sort();
assert.deepEqual(keys, enKeys);
});

test(`placeholders match between English and ${code}`, () => {
const ph = /\{(\w+)\}/g;
const names = (s: string) => new Set([...s.matchAll(ph)].map((m) => m[1]));
const enFlat = flatten(en);
const flat = flatten(catalog);
const mismatches: string[] = [];
for (const [key, value] of Object.entries(enFlat)) {
const a = names(value);
const b = names(flat[key] ?? '');
if (a.size !== b.size || [...a].some((n) => !b.has(n))) {
mismatches.push(`${code}:${key}`);
}
}
assert.deepEqual(mismatches, []);
});
}

test('catalogs do not bake "(s)" plurals', () => {
const baked: string[] = [];
for (const [key, value] of Object.entries({ ...flatten(en), ...flatten(fr) })) {
for (const [key, value] of allEntries()) {
if (/\w\(s\)/.test(value) && !value.includes('http(s)')) baked.push(key);
}
assert.deepEqual(baked, []);
Expand All @@ -97,11 +131,10 @@ describe('admin i18n catalogs', () => {
test('linked sentences keep the same {placeholders} in both locales', () => {
const ph = /\{(\w+)\}/g;
const names = (s: string) => [...s.matchAll(ph)].map((m) => m[1]);
const enFlat = flatten(en);
const frFlat = flatten(fr);
const flats = [en, ...Object.values(TRANSLATIONS)].map((catalog) => flatten(catalog));
const missing: string[] = [];
for (const [key, expected] of Object.entries(LINKED_SENTENCES)) {
for (const catalog of [enFlat, frFlat]) {
for (const catalog of flats) {
const got = names(catalog[key] ?? '');
if (expected.some((n) => !got.includes(n))) missing.push(key);
}
Expand All @@ -110,11 +143,10 @@ describe('admin i18n catalogs', () => {
});

test('link-text keys exist and are plain text', () => {
const enFlat = flatten(en);
const frFlat = flatten(fr);
const flats = [en, ...Object.values(TRANSLATIONS)].map((catalog) => flatten(catalog));
const bad: string[] = [];
for (const key of LINK_TEXT_KEYS) {
for (const catalog of [enFlat, frFlat]) {
for (const catalog of flats) {
const value = catalog[key] ?? '';
if (!value || /\{(\w+)\}/.test(value) || /<\/?a[\s>]/.test(value)) bad.push(key);
}
Expand All @@ -124,14 +156,16 @@ describe('admin i18n catalogs', () => {

test('catalogs do not embed HTML anchors', () => {
const html: string[] = [];
for (const [key, value] of Object.entries({ ...flatten(en), ...flatten(fr) })) {
for (const [key, value] of allEntries()) {
if (/<\/?a[\s>]/i.test(value) || /href\s*=/.test(value)) html.push(key);
}
assert.deepEqual(html, []);
});
});

describe('translate', () => {
before(() => loadCatalog('fr'));

test('returns the French string when the key exists', () => {
assert.equal(translate('fr', 'layout.nav.eventTypes'), 'Types de rendez-vous');
assert.equal(translate('fr', 'layout.nav.settings'), 'Paramètres');
Expand All @@ -156,15 +190,17 @@ describe('locale matching', () => {
test('isAdminLocale only accepts shipped codes', () => {
assert.equal(isAdminLocale('en'), true);
assert.equal(isAdminLocale('fr'), true);
assert.equal(isAdminLocale('de'), false);
assert.equal(isAdminLocale('ja'), false);
assert.equal(isAdminLocale('de'), true);
assert.equal(isAdminLocale('fr-CA'), false);
});

test('matchAdminLocale maps regional tags onto the primary language', () => {
assert.equal(matchAdminLocale('fr-CA'), 'fr');
assert.equal(matchAdminLocale('fr-FR'), 'fr');
assert.equal(matchAdminLocale('en-GB'), 'en');
assert.equal(matchAdminLocale('de-DE'), null);
assert.equal(matchAdminLocale('de-DE'), 'de');
assert.equal(matchAdminLocale('ja-JP'), null);
});

test('stored preference wins over the browser', () => {
Expand All @@ -174,8 +210,9 @@ describe('locale matching', () => {

test('browser language is used when nothing is stored', () => {
assert.equal(resolveInitialLocale(null, ['fr-CA', 'en']), 'fr');
assert.equal(resolveInitialLocale(null, ['de-DE', 'fr']), 'fr');
assert.equal(resolveInitialLocale(null, ['de-DE', 'ja']), 'en');
assert.equal(resolveInitialLocale(null, ['ja-JP', 'fr']), 'fr');
assert.equal(resolveInitialLocale(null, ['de-AT', 'fr']), 'de');
assert.equal(resolveInitialLocale(null, ['ja-JP', 'ko']), 'en');
});

test('unknown stored value falls through to the browser, then English', () => {
Expand Down Expand Up @@ -221,6 +258,8 @@ describe('pluralForm', () => {
});

describe('translatePlural', () => {
before(() => loadCatalog('fr'));

test('picks singular and plural member counts per locale', () => {
assert.equal(translatePlural('en', 'teams.memberCount', 1), '1 member');
assert.equal(translatePlural('en', 'teams.memberCount', 0), '0 members');
Expand Down
Loading
Loading