Skip to main content

Sprachwahl

Erkennungsreihenfolge: URL-Präfix → Cookie → Basissprache (Englisch)

Aktuelle Sprache: Deutsch (de)
Formatting locale: de-DE

Übersetzte Nachrichten

m.greeting({ name: 'World' }) Hallo, World!
m.welcome_message() Willkommen bei der Internationalisierungs-Demo
m.sample_text() Dieser Text wird basierend auf der aktuellen Sprache übersetzt.

Pluralisierung

ICU MessageFormat handles pluralization rules per language.

m.items_count({ count: 0 }) undefined other }
m.items_count({ count: 1 }) undefined other }
m.items_count({ count: 2 }) undefined other }
m.items_count({ count: 5 }) undefined other }
m.items_count({ count: 42 }) undefined other }

Datums- & Zahlenformatierung

Formatting uses the browser's Intl API, decoupled from the translation locale. A German user in Switzerland gets German text but Swiss number formatting.

Formatiertes Datum 15.01.2025
Formatiertes Datum (long) Mittwoch, 15. Januar 2025
Formatierte Zahl 1.234.567,89
Formatierte Währung (EUR) 1.234,50 €
Formatierte Währung (USD) 1.234,50 $
Formatierter Prozentsatz 85,4 %
Relative Zeit vorgestern

Content Translation (Database)

The tc() helper translates JSON fields from the database, falling back through: current locale → English → first available.

tc(post.title) Hallo Welt
tc(post.description) Dieser Inhalt ist in der Datenbank als JSON gespeichert.

Database Schema Pattern

// JSON columns for translated content
title: jsonb('title').$type<Record<string, string>>()
// Data: { "en": "Hello", "de": "Hallo", "fr": "Bonjour" }

Typsicherheit

Alle Nachrichtenschlüssel werden zur Kompilierzeit geprüft mit vollständiger IntelliSense-Unterstützung. Fehlende Schlüssel oder falsche Parameter verursachen Build-Fehler, keine Laufzeitfehler.

Compile-time Guarantees

// ✅ Type-safe with autocomplete
m.greeting({ name: 'Alice' });

// ❌ Compile error — missing parameter
m.greeting();

// ❌ Compile error — unknown message key
m.unknownKey();
← Back to Showcases