babel-plugin-i18n
Babel plugin to statically compile keypath denoted translation calls to literals.
Compiles these...
const myString = ;const anEnum = ;const lyrics = ;const veryComplex = ;
...with this kind of translation...
"my": "translation": "path": "Hei, maailma!" "example": "countries": "finland": "Suomi" "sweden": "Ruotsi" "song": "Hey!" "Ho!" "Let's go!" "complex": "multilevel array" 123 null
...into this:
const myString = "Hei, maailma!";const anEnum = finland: "Suomi" sweden: "Ruotsi";const lyrics = "Hey!" "Ho!" "Let's go!";const complex = "multilevel array" 123 null;
Installation
$ npm install babel-plugin-i18n --save-dev
Usage
.babelrc
(Recommended)
Via .babelrc
Via CLI
TODO: How does one actually pass options via CLI?
Via Node API
;
Translation loader example
const join = join;const readFileSync = readFileSync; const TRANSLATIONS_PATH = ; module { const translationJSON = ; return JSON;};