npm.io
0.2.1 • Published yesterday

saykit

Licence
MIT
Version
0.2.1
Deps
1
Size
17 kB
Vulns
0
Weekly
0
Stars
6

saykit

Type-safe i18n library with compile-time macro transforms.

Coverage

The core runtime for SayKit. Exports the Say class, which stores your locales, loads message catalogues, and formats messages using ICU MessageFormat.

You author messages with the say`...` tagged template (and say.plural, say.ordinal, say.select); a SayKit build-tool plugin rewrites them at build time into small runtime calls.

Install

pnpm add saykit

You will normally also want @saykit/config and a build-tool plugin (unplugin-saykit or babel-plugin-saykit).

Usage

import { Say } from 'saykit';
import en from './locales/en.po';
import fr from './locales/fr.po';

const say = new Say({
  locales: ['en', 'fr'],
  messages: { en, fr },
});

say.activate('en');

say`Hello, ${name}!`;
say.plural(count, { one: '1 item', other: '# items' });

Documentation

Full guide at saykit.js.org.

Keywords