1.0.1 • Published 4 years ago
ez-translation v1.0.1
ez-translation
Lightweight translation module usable on browser and server
Install
npm i ez-translation
Usage
Basic
Create a translation object (can be a .json file)
const myTranslation = {
"login-form": {
"label": {
"email": "E-mail",
"password": "Password"
}
}
}
Add to your code :
import {Translation} from "ez-translation";
const translation = new Translation(myTranslation)
translation.t('login-form.label.email') // "E-mail"
CLI
There is also a cli interface !
To test if there is no missing keys in your translation files
npx ezt check file1 file2 file3 --file=report
--file=myfile is optionnal. It will generate a .json file with all diffs. By default a console.log output is displayed
You can also name your file (optionnal) by passing a key like --mykey=myfile
Full example:
npx ezt check --en=/public/translation/en/common.json --fr=/public/translation/fr/common.json --file=report