feat(web): Paraglide v2 i18n infrastructure (en/de/da, cookie locale, app chrome) #1178
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/i18n-paraglide-infra"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
@inlang/paraglide-js2.27) via the Vite plugin. Locales:en(base),de,da.['cookie', 'preferredLanguage', 'baseLocale'], cookie namelocale. Compiler options live inproject.inlang/paraglide.config.jsso the Vite plugin and the CLI compile (run bynpm run check) can never drift.hooks.server.tscomposes with the existing/apireverse proxy —/api/*requests bypass Paraglide entirely and stay byte-for-byte transparent; only page requests go throughparaglideMiddlewarewith%paraglide.lang%/%paraglide.dir%substitution inapp.html.npm run checknow compiles Paraglide first (CI runscheckbeforebuild, andhooks.server.tsimports generated code). Dockerfile copiesproject.inlang/+messages/so the image build can compile messages.src/lib/paraglide/and inlang CDN caches are gitignored.Extracted strings (93 keys × 3 locales)
<title>s ("X - Memories" part only)/setup(login + storage-path setup — the German hardcoded copy is nowdevalues with properen/da),/register,MaintenanceViewfull-page copyLanguage switcher
Radio rows on Settings → Account (
routes/profile/+page.svelte), consistent with existing settings sections. CallssetLocale(value)→ writes thelocalecookie 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 onceuser_accounts.localeships. Not wired yet.persistLocaleToAccount(locale)— clearly-marked wave-2 integration point forPUT /api/session/preferences; currently a no-op. No backend endpoints are called.Other
explore/+page.svelte: hardcoded'da-DK'→getLocale().lib/utils/decisionTime.tsdeliberately 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: succeedsnpm run test:unit: 162/162 pass/setupSSR renderslang="en" dir="ltr""Welcome to Memories"Cookie: locale=de→lang="de""Willkommen bei Memories";locale=da→lang="da""Velkommen til Memories"/librarytitle: en "Library" / de "Mediathek" / da "Bibliotek"/api/*returns proxy fetch error (expected with no backend), not an i18n errorCaveats
navPhotos,setupPathsTitle) rather than nested — call sites arem.navPhotos().urlstrategy there are no locale-prefixed URLs to delocalize.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).c39931127715aeb61af5