Decisions

0005 · Own i18n layer

A small typed translation layer replaces i18next, react-i18next and next-i18next.

Status: Accepted · 2026-11

Context

Three locales, a few hundred strings, one namespace, plurals in two places. Version 1 carried three i18n packages for that, and keys were untyped strings — several referenced keys didn't exist (confirm.backToIntro.*) and rendered as raw keys.

Decision

  • Dictionaries are TypeScript objects. Portuguese defines the Dictionary type; other languages must satisfy it.
  • t(key, vars) with type-checked dotted keys and {name} interpolation; tp(key, count) picks _one/_other via Intl.PluralRules.
  • Server Components call createTranslator(locale); client components use useI18n() from a provider that only receives the locale.
  • Formatting uses Intl directly through lib/money.ts and features/bill/format.ts.

Consequences

  • Missing translations and typos in keys are compile errors.
  • No runtime dependency; about 150 lines to read and maintain.
  • No ICU message syntax. If the app ever needs gender/select rules or many more locales, revisit this record.
Edit this page on GitHub