Skip to content

Commit

Permalink
feat: customize welcome email subject with user name
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasRichel committed Nov 23, 2023
1 parent b313bdd commit 2f66b82
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 20 deletions.
8 changes: 5 additions & 3 deletions locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Platform Back\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-23 08:08+0000\n"
"POT-Creation-Date: 2023-11-23 13:41+0000\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -188,5 +188,7 @@ msgid "Nouvelle notification Visa"
msgstr ""

#: utils/mailer.py:18
msgid "Bienvenue sur la plateforme BIMData.io"
msgstr "Willkommen auf der Plattform BIMData.io"
#, fuzzy, python-format
#| msgid "Bienvenue sur la plateforme BIMData.io"
msgid "Bienvenue sur la plateforme BIMData.io %(user_name)s"
msgstr "Willkommen auf der Plattform BIMData.io %(user_name)s"
8 changes: 5 additions & 3 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Platform Back\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-23 08:08+0000\n"
"POT-Creation-Date: 2023-11-23 13:41+0000\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -187,5 +187,7 @@ msgid "Nouvelle notification Visa"
msgstr "New validation notification"

#: utils/mailer.py:18
msgid "Bienvenue sur la plateforme BIMData.io"
msgstr "Welcome to BIMData.io Platform!"
#, fuzzy, python-format
#| msgid "Bienvenue sur la plateforme BIMData.io"
msgid "Bienvenue sur la plateforme BIMData.io %(user_name)s"
msgstr "Welcome to BIMData.io Platform %(user_name)s!"
8 changes: 5 additions & 3 deletions locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Platform Back\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-23 08:10+0000\n"
"POT-Creation-Date: 2023-11-23 13:41+0000\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -184,5 +184,7 @@ msgid "Nouvelle notification Visa"
msgstr ""

#: utils/mailer.py:18
msgid "Bienvenue sur la plateforme BIMData.io"
msgstr "Te damos la bienvenida a la plataforma BIMData.io"
#, fuzzy, python-format
#| msgid "Bienvenue sur la plateforme BIMData.io"
msgid "Bienvenue sur la plateforme BIMData.io %(user_name)s"
msgstr "Te damos la bienvenida a la plataforma BIMData.io %(user_name)s"
9 changes: 6 additions & 3 deletions locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-23 08:08+0000\n"
"POT-Creation-Date: 2023-11-23 13:41+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -113,7 +113,8 @@ msgid ""
"<strong>%(email_author)s</strong> a créé un nouveau BCF dans le projet "
"<strong>%(project_name)s</strong>."
msgstr ""
"<strong>%(email_author)s</strong> a créée un nouveau BCF dans le projet <strong>%(project_name)s</strong>."
"<strong>%(email_author)s</strong> a créée un nouveau BCF dans le projet "
"<strong>%(project_name)s</strong>."

#: templates/mails/notifications-bcf.html:259
#: templates/mails/notifications-bcf.html:427
Expand Down Expand Up @@ -208,5 +209,7 @@ msgid "Nouvelle notification Visa"
msgstr "Nouvelle notification Visa"

#: utils/mailer.py:18
msgid "Bienvenue sur la plateforme BIMData.io"
#, fuzzy, python-format
#| msgid "Bienvenue sur la plateforme BIMData.io"
msgid "Bienvenue sur la plateforme BIMData.io %(user_name)s"
msgstr "Bienvenue sur la plateforme BIMData.io"
8 changes: 5 additions & 3 deletions locale/it/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Platform Back\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-23 08:08+0000\n"
"POT-Creation-Date: 2023-11-23 13:41+0000\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -185,5 +185,7 @@ msgid "Nouvelle notification Visa"
msgstr ""

#: utils/mailer.py:18
msgid "Bienvenue sur la plateforme BIMData.io"
msgstr "Benvenuto sulla piattaforma BIMData.io!"
#, fuzzy, python-format
#| msgid "Bienvenue sur la plateforme BIMData.io"
msgid "Bienvenue sur la plateforme BIMData.io %(user_name)s"
msgstr "Benvenuto sulla piattaforma BIMData.io %(user_name)s!"
8 changes: 3 additions & 5 deletions utils/mailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
from django.conf import settings
from django.core.mail import EmailMessage
from django.core.mail import get_connection
from django.template import engines
from django.template.loader import render_to_string
from django.utils import translation
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy as _

logger = logging.getLogger("django")

Expand All @@ -15,7 +14,7 @@ def subjects(template_name):
subs = {
"notifications-bcf": _("Nouvelle notification BCF"),
"notifications-visa": _("Nouvelle notification Visa"),
"mailing-welcome": _("Bienvenue sur la plateforme BIMData.io"),
"mailing-welcome": _("Bienvenue sur la plateforme BIMData.io %(user_name)s"),
}
return subs[template_name]

Expand All @@ -36,8 +35,7 @@ def send_mail(
content["bimdata_url"] = settings.PLATFORM_URL

with translation.override(language):
template_subject = engines["django"].from_string(subjects(template_name))
subject = template_subject.render()
subject = subjects(template_name) % content
html_content = render_to_string(f"mails/{template_name}.html", content)
if settings.APP_EMAIL_HOST:
connection = get_connection(
Expand Down

0 comments on commit 2f66b82

Please sign in to comment.