🐛(mail) fix team invitation subject not translated
Using format or f-string breaks translations
This commit is contained in:
@@ -1057,10 +1057,9 @@ class Invitation(BaseInvitation):
|
||||
|
||||
def _get_mail_subject(self):
|
||||
"""Get the subject of the team invitation."""
|
||||
role = self.get_role_display().lower()
|
||||
return gettext(
|
||||
f"[La Suite] You have been invited to become a {role} of a group"
|
||||
)
|
||||
"[La Suite] You have been invited to become a %(role)s of a group"
|
||||
) % {"role": self.get_role_display().lower()}
|
||||
|
||||
def _get_mail_context(self):
|
||||
"""Get the template variables for the invitation."""
|
||||
|
||||
@@ -246,9 +246,8 @@ def test_models_team_invitations_email():
|
||||
# pylint: disable-next=no-member
|
||||
assert len(mail.outbox) == 0
|
||||
|
||||
# Please add test for french language after translations update
|
||||
invitation = factories.InvitationFactory(
|
||||
role="member", team=team, email="john@people.com", issuer__language="en-us"
|
||||
role="member", team=team, email="john@people.com", issuer__language="fr-fr"
|
||||
)
|
||||
|
||||
# pylint: disable-next=no-member
|
||||
@@ -259,13 +258,12 @@ def test_models_team_invitations_email():
|
||||
|
||||
assert email.to == [invitation.email]
|
||||
assert (
|
||||
email.subject
|
||||
== "[La Suite] You have been invited to become a member of a group"
|
||||
email.subject == "[La Suite] Vous avez été invité(e) à être membre d'un groupe"
|
||||
)
|
||||
|
||||
email_content = " ".join(email.body.split())
|
||||
assert (
|
||||
f"""You have been invited to be a member of the group "{team.name}" within La Suite."""
|
||||
f"""Vous avez été invité(e) à être membre du groupe "{team.name}" au sein de la Suite."""
|
||||
in email_content
|
||||
)
|
||||
assert "[//example.com]" in email_content
|
||||
|
||||
Binary file not shown.
@@ -324,8 +324,8 @@ msgstr "Invitations d'équipe"
|
||||
|
||||
#: build/lib/core/models.py:1062 core/models.py:1062
|
||||
#, python-brace-format
|
||||
msgid "[La Suite] You have been invited to become a {role} of a group"
|
||||
msgstr "[La Suite] Vous avez été invité(e) à être {role} d'un groupe"
|
||||
msgid "[La Suite] You have been invited to become a %(role)s of a group"
|
||||
msgstr "[La Suite] Vous avez été invité(e) à être %(role)s d'un groupe"
|
||||
|
||||
#: build/lib/mailbox_manager/admin.py:17 mailbox_manager/admin.py:17
|
||||
msgid "Synchronise from dimail"
|
||||
|
||||
Reference in New Issue
Block a user