multilingualization module for Node.js server
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example-messages
languages
regions
.gitignore
LICENSE
README.md
index.es6
package.json

README.md

node-m17n

multilingualization module for Node.js server

How to use

init phase:

var path = require("path");
var m17n = require("node-m17n");

// specify m17n directories and fallback language
// * dirLanguages and dirRegions are NOT required.
// * If omitted, default directories in node-m17n will be used.
m17n.configure({
	dirLanguages: path.resolve("languages"),
	dirRegions: path.resolve("regions"),
	dirMessages: path.resolve("messages"),
	fallback: "ja-jp"
});

request phase:

var m = m17n({
	acceptLanguage: "ja,en-US;q=0.8,en;q=0.7,pl;q=0.5,pt-BR;q=0.3,de;q=0.2",
});

console.log("currency: " + m.region.currency);
console.log("language direction: " + m.lang.dir);
console.log("i18n: " + m._.i18n());
console.log("replacement: " + m._.message.to.be.replaced({
    aaa: "{bbb}",
    bbb: "{ccc}",
    ccc: "{aaa}",
}));