Internationalization
Type-safe translations, pluralization, date/number formatting, and language switching with Paraglide JS.
Language Switcher
Detection order: URL prefix → Cookie → Base locale (English)
Translated Messages
Pluralization
ICU MessageFormat handles pluralization rules per language.
Date & Number Formatting
Formatting uses the browser's Intl API, decoupled from the translation locale. A German user in Switzerland gets German text but Swiss number formatting.
Content Translation (Database)
The tc() helper translates JSON fields from the database, falling back through: current locale → English → first available.
Database Schema Pattern
// EN canonical column + JSONB i18n sibling per non-base locale
name: text('name').notNull(),
nameI18n: jsonb('name_i18n')
.$type<Partial<Record<'de'|'ru', string>>>()
.notNull().default(sql`'{}'::jsonb`),
// Render: tc(row.name, row.nameI18n, locale)Error Codes
Domain code throws stable error codes; adapters resolve them to localized strings via errorMessage(code). Switching locale re-renders without re-submitting.
Type Safety
All message keys are compile-time checked with full IntelliSense support. Missing keys or wrong parameters cause build errors, not runtime errors.
Compile-time Guarantees
// ✅ Type-safe with autocomplete
m.greeting({ name: 'Alice' });
// ❌ Compile error — missing parameter
m.greeting();
// ❌ Compile error — unknown message key
m.unknownKey();