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

@ -12,6 +12,7 @@ let feed = require('../feed');
let log = require('npmlog');
let mailer = require('../mailer');
let humanize = require('humanize');
let _ = require('../translate')._;
let allowedKeys = ['description', 'from', 'address', 'reply_to', 'subject', 'editor_name', 'editor_data', 'template', 'source_url', 'list', 'segment', 'html', 'text', 'tracking_disabled'];
@ -267,7 +268,7 @@ module.exports.filterStatusSubscribers = (campaign, status, request, columns, ca
module.exports.getByCid = (cid, callback) => {
cid = (cid || '').toString().trim();
if (!cid) {
return callback(new Error('Missing Campaign ID'));
return callback(new Error(_('Missing Campaign ID')));
}
db.getConnection((err, connection) => {
if (err) {
@ -294,7 +295,7 @@ module.exports.get = (id, withSegment, callback) => {
id = Number(id) || 0;
if (id < 1) {
return callback(new Error('Missing Campaign ID'));
return callback(new Error(_('Missing Campaign ID')));
}
db.getConnection((err, connection) => {
@ -367,7 +368,7 @@ module.exports.getAttachments = (campaign, callback) => {
campaign = Number(campaign) || 0;
if (campaign < 1) {
return callback(new Error('Missing Campaign ID'));
return callback(new Error(_('Missing Campaign ID')));
}
db.getConnection((err, connection) => {
@ -403,7 +404,7 @@ module.exports.addAttachment = (id, attachment, callback) => {
let size = attachment.content ? attachment.content.length : 0;
if (!size) {
return callback(new Error('Emtpy or too large attahcment'));
return callback(new Error(_('Emtpy or too large attahcment')));
}
db.getConnection((err, connection) => {
if (err) {
@ -490,7 +491,7 @@ module.exports.getLinks = (id, linkId, callback) => {
linkId = Number(linkId) || 0;
if (id < 1) {
return callback(new Error('Missing Campaign ID'));
return callback(new Error(_('Missing Campaign ID')));
}
db.getConnection((err, connection) => {
@ -569,11 +570,11 @@ module.exports.create = (campaign, opts, callback) => {
campaign.template = Number(campaign.template) || 0;
if (!name) {
return callback(new Error('Campaign Name must be set'));
return callback(new Error(_('Campaign Name must be set')));
}
if (campaign.type === 2 && (!campaign.sourceUrl || !isUrl(campaign.sourceUrl))) {
return callback(new Error('RSS URL must be set and needs to be a valid URL'));
return callback(new Error(_('RSS URL must be set and needs to be a valid URL')));
}
let getList = (listId, callback) => {
@ -726,7 +727,7 @@ module.exports.create = (campaign, opts, callback) => {
return callback(err);
}
if (!template) {
return callback(new Error('Selected template not found'));
return callback(new Error(_('Selected template not found')));
}
campaign.editorName = template.editorName;
@ -748,7 +749,7 @@ module.exports.update = (id, updates, callback) => {
id = Number(id) || 0;
if (id < 1) {
return callback(new Error('Missing Campaign ID'));
return callback(new Error(_('Missing Campaign ID')));
}
let campaign = tools.convertKeys(updates);
@ -757,7 +758,7 @@ module.exports.update = (id, updates, callback) => {
campaign.trackingDisabled = campaign.trackingDisabled ? 1 : 0;
if (!name) {
return callback(new Error('Campaign Name must be set'));
return callback(new Error(_('Campaign Name must be set')));
}
if (/^\d+:\d+$/.test(campaign.list)) {
@ -877,7 +878,7 @@ module.exports.delete = (id, callback) => {
id = Number(id) || 0;
if (id < 1) {
return callback(new Error('Missing Campaign ID'));
return callback(new Error(_('Missing Campaign ID')));
}
db.getConnection((err, connection) => {
@ -1078,7 +1079,7 @@ module.exports.getMail = (campaignId, listId, subscriptionId, callback) => {
subscriptionId = Number(subscriptionId) || 0;
if (campaignId < 1 || listId < 1 || subscriptionId < 1) {
return callback(new Error('Invalid or missing message ID'));
return callback(new Error(_('Invalid or missing message ID')));
}
db.getConnection((err, connection) => {