Krizaka
Documentation
Tooling

i18n

Typed messages, formatting and rich text for every Krizaka app, with the CLI that checks both languages.

@krizaka/i18n is the i18n engine of every Krizaka app, written once: typed message keys and placeholders from en.json, format(), plural sets on @krizaka/intl, <Rich> for <b> and <a>, a React provider, and the krizaka-i18n CLI that checks the catalogues and finds text written in the code.

Every user-facing string lives in messages/<locale>.json. en.json is the reference: its shape types the keys, every other locale has exactly the same keys, the same {placeholders} and the same markup. The code holds keys, never words.

npm install @krizaka/i18n
EntryWhat
@krizaka/i18ncreateI18n, format, placeholdersOf, the types.
@krizaka/i18n/rich<Rich> — bold and links from a message; no hook, so Server Components too.
@krizaka/i18n/reactcreateI18nReact → I18nProvider, useI18n.
krizaka-i18n (CLI)check (same keys, no empty strings, same placeholders and markup) and scan (text written in the code).
import { createI18n } from "@krizaka/i18n";
import en from "@/messages/en.json";
import fr from "@/messages/fr.json";

// fr.json type-checks against en.json: a missing key fails to compile.
export const i18n = createI18n<typeof en, "en" | "fr">({ en, fr }, { defaultLocale: "en" });

A component's words always arrive as props, already translated: that is why the primitives of Krizaka UI hold no t(). Money, numbers, dates and plurals go through @krizaka/intl.