From a87cc524a641fbde0de8f0f868d05d44eea4aacf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 23 Sep 2021 14:04:58 +0200 Subject: [PATCH] Translate e-mail subject --- .../helpers/email/templateBuilder.js | 18 ++++++------------ .../email/templates/de/notification.html | 1 + .../email/templates/en/notification.html | 1 + 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/backend/src/middleware/helpers/email/templateBuilder.js b/backend/src/middleware/helpers/email/templateBuilder.js index dd4985327..0d9972c76 100644 --- a/backend/src/middleware/helpers/email/templateBuilder.js +++ b/backend/src/middleware/helpers/email/templateBuilder.js @@ -106,9 +106,8 @@ export const wrongAccountTemplate = ({ email }) => { } export const notificationTemplate = ({ email, notification }) => { - // TODO Wolle language - const subject = `${CONFIG.APPLICATION_NAME} – Benachrichtigung | Notification` const actionUrl = new URL('/notifications', CONFIG.CLIENT_URI) + const renderParams = { ...defaultParams, name: notification.to.name, actionUrl } let content switch (notification.to.locale) { case 'de': @@ -122,24 +121,19 @@ export const notificationTemplate = ({ email, notification }) => { content = templatesEN.notification break } + const subjectUnrendered = content.split('\n')[0].split('"')[1] + const subject = mustache.render(subjectUnrendered, renderParams, {}) + // Wolle console.log('subject: ', subject) // Wolle // console.log( - // mustache.render( - // templates.layout, - // { ...defaultParams, name: notification.to.name, actionUrl }, - // { content }, - // ), + // mustache.render(templates.layout, renderParams, { content }), // ) return { from, to: email, subject, - html: mustache.render( - templates.layout, - { ...defaultParams, name: notification.to.name, actionUrl }, - { content }, - ), + html: mustache.render(templates.layout, renderParams, { content }), } } diff --git a/backend/src/middleware/helpers/email/templates/de/notification.html b/backend/src/middleware/helpers/email/templates/de/notification.html index 24e2257e0..1c8092f9d 100644 --- a/backend/src/middleware/helpers/email/templates/de/notification.html +++ b/backend/src/middleware/helpers/email/templates/de/notification.html @@ -1,3 +1,4 @@ + diff --git a/backend/src/middleware/helpers/email/templates/en/notification.html b/backend/src/middleware/helpers/email/templates/en/notification.html index d32a7aecf..bd4cbb8a7 100644 --- a/backend/src/middleware/helpers/email/templates/en/notification.html +++ b/backend/src/middleware/helpers/email/templates/en/notification.html @@ -1,3 +1,4 @@ +