1.3.4 • Published 5 years ago
webux-language v1.3.4
Webux Language
This module is a wrapper for i18n.
Installation
npm i --save webux-language
Usage
For more details on the options, check the i18n module on NPM,
const { init, i18n, getLocale } = require("../index");
const express = require("express");
const app = express();
const options = {
availables: ["fr", "en"],
directory: "locales",
default: "en",
autoReload: true,
syncFiles: true
};
init(options, app);
app.get("/", (req, res) => {
console.log(getLocale());
console.log("Language initialized");
console.log(i18n.getLocale());
res.status(200).send({ msg: i18n.__("MSG_BONJOUR"), lang: i18n.getLocale() });
});
app.listen(1337);
After launching the application, a folder named locales, will be created and containing the translation,
locales/fr.json
{
"MSG_BONJOUR": "Bonjour !"
}
locales/en.json
{
"MSG_BONJOUR": "Welcome !"
}
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
SEE LICENSE IN license.txt