title: Using i18n module at rendering a jade template with app.render and not res.render
body: <p><strong>Environment</strong>: </p>
  
  <p>Node.js, Express, i18n Module, Jade</p>
  
  <p><strong>Purpose</strong>: </p>
  
  <p>Render an internationalized jade template for email it, and given a "locale" property such as "es_ES".</p>
  
  <p><strong>Description</strong>:</p>
  
  <p>I have a mailing object that sends mails which language is based on a user.locale property, so given a 'es_ES' value i want to send a jade rendered template in the given language. </p>
  
  <p>For i18n i make this at the express initialitation:</p>
  
  <pre><code>app.use(i18n.init);
  app.use(function(req, res, next){
      i18n.setLocale(req.getLocale());
      next();
  });
  </code></pre>
  
  <p>So when i use res.render i just do the next thing at the jade template:</p>
  
  <p><code>#{__('key')}</code></p>
  
  <p>This works great, but i have a cron that doesn't have a req, just the locale in a property of the user object and when i try to render the jade template as above but changing res.render for app.render:</p>
  
  <pre><code>/*** Module Dependencies ***/
  var mandrill = require('mandrill-api/mandrill');
  var mandrill_client = new mandrill.Mandrill(g.wizco.mandrill_api_key);
  
  /**
   *  MAILER API
   */
  
  var mailer = {
  
  
      send_activation_mail: function(user, cb){
          var self = this;
          app.render('mails/account_confirmation_email', {var1: 'Holaaaaaaa'}, function(err, html){
              if(err) { console.log(err); return err }
              self.send_mail(html, 'Activación de cuenta', user.email, user.displayName, cb);
          }); 
      }
  
  .....
  
  }
  </code></pre>
  
  <p>i get the next error when rendering the jade template:</p>
  
  <blockquote>
    <p>undefined is not a function</p>
  </blockquote>
  
  <p>Meaning __('...') which is the i18n shortcut for i18n module.</p>