SayKit
Core Concepts

Extraction

How the saykit CLI scans your source and produces translation files

saykit extract scans your source for macros, writes them to the source locale's catalogue as ICU MessageFormat, and compiles every locale into the module your app imports.

pnpm saykit extract

For each bucket it globs include (minus exclude), has each transformer extract the messages, merges identical text and context into one entry with every source reference, and hashes an id for each message without a custom one. The result:

src/locales/
  en.po       # source locale, regenerated from your code
  en.js       # the compiled module your app imports
  en.d.ts     # its declaration
  fr.po       # other locales: left alone, or created empty
  fr.js
  fr.d.ts

The .po is what translators edit. The .js is build output: the build plugin compiles it when your dev server or build starts, extraction compiles it as its last step, and saykit compile compiles it on its own.

Source-only writes

Extraction writes only the source locale, the first in locales:

  • The source catalogue is regenerated on every run.
  • A locale with no file gets an empty, header-only one, so a TMS like Weblate can register it.
  • A locale that has a file is never touched: no keys added, none removed.

So changing a string touches one file, and translators' work is never overwritten.

Fallback at compile time

Since other locales hold only what was translated, compiling fills each missing key from a fallback chain that ends at the source locale. fallbackLocales inserts steps before it:

saykit.config.ts
fallbackLocales: {
  'en-NZ': ['en-GB'], // en-NZ → en-GB → en
},

The chain is merged into the compiled module, so the app still imports one module per locale.

Pruning other locales

If your TMS does not tidy up, saykit clean removes entries that are no longer in the source, and entries that were never translated. It never adds anything.

Watch mode

pnpm saykit extract --watch

After the first run it re-extracts when a source file in a bucket changes, drops the entries of a deleted file, and recompiles when a catalogue changes, such as a translator's edit. Run it beside your dev server and edits show up through ordinary hot reload.

Committing

FileCommit?
{locale}.poYes: the catalogues are the source of truth
{locale}.jsNo: build output, compiled by the build plugin
{locale}.d.tsYes: it never changes, and lets tsc pass on a fresh clone

For the scripts and CI check, see the CLI reference.

Next

On this page