Which package do you use for localization with express in node.js?
Thanks!
Which package do you use for localization with express in node.js?
Thanks!
Actually I use this NPM Package i18n
It have a very simple usage with Express framework... create locales folder (it.json, en.json, etc...)
// load modules at bootstrap
var app = express();
var i18n = require("i18n");
//set configuration
i18n.configure({
locales:['en', 'de'],
directory: __dirname + '/server/locales'
});
app.use(i18n.init);
// and then, in controller we can use response
res__('YOUR_KEY')
Front End side just set the HTTP header Accept-Language with value 'en', 'it', etc.
You can use language-translator library. It uses json files to load texts. You can define languages whatever you want.
I found few of the best libraries to deal with localization in nodeJS: