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
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,29 @@ 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. 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.
- **German without du or Sie (`de-x-neutral`).** An opt-in wording variant of the German
booker catalogue that addresses nobody: "Tag auswählen" rather than "Wählen Sie einen
Tag". It is for operators whose own site is informal, where the formal widget stands out
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">`.

### 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
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
75 changes: 44 additions & 31 deletions frontend/src/lib/i18n/catalog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import assert from 'node:assert/strict';
import { 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,
matchAdminLocale,
Expand Down Expand Up @@ -63,32 +66,41 @@ function flatten(obj: unknown, prefix = ''): Record<string, string> {
return out;
}

/** 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('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);
});
for (const [code, catalog] of Object.entries(TRANSLATIONS)) {

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.

Only this node:test copy was converted to iterate every translation. CI runs pnpm test:visual (vitest), which excludes catalog.test.ts and runs i18n.test.ts — still hardcoding fr for key parity, placeholders, plurals and anchors. So de.json has no CI guard, and the claim that tests cover every translation holds only for the suite CI does not run; mirror the TRANSLATIONS loop into i18n.test.ts.

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 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);
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, []);
});
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 +109,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 +121,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,7 +134,7 @@ 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, []);
Expand Down Expand Up @@ -156,15 +166,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 +186,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
6 changes: 4 additions & 2 deletions frontend/src/lib/i18n/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@

import en from './en.json' with { type: 'json' };
import fr from './fr.json' with { type: 'json' };
import de from './de.json' with { type: 'json' };

export const ADMIN_LOCALES = [
{ code: 'en', name: 'English' },
{ code: 'fr', name: 'Français' }
{ code: 'fr', name: 'Français' },
{ code: 'de', name: 'Deutsch' }
] as const;

export type AdminLocale = (typeof ADMIN_LOCALES)[number]['code'];
Expand All @@ -22,7 +24,7 @@ export const STORAGE_KEY = 'calnode-admin-locale';

type Catalog = Record<string, unknown>;

const catalogs: Record<AdminLocale, Catalog> = { en, fr };
const catalogs: Record<AdminLocale, Catalog> = { en, fr, de };

const localeSet = new Set<string>(ADMIN_LOCALES.map((l) => l.code));

Expand Down
Loading
Loading