Skip to content

Instantly share code, notes, and snippets.

@FrankGrimm
Created February 12, 2015 12:15
Show Gist options
  • Save FrankGrimm/918113c3d836b0900e7c to your computer and use it in GitHub Desktop.
Save FrankGrimm/918113c3d836b0900e7c to your computer and use it in GitHub Desktop.
var express = require('express');
var i18n = require('i18n-2');
var app = express();
var localeSetup = {
locales: ['en', 'es'],
defaultLocale: 'en'
}
var setNewLocaleFromQuery = function(req, res, next) {
if (req.query.lang) {
req.i18n.setLocaleFromQuery(req);
}
next();
}
module.exports = exports = function(app) {
i18n.expressBind(app, localeSetup);
app.use(setNewLocaleFromQuery);
};
// and in your main app:
require('thisfile')(app);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment