Updated translation support

This commit is contained in:
Andris Reinman 2017-03-07 16:30:56 +02:00
parent b1e8cd68cd
commit d25565b6f8
114 changed files with 42095 additions and 1902 deletions

View file

@ -14,6 +14,23 @@ let templates = new Map();
let htmlToText = require('html-to-text');
let aws = require('aws-sdk');
let _ = require('./translate')._;
let util = require('util');
Handlebars.registerHelper('translate', function (context, options) { // eslint-disable-line prefer-arrow-callback
if (typeof options === 'undefined' && context) {
options = context;
context = false;
}
let result = _(options.fn(this)); // eslint-disable-line no-invalid-this
if (Array.isArray(context)) {
result = util.format(result, ...context);
}
return new Handlebars.SafeString(result);
});
module.exports.transport = false;
module.exports.update = () => {
@ -195,7 +212,7 @@ function createMailer(callback) {
}
};
} else {
return callback(new Error('Invalid mail transport'));
return callback(new Error(_('Invalid mail transport')));
}
module.exports.transport = nodemailer.createTransport(transportOptions, config.nodemailer);