CLI
The saykit command-line interface, every command and flag
The saykit CLI ships with @saykit/config. It has three commands: extract, compile and clean.
saykit help [command]Every command takes these flags:
Prop
Type
saykit extract
Extracts messages from each bucket's include files, writes the source locale's catalogue, then compiles every locale as compile does. Other locales are never edited; one with no file yet is created empty so a TMS can register it.
saykit extract
saykit extract --watchProp
Type
Messages with the same text and context are merged into one entry with every reference. Ids are hashed for messages without a custom one.
saykit compile
Compiles each locale's catalogue into the {locale}.js module your app imports, beside the catalogue. The Vite/unplugin and Next.js and Metro plugins already do this when they start, so you need it only without one: plain babel, or a script Node runs directly.
saykit compileFor each locale it reads the catalogue and its fallback chain, compiles each ICU message to a Message with every style resolved to Intl options, and writes {locale}.js and {locale}.d.ts:
// Generated by saykit. Do not edit.
export default {
// {count, plural, one {# article} other {# articles}}
c4Ef_2: [3, '_count', { one: [[6], ' article'], other: [[6], ' articles'] }],
};Nothing parses a message at runtime, and since the module is data, a server can hand it to a client like any other JSON.
Keep the .js out of version control. Commit the .d.ts: it never changes, and it lets tsc
pass on a fresh clone.
saykit clean
Removes dead entries from every non-source locale. It only subtracts:
- drops keys no longer in the source catalogue,
- drops empty translations, which fall back anyway,
- leaves everything else byte-for-byte.
Keys missing from a locale are left for your TMS to add. clean is optional; if your TMS prunes orphans you may never need it.
saykit cleanConfiguration discovery
The CLI looks for saykit.config.{ts,mts,cts,js,mjs,cjs} from the working directory upwards; the first match wins. See Configuration → Loading.
Scripts
The build plugin compiles the modules, so dev and build need no pre script:
{
"scripts": {
"extract": "saykit extract"
}
}Without a plugin, compile before anything that imports a locale:
{
"scripts": {
"prebuild": "saykit compile"
}
}In CI, check that extraction was run:
- run: pnpm saykit extract
- run: git diff --exit-code -- 'src/locales/*.po'