Add smtp test email translations

This commit is contained in:
nztqa 2017-11-28 13:26:46 +09:00
parent 332f12ce28
commit 44559b52a6
3 changed files with 17 additions and 9 deletions

View file

@ -128,11 +128,14 @@ BlazeComponent.extendComponent({
sendSMTPTestEmail() { sendSMTPTestEmail() {
Meteor.call('sendSMTPTestEmail', (err, ret) => { Meteor.call('sendSMTPTestEmail', (err, ret) => {
if (!err && ret) { /* eslint-disable no-console */ if (!err && ret) { /* eslint-disable no-console */
console.log('Success:', ret.message, ret.email); const message = `${TAPi18n.__(ret.message)}: ${ret.email}`;
alert('Success'); console.log(message);
alert(message);
} else { } else {
console.log('Error: Sending test email', err); const reason = err.reason || '';
alert(err); const message = `${TAPi18n.__(err.error)}\n${reason}`;
console.log(message, err);
alert(message);
} /* eslint-enable no-console */ } /* eslint-enable no-console */
}); });
}, },

View file

@ -184,6 +184,7 @@
"email-enrollAccount-subject": "An account created for you on __siteName__", "email-enrollAccount-subject": "An account created for you on __siteName__",
"email-enrollAccount-text": "Hello __user__,\n\nTo start using the service, simply click the link below.\n\n__url__\n\nThanks.", "email-enrollAccount-text": "Hello __user__,\n\nTo start using the service, simply click the link below.\n\n__url__\n\nThanks.",
"email-fail": "Sending email failed", "email-fail": "Sending email failed",
"email-fail-text": "Error trying to send email",
"email-invalid": "Invalid email", "email-invalid": "Invalid email",
"email-invite": "Invite via Email", "email-invite": "Invite via Email",
"email-invite-subject": "__inviter__ sent you an invitation", "email-invite-subject": "__inviter__ sent you an invitation",
@ -239,6 +240,7 @@
"initials": "Initials", "initials": "Initials",
"invalid-date": "Invalid date", "invalid-date": "Invalid date",
"invalid-time": "Invalid time", "invalid-time": "Invalid time",
"invalid-user": "Invalid user",
"joined": "joined", "joined": "joined",
"just-invited": "You are just invited to this board", "just-invited": "You are just invited to this board",
"keyboard-shortcuts": "Keyboard shortcuts", "keyboard-shortcuts": "Keyboard shortcuts",
@ -390,6 +392,8 @@
"invitation-code": "Invitation Code", "invitation-code": "Invitation Code",
"email-invite-register-subject": "__inviter__ sent you an invitation", "email-invite-register-subject": "__inviter__ sent you an invitation",
"email-invite-register-text": "Dear __user__,\n\n__inviter__ invites you to Wekan for collaborations.\n\nPlease follow the link below:\n__url__\n\nAnd your invitation code is: __icode__\n\nThanks.", "email-invite-register-text": "Dear __user__,\n\n__inviter__ invites you to Wekan for collaborations.\n\nPlease follow the link below:\n__url__\n\nAnd your invitation code is: __icode__\n\nThanks.",
"email-smtp-test-subject": "SMTP Test Email From Wekan",
"email-smtp-test-text": "You have successfully sent an email",
"error-invitation-code-not-exist": "Invitation code doesn't exist", "error-invitation-code-not-exist": "Invitation code doesn't exist",
"error-notAuthorized": "You are not authorized to view this page.", "error-notAuthorized": "You are not authorized to view this page.",
"outgoing-webhooks": "Outgoing Webhooks", "outgoing-webhooks": "Outgoing Webhooks",

View file

@ -144,22 +144,23 @@ if (Meteor.isServer) {
sendSMTPTestEmail() { sendSMTPTestEmail() {
if (!Meteor.userId()) { if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user'); throw new Meteor.Error('invalid-user');
} }
const user = Meteor.user(); const user = Meteor.user();
if (!user.emails && !user.emails[0] && user.emails[0].address) { if (!user.emails && !user.emails[0] && user.emails[0].address) {
throw new Meteor.Error('error-invalid-email', 'Invalid email'); throw new Meteor.Error('email-invalid');
} }
this.unblock(); this.unblock();
const lang = user.getLanguage();
try { try {
Email.send({ Email.send({
to: user.emails[0].address, to: user.emails[0].address,
from: Accounts.emailTemplates.from, from: Accounts.emailTemplates.from,
subject: 'SMTP Test Email From Wekan', subject: TAPi18n.__('email-smtp-test-subject', {lng: lang}),
text: 'You have successfully sent an email', text: TAPi18n.__('email-smtp-test-text', {lng: lang}),
}); });
} catch ({message}) { } catch ({message}) {
throw new Meteor.Error('error-email-send-failed', `Error trying to send email: ${ message }`, message); throw new Meteor.Error('email-fail', `${TAPi18n.__('email-fail-text', {lng: lang})}: ${ message }`, message);
} }
return { return {
message: 'email-sent', message: 'email-sent',