Skip to content

Kamod i18n

Type-safe translations, native Intl formatting, and a Preact-first integration in one small package.

Internationalization you can try, not just read about

This PreactPress site is both the documentation for @kamod-ch/i18n and a working consumer of the package. Change the language, add users, and compare locale-aware currency and date output below.

locale: en

A small internationalized app

Welcome, Ada!

2 active users
Annual planCHF 128.40
Release dateAugust 24, 2026

What the example demonstrates#

  • typed nested translation keys and interpolation
  • locale-aware plural selection through Intl.PluralRules
  • number and date formatting with native Intl APIs
  • reactive Preact components using I18nProvider, useI18n, and useLocale
  • an asynchronously loaded French locale

The same setup in your app#

import { createI18n } from "@kamod-ch/i18n";
import { I18nProvider, useI18n } from "@kamod-ch/i18n/preact";

const en = {
  greeting: "Welcome, {name}!",
  users: { one: "{count} user", other: "{count} users" },
} as const;

const i18n = createI18n({
  locale: "en",
  fallbackLocale: "en",
  messages: {
    en,
    de: () => import("./locales/de"),
  },
});

function Greeting() {
  const { t } = useI18n<typeof en, "en" | "de">();
  return <p>{t("greeting", { name: "Ada" })}</p>;
}

export function App() {
  return (
    <I18nProvider i18n={i18n}>
      <Greeting />
    </I18nProvider>
  );
}

Continue with the documentation#

Start with installation, follow the getting started guide, or inspect the complete API reference.