More work in email translations
This commit is contained in:
parent
af042b8722
commit
c67609b417
9 changed files with 37 additions and 20 deletions
|
|
@ -6,21 +6,27 @@ import getPrivateFile from '../../../modules/server/get-private-file';
|
|||
import templateToHTML from '../../../modules/server/handlebars-email-to-html';
|
||||
import templateToText from '../../../modules/server/handlebars-email-to-text';
|
||||
|
||||
const name = i18n.t('AppName');
|
||||
const name = (lang) => {
|
||||
i18n.changeLanguage(lang);
|
||||
return i18n.t('AppName');
|
||||
};
|
||||
const email = '<noreply@comunes.org>';
|
||||
const from = `${name} ${email}`;
|
||||
const from = `${name('en')} ${email}`;
|
||||
// const from = 'noreply@comunes.org';
|
||||
const emailTemplates = Accounts.emailTemplates;
|
||||
|
||||
emailTemplates.siteName = name;
|
||||
emailTemplates.from = from;
|
||||
|
||||
emailTemplates.verifyEmail = {
|
||||
subject() {
|
||||
return `[${name}] Verify Your Email Address`;
|
||||
subject(user) {
|
||||
i18n.changeLanguage(user.lang);
|
||||
const msg = i18n.t('Verifica tu dirección de correo');
|
||||
return `[${name(user.lang)}] ${msg}`;
|
||||
},
|
||||
html(user, url) {
|
||||
return templateToHTML(getPrivateFile(getFileNameOfLang('email-templates', 'verify-email', 'html', user.lang)), {
|
||||
applicationName: name,
|
||||
applicationName: name(user.lang),
|
||||
firstName: user.profile.name.first,
|
||||
verifyUrl: url.replace('#/', '')
|
||||
});
|
||||
|
|
@ -29,7 +35,7 @@ emailTemplates.verifyEmail = {
|
|||
const urlWithoutHash = url.replace('#/', '');
|
||||
if (Meteor.isDevelopment) console.info(`Verify Email Link: ${urlWithoutHash}`); // eslint-disable-line
|
||||
return templateToText(getPrivateFile(getFileNameOfLang('email-templates', 'verify-email', 'txt', user.lang)), {
|
||||
applicationName: name,
|
||||
applicationName: name(user.lang),
|
||||
firstName: user.profile.name.first,
|
||||
verifyUrl: urlWithoutHash
|
||||
});
|
||||
|
|
@ -37,13 +43,15 @@ emailTemplates.verifyEmail = {
|
|||
};
|
||||
|
||||
emailTemplates.resetPassword = {
|
||||
subject() {
|
||||
return `[${name}] Reset Your Password`;
|
||||
subject(user) {
|
||||
i18n.changeLanguage(user.lang);
|
||||
const msg = i18n.t('Resetea tu contraseña');
|
||||
return `[${name(user.lang)}] ${msg}`;
|
||||
},
|
||||
html(user, url) {
|
||||
return templateToHTML(getPrivateFile(getFileNameOfLang('email-templates', 'reset-password', 'html', user.lang)), {
|
||||
firstName: user.profile.name.first,
|
||||
applicationName: name,
|
||||
applicationName: name(user.lang),
|
||||
emailAddress: user.emails[0].address,
|
||||
resetUrl: url.replace('#/', '')
|
||||
});
|
||||
|
|
@ -53,7 +61,7 @@ emailTemplates.resetPassword = {
|
|||
if (Meteor.isDevelopment) console.info(`Reset Password Link: ${urlWithoutHash}`); // eslint-disable-line
|
||||
return templateToText(getPrivateFile(getFileNameOfLang('email-templates', 'reset-password', 'txt', user.lang)), {
|
||||
firstName: user.profile.name.first,
|
||||
applicationName: name,
|
||||
applicationName: name(user.lang),
|
||||
emailAddress: user.emails[0].address,
|
||||
resetUrl: urlWithoutHash
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,15 +3,17 @@ import sendWelcomeEmail from '../../../api/Users/server/send-welcome-email';
|
|||
|
||||
Accounts.onCreateUser((options, user) => {
|
||||
const userToCreate = user;
|
||||
console.log(JSON.stringify(user));
|
||||
console.log(JSON.stringify(options));
|
||||
// console.log(JSON.stringify(user));
|
||||
// console.log(JSON.stringify(options));
|
||||
let lang = 'en'; // fallback
|
||||
if (options.profile) {
|
||||
userToCreate.profile = options.profile;
|
||||
userToCreate.lang = options.profile.lang;
|
||||
lang = options.profile.lang;
|
||||
delete options.profile.lang;
|
||||
} else {
|
||||
// TODO others (google, etc) ?
|
||||
}
|
||||
sendWelcomeEmail(options, userToCreate);
|
||||
sendWelcomeEmail(options, userToCreate, lang);
|
||||
return userToCreate;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ const MailQueue = new MailTime({
|
|||
}
|
||||
return `${i18n.t('AppName')} <${transport.options.auth.user}>`;
|
||||
},
|
||||
debug: true,
|
||||
debug: Meteor.settings.private.debugMailer,
|
||||
concatEmails: true, // Concatenate emails to the same addressee
|
||||
concatSubject: `${i18n.t('Nuevas notificaciones de {{app}}', { app: i18n.t('AppName') })}`,
|
||||
/* eslint-disable */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue