feat(web): Paraglide v2 i18n infrastructure (en/de/da, cookie locale, app chrome) #1178

Merged
chris merged 1 commit from feature/i18n-paraglide-infra into main 2026-10-13 01:21:32 +02:00
Owner

Summary

Wave 1 of the frontend i18n rollout: Paraglide v2 infrastructure + app chrome only. Bulk component extraction (~1,000–1,500 sites) is planned in later waves — see apps/web/src/lib/i18n/EXTRACTION.md.

Infrastructure

  • Paraglide v2 (@inlang/paraglide-js 2.27) via the Vite plugin. Locales: en (base), de, da.
  • Cookie-based locale, no URL prefixes: strategy ['cookie', 'preferredLanguage', 'baseLocale'], cookie name locale. Compiler options live in project.inlang/paraglide.config.js so the Vite plugin and the CLI compile (run by npm run check) can never drift.
  • hooks.server.ts composes with the existing /api reverse proxy — /api/* requests bypass Paraglide entirely and stay byte-for-byte transparent; only page requests go through paraglideMiddleware with %paraglide.lang%/%paraglide.dir% substitution in app.html.
  • npm run check now compiles Paraglide first (CI runs check before build, and hooks.server.ts imports generated code). Dockerfile copies project.inlang/ + messages/ so the image build can compile messages.
  • Generated src/lib/paraglide/ and inlang CDN caches are gitignored.

Extracted strings (93 keys × 3 locales)

  • AppShell nav + utility items, ProfileMenu items
  • All 12 static page <title>s ("X - Memories" part only)
  • /setup (login + storage-path setup — the German hardcoded copy is now de values with proper en/da), /register, MaintenanceView full-page copy
  • Profile page tab labels (were hardcoded Danish) + "X - Memories" titles

Language switcher

Radio rows on Settings → Account (routes/profile/+page.svelte), consistent with existing settings sections. Calls setLocale(value) → writes the locale cookie and reloads so SSR matches. Functional but plain — a designer pass can polish later.

Account sync seam (backend lane)

src/lib/i18n/localeSync.ts:

  • syncLocaleFromAccount(locale) — no-ops on null/match/unknown tags; call on session load once user_accounts.locale ships. Not wired yet.
  • persistLocaleToAccount(locale) — clearly-marked wave-2 integration point for PUT /api/session/preferences; currently a no-op. No backend endpoints are called.

Other

  • explore/+page.svelte: hardcoded 'da-DK' → getLocale(). lib/utils/decisionTime.ts deliberately untouched.
  • MessageWithMarkup.svelte: safe renderer (tag whitelist + escaping) for messages with {#code}…{/code} markup parts; later waves reuse it.
  • KNOWN_ISSUES.md: ISSUE-142 tracks that da/de need native review.

Verification

  • npm run check: 0 errors (18 pre-existing warnings in untouched files)
  • npm run build: succeeds
  • npm run test:unit: 162/162 pass
  • Dev-server smoke test (backend intentionally down):
    • /setup SSR renders lang="en" dir="ltr" "Welcome to Memories"
    • Cookie: locale=de → lang="de" "Willkommen bei Memories"; locale=da → lang="da" "Velkommen til Memories"
    • /library title: en "Library" / de "Mediathek" / da "Bibliotek"
    • /api/* returns proxy fetch error (expected with no backend), not an i18n error

Caveats

  • da/de translations are agent-authored, not native-reviewed (ISSUE-142) — please flag copy issues in review.
  • The profile tab row only renders after session load, so tabs couldn't be visually smoke-tested without a backend; labels are extracted and typed.
  • Paraglide's compiler emits flat exports for dotted keys, so message keys are flat camelCase with grouped prefixes (navPhotos, setupPathsTitle) rather than nested — call sites are m.navPhotos().
  • No reroute hook added: with no url strategy there are no locale-prefixed URLs to delocalize.
## Summary Wave 1 of the frontend i18n rollout: **Paraglide v2 infrastructure + app chrome only**. Bulk component extraction (~1,000–1,500 sites) is planned in later waves — see `apps/web/src/lib/i18n/EXTRACTION.md`. ### Infrastructure - **Paraglide v2** (`@inlang/paraglide-js` 2.27) via the Vite plugin. Locales: `en` (base), `de`, `da`. - **Cookie-based locale, no URL prefixes**: strategy `['cookie', 'preferredLanguage', 'baseLocale']`, cookie name `locale`. Compiler options live in `project.inlang/paraglide.config.js` so the Vite plugin and the CLI compile (run by `npm run check`) can never drift. - **`hooks.server.ts` composes with the existing `/api` reverse proxy** — `/api/*` requests bypass Paraglide entirely and stay byte-for-byte transparent; only page requests go through `paraglideMiddleware` with `%paraglide.lang%`/`%paraglide.dir%` substitution in `app.html`. - `npm run check` now compiles Paraglide first (CI runs `check` before `build`, and `hooks.server.ts` imports generated code). Dockerfile copies `project.inlang/` + `messages/` so the image build can compile messages. - Generated `src/lib/paraglide/` and inlang CDN caches are gitignored. ### Extracted strings (93 keys × 3 locales) - AppShell nav + utility items, ProfileMenu items - All 12 static page `<title>`s ("X - Memories" part only) - `/setup` (login + storage-path setup — the German hardcoded copy is now `de` values with proper `en`/`da`), `/register`, `MaintenanceView` full-page copy - Profile page tab labels (were hardcoded Danish) + "X - Memories" titles ### Language switcher Radio rows on **Settings → Account** (`routes/profile/+page.svelte`), consistent with existing settings sections. Calls `setLocale(value)` → writes the `locale` cookie and reloads so SSR matches. Functional but plain — a designer pass can polish later. ### Account sync seam (backend lane) `src/lib/i18n/localeSync.ts`: - `syncLocaleFromAccount(locale)` — no-ops on null/match/unknown tags; call on session load once `user_accounts.locale` ships. **Not wired yet.** - `persistLocaleToAccount(locale)` — clearly-marked wave-2 integration point for `PUT /api/session/preferences`; currently a no-op. **No backend endpoints are called.** ### Other - `explore/+page.svelte`: hardcoded `'da-DK'` → `getLocale()`. `lib/utils/decisionTime.ts` deliberately untouched. - `MessageWithMarkup.svelte`: safe renderer (tag whitelist + escaping) for messages with `{#code}…{/code}` markup parts; later waves reuse it. - `KNOWN_ISSUES.md`: ISSUE-142 tracks that **da/de need native review**. ## Verification - `npm run check`: **0 errors** (18 pre-existing warnings in untouched files) - `npm run build`: **succeeds** - `npm run test:unit`: **162/162 pass** - Dev-server smoke test (backend intentionally down): - `/setup` SSR renders `lang="en" dir="ltr"` "Welcome to Memories" - `Cookie: locale=de` → `lang="de"` "Willkommen bei Memories"; `locale=da` → `lang="da"` "Velkommen til Memories" - `/library` title: en "Library" / de "Mediathek" / da "Bibliotek" - `/api/*` returns proxy fetch error (expected with no backend), not an i18n error ## Caveats - **da/de translations are agent-authored, not native-reviewed** (ISSUE-142) — please flag copy issues in review. - The profile tab row only renders after session load, so tabs couldn't be visually smoke-tested without a backend; labels are extracted and typed. - Paraglide's compiler emits flat exports for dotted keys, so message keys are flat camelCase with grouped prefixes (`navPhotos`, `setupPathsTitle`) rather than nested — call sites are `m.navPhotos()`. - No reroute hook added: with no `url` strategy there are no locale-prefixed URLs to delocalize.
feat(web): add Paraglide v2 i18n infrastructure (en/de/da, cookie locale)
All checks were successful
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Android unit tests and debug APK (push) Has been skipped
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 2m55s
c399311277
Wave 1 of the frontend i18n rollout: infrastructure + app chrome only.

- Paraglide v2 via @inlang/paraglide-js vite plugin; locales en (base), de, da;
  cookie-first strategy (cookie -> preferredLanguage -> baseLocale), cookie
  name 'locale', NO URL prefixes. Compiler options live in
  project.inlang/paraglide.config.js (shared by vite plugin + CLI compile).
- hooks.server.ts: compose paraglideMiddleware with the existing /api reverse
  proxy — /api/* stays a pure transparent proxy, page requests get locale
  resolution + %paraglide.lang%/%paraglide.dir% substitution in app.html.
- Extracted to messages/{en,de,da}.json: AppShell nav + utility items,
  ProfileMenu, 12 static page <title>s, setup/login + storage-path setup,
  register, MaintenanceView full-page copy, profile tab labels (were
  hardcoded Danish), language switcher labels.
- Language switcher: radio rows on Settings -> Account (Konto) tab; setLocale()
  writes the cookie and reloads. src/lib/i18n/localeSync.ts encapsulates the
  future user_accounts.locale sync (syncLocaleFromAccount + marked
  persistLocaleToAccount integration point; no backend calls yet).
- explore page: hardcoded 'da-DK' Intl.NumberFormat -> getLocale().
- npm run check now compiles paraglide first (CI runs check before build and
  hooks.server.ts imports generated code); Dockerfile copies project.inlang +
  messages; generated src/lib/paraglide/ + inlang caches gitignored.
- src/lib/i18n/EXTRACTION.md: key naming, extraction rules, wave plan.
- MessageWithMarkup.svelte: safe renderer for {#code}-style markup parts.

da/de translations are agent-authored and need native review (KNOWN_ISSUES
ISSUE-142).
chris force-pushed feature/i18n-paraglide-infra from c399311277
All checks were successful
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Android unit tests and debug APK (push) Has been skipped
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 2m55s
to 15aeb61af5
All checks were successful
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Android unit tests and debug APK (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 1m9s
2026-10-13 01:19:58 +02:00
Compare
chris merged commit 38f5611568 into main 2026-10-13 01:21:32 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!1178
No description provided.