diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index 4304f2d..45e0216 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -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" @@ -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" diff --git a/locale/en/LC_MESSAGES/django.po b/locale/en/LC_MESSAGES/django.po index 5e8c2a7..d0427ef 100644 --- a/locale/en/LC_MESSAGES/django.po +++ b/locale/en/LC_MESSAGES/django.po @@ -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" @@ -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!" diff --git a/locale/es/LC_MESSAGES/django.po b/locale/es/LC_MESSAGES/django.po index 967f761..a1757de 100644 --- a/locale/es/LC_MESSAGES/django.po +++ b/locale/es/LC_MESSAGES/django.po @@ -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" @@ -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" diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 1a8bb84..65116e4 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \n" @@ -113,7 +113,8 @@ msgid "" "%(email_author)s a créé un nouveau BCF dans le projet " "%(project_name)s." msgstr "" -"%(email_author)s a créée un nouveau BCF dans le projet %(project_name)s." +"%(email_author)s a créée un nouveau BCF dans le projet " +"%(project_name)s." #: templates/mails/notifications-bcf.html:259 #: templates/mails/notifications-bcf.html:427 @@ -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" diff --git a/locale/it/LC_MESSAGES/django.po b/locale/it/LC_MESSAGES/django.po index 156547d..4d0f026 100644 --- a/locale/it/LC_MESSAGES/django.po +++ b/locale/it/LC_MESSAGES/django.po @@ -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" @@ -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!" diff --git a/utils/mailer.py b/utils/mailer.py index 4b702c9..c9abf83 100644 --- a/utils/mailer.py +++ b/utils/mailer.py @@ -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") @@ -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] @@ -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( diff --git a/utils/tests/test_mails.py b/utils/tests/test_mails.py index ea17ed1..9ff5354 100644 --- a/utils/tests/test_mails.py +++ b/utils/tests/test_mails.py @@ -1,14 +1,19 @@ from django.core import mail from django.test import TestCase -from utils import mailer -from parameterized import parameterized from django.utils.translation import activate +from parameterized import parameterized + +from utils import mailer class EmailTest(TestCase): @parameterized.expand( [ - ("mailing-welcome", {}, "Bienvenue sur la plateforme BIMData.io"), + ( + "mailing-welcome", + {"user_name": "Jane"}, + "Bienvenue sur la plateforme BIMData.io Jane", + ), ] ) def test_send_email_invitation_with_django(