dyna-gettext

0.2.8 • Public • Published

Dyna-gettext

A tiny npm modules that loads the text from static json files dynamically. Save your text in a json file. They key will be used as id of that text. Below is a text file. Save it as mytext.json.

{
    "hello" : {
        "en" : "Hello [name]",
        "fr" : "Bonjour [name]"
    },
}

You can can load this file in your app in following way

const dynatext = require('dyna-gettext');
dynatext.load(__dirname + '/mytext.json', 'mytext');

(async () => {
    let d = await dynatext.getText("hello", {id: 'mytext', lang: 'fr'}, {name: 'Nauroz'});
    console.log(d);
    //Bonjour Nauroz
})()

Readme

Keywords

none

Package Sidebar

Install

npm i dyna-gettext

Weekly Downloads

0

Version

0.2.8

License

ISC

Unpacked Size

4.31 kB

Total Files

8

Last publish

Collaborators

  • nauroz