title: Keystone.js + i18n. Get current locale before rendering view
body: <p>I'm trying to include i18n in keystone.js app. I'm doing it like in this example <a href="https://gist.github.com/JedWatson/9191081" rel="nofollow">https://gist.github.com/JedWatson/9191081</a>, and it works, but my problem is to get current locale in view. I'm using a middleware for setting locale by url param:</p>
  
  <pre><code>// middleware.js
  exports.setLocale = function (req, res, next) {
      if (req.params.lang) {
          req.setLocale(req.params.lang);
      }
      else
          res.redirect('/ru/');
      next();
  };
  
  // index.js
  keystone.pre('render', middleware.setLocale);
  </code></pre>
  
  <p>and routing</p>
  
  <pre><code>app.get('/:lang/', routes.views.index);
  app.get('/:lang/blog/:category?', routes.views.blog);
  app.get('/:lang/blog/post/:post', routes.views.post);
  ...
  </code></pre>
  
  <p>Default locale is 'ru'. But in my view</p>
  
  <pre><code>view.on('render', function (next) {
      console.log('on render', req.getLocale());
      next();
  });
  
  console.log('before render', req.getLocale());
  view.render('blog');
  </code></pre>
  
  <p>on route <code>/en/blog</code> it outputs</p>
  
  <pre><code>------------------------------------------------
  KeystoneJS Started:
  qalqan is ready on default port 3000
  ------------------------------------------------
  
  before render ru
  on render en
  GET /en/blog 304 373ms
  </code></pre>
  
  <p>So, as i understand, locale is changed after varibales sended to view. Is threre any way to set it before rendering? I know, that i can get it by req.params from url param <code>lang</code> in each view, but i want do it by middleware for all views.</p>