rollup-plugin-messageformat-modules

Rollup plugin for messageformat-modules


Keywords
rollup-plugin, messageformat, pluralformat, icu, i18n, translations
License
MIT
Install
npm install rollup-plugin-messageformat-modules@0.0.1

Documentation

Traduki

npm version Build Status GitHub license

Traduki is a set of build- and runtime tools for lazy loading L10n messages.

  • Modular messages files which are bundled and precompiled per locale and per chunk for production.

  • When importing the messages YAML from a JS Module, it exports an object with all mappings from local message keys to global message keys. And as side effect it registers the location of the bundled (global) messages file for each locale. (Inspired by CSS Modules)

  • It uses MessageFormat for text formatting.

Packages

Example

# a.messages.yaml
en:
    hello: Hello {name}!
    intro: How are you?
nl:
    hello: Hallo {name}!
    intro: Hoe is het met jou?
// index.js
import traduki from '@traduki/runtime'
import messages from './a.messages.yaml'

console.log(messages); // { hello: 'hello_30ebe736', intro: 'intro_01b95038' }

traduki.setLocale('en').load().then(() => {
    traduki.translate(messages.hello, { name: 'John' }); // "Hello John!"
});

Status (in beta)

Webpack plugin Vite plugin
Precompiled translations
Code splitting *
Lazy loading **
HMR
Minify bundles
Strict mode ***
Emit .d.ts

(*) messages bundles per locale and per chunk

(**) Lazy loading with EcmaScript Modules using the runtime

(***) Check *.messages.yaml consistency