Npm package - A JSON-based translation file manager.
npm install linguini
An example language file, lang.en.json
:
{
"data": {
"intro": {
"myFavoriteColor": "My favorite color is {{REF:aboutMe.favoriteColor}}."
}
},
"refs": {
"aboutMe": {
"favoriteColor": "Blue"
}
}
}
We could have additional translations of this file, for example: lang.fr.json
, lang.ru.json
, etc:
An example of using Linguini with the above language file:
let englishLine = linguini.get('intro.myFavoriteColor', 'en', stringTm); // "My favorite color is Blue."
let frenchLine = linguini.get('intro.myFavoriteColor', 'fr', stringTm); // "Ma couleur préférée est le bleu."
npm install linguini
let linguini = new Linguini(path.join(__dirname, './data'), 'lang');