Created
February 12, 2015 12:15
-
-
Save FrankGrimm/918113c3d836b0900e7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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