Closed foobar321 closed 9 years ago
It'd be great to have an option to auto-use Accept-Language. For now, here's how you can do it:
// ...
// Attach the i18n property to the express request object
// And attach helper methods for use in templates
I18n.expressBind(app, {
// setup some locales - other locales default to en silently
locales: ['en', 'de']
});
app.use(function (req, res, next) {
req.i18n.setLocale(req.i18n.preferredLocale(req));
next();
});
// ...
req.i18n.setLocale(req.i18n.preferredLocale(req));
That is actually the way it's meant to use...
prefLocale variable seems to be unused. Or please give an example with ejs and language detection just based on accept-language header (no cookies and no subdomains).