Intl
Money, numbers, dates and plurals formatted the same way in every Krizaka product.
@krizaka/intl has no dependency: it is built on Intl, with one cached formatter per locale and options.
npm install @krizaka/intlThe cents are the ledger's money, never a float. An amount travels as an integer of minor units from the database to the screen; only
formatMoneyturns it into text. The locale is always passed: a server render and a browser render say the same thing.
| Function | Example (en-US) | Example (fr-CA) |
|---|---|---|
formatMoney(123450, { currency: "USD", locale }) | $1,234.50 | 1 234,50 $ US |
formatNumber(1234567.891, { locale }) | 1,234,567.891 | 1 234 567,891 |
formatCompact(12345, { locale }) | 12.3K | 12,3 k |
formatPercent(0.125, { locale }) | 13% | 13 % |
formatDate(date, { locale }) | Oct 9, 2026 | 9 oct. 2026 |
formatRelative(date, { locale, now }) | 3 hours ago, yesterday | il y a 3 heures, hier |
plural(1, locale, { one: "bid", other: "bids" }) | bid | 0 and 1 are one |
Sub-paths (@krizaka/intl/money, /number, /date, /plural) import one family; the root imports all of them.
Hermes / missing Intl constructors
If Intl.PluralRules or Intl.RelativeTimeFormat is missing, plural and formatRelative use small built-in
fallbacks. Native Intl behavior is unchanged when the constructors exist.
- Plurals support unrounded English and French cardinal rules (including French
manyfor nonzero multiples of a million). Unsupported languages and non-finite counts useother; plural options are not applied. - Relative times use long numeric English/French wording, even for
numeric: "auto"or abbreviated styles. Unsupported languages use English wording; numbers still use the requested locale. - Locale lists use the first supported English/French entry, never the runtime default.
getPluralRules/getRelativeTimeFormatguarantee onlyselect/format; check for native-only methods before using them. The return types include these minimal fallbacks, not complete Intl polyfills.
Intl.NumberFormat and Intl.DateTimeFormat remain required. Apps needing complete locale, option and method
support should load an Intl polyfill.
Bind it once in the app
The app knows its currency and its locale; the components only pass cents:
import { formatMoney } from "@krizaka/intl";
import { currentLocale } from "@/lib/i18n";
export const money = (cents: number) => formatMoney(cents, { currency: "USD", locale: currentLocale() });formatMoney(12.5, …) throws a TypeError: a float never reaches the screen as money.