i18n in node.js

Howto get started with the i18n module in an node.js cli, application or website.

Install

npm install i18n --save

Load

var express = require('express'),
    i18n = require("i18n");

Configure

i18n.configure({
    locales:['en', 'de'],
    directory: __dirname + '/locales'
});

Use

app.use(i18n.init());

app.get('/de', function(req, res){
  var greeting = res.__('Hello');
});

Translate

{
    "Hello": "Hallo"
}

go ahead to learn about the details.