Skip to content

KevinNovak/Linguini

Repository files navigation

Linguini

NPM Version Downloads Stars License Pull Requests

Npm package - A JSON-based translation file manager.

Installation

npm install linguini

Example Language File

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:

Example Usage

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."

Setup

npm install linguini

let linguini = new Linguini(path.join(__dirname, './data'), 'lang');