Skip to content

Instantly share code, notes, and snippets.

@mderazon
Created October 30, 2013 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mderazon/7229824 to your computer and use it in GitHub Desktop.
Save mderazon/7229824 to your computer and use it in GitHub Desktop.
i18n module
var i18n = require('i18n');
i18n.configure({
// setup some locales - other locales default to en silently
locales:['en', 'iw'],
// where to store json files - defaults to './locales' relative to modules directory
directory: __dirname + '/locales',
defaultLocale: 'en',
// sets a custom cookie name to parse locale settings from - defaults to NULL
cookie: 'lang',
});
module.exports = function(req, res, next) {
i18n.init(req, res);
res.local('__', res.__);
var current_locale = i18n.getLocale();
return next();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment