Skip to content

Introducing Parla: i18n where the types know what loaded

Most i18n bugs aren’t translation bugs: a missing key, a {count} nobody passed, a namespace read before it loaded. TypeScript could catch each. Today’s libraries type keys, some type params too, and most leave “is it loaded?” to a ready flag.

Parla is a type-safe, framework-agnostic i18n library for TypeScript, with React, Solid, Svelte and Vue bindings. A compiler turns ICU or MessageFormat 2 catalogs into typed functions and lazy chunks, one per locale and namespace. The name, pronounced /ˈparla/ (“PAR-lah”), is Italian for “speaks”, from the verb parlare, “to speak”.

import { checkout } from './parla/namespaces/checkout.js';
const { t } = useParla([checkout]);
t.checkout.cart.items({ count: 3 }); // count: number, required
t.checkout.terms({ link: (c) => <a href="/terms">{c}</a> });
  • Params come from the message: a plural’s number, a select’s keys and their params, a renderer per tag.
  • t is proof of loading: reading a namespace you didn’t load is a type error.
  • Namespaces are imports: the bundler ships only what you import.
  • No flash on switch: switchLocale loads first, then switches.
  • ICU and MF2, per namespace.
  • Missing and unused keys, reported by x18n through a plugin.

How it compares with other libraries: Why Parla.

No idea here is new. Parla combines:

  • namespaces and fallbacks, from i18next;
  • ICU messages formatted through Intl, from FormatJS;
  • catalogs compiled ahead of time, from Lingui;
  • messages as tree-shakable functions, from Paraglide;
  • params typed from the message, from typesafe-i18n;
  • MessageFormat 2, the Unicode standard for message syntax.

Parla is experimental and not on npm yet. Once it is:

Terminal window
pnpm add @parlajs/react # or solid, svelte, vue
pnpm add -D @parlajs/compiler

Start with Getting started or the showcase. Source: GitHub.

Parla is built with the help of AI coding tools.