Repository: fossasia/open-event-server

Issue:
Make subjects of all mails translatable
Currently session state mails and subjects of all mails are not translatable. Please make it possible to translate them.

For example, where are the strings for this email? Where can this be translated?

```
        },
        'canceled': {
            'subject': 'Canceled! Your submission for {event_name} titled {session_name} has been Canceled',
            'message': "Hello,<br/><br/>"
            "This is an automatic message from {app_name}.<br/><br/>"
            "Your session status for the submission {session_name} for {event_name} was changed to \"Canceled\".<br/><br/>"
            "The status change was done by event organizers. If there are questions about this change please contact the organizers.<br/><br/>"
            "You can also check the status and details of your submission on the session page {session_cfs_link}. You need to be logged in to view it.<br/><br/>"
            "More details about the event are on the event page at {event_link}.<br/><br/>"
            "Thank you.<br/>"
            "{frontend_link}",
        },
```

_Originally posted by @mariobehling in https://github.com/fossasia/open-event-server/issues/8321#issuecomment-954752178_


Discussion:
After the last PR in the mails "New order for" there is a quote sign in front of eventyay (appName).

![Screenshot from 2021-11-10 15-35-12](https://user-images.githubusercontent.com/1583873/141132851-3af91908-c4e6-4235-95e2-fbebf78477b8.png)

will correct this in this PR
The subject of mails is translatable in the translation system, but it does not show up in the subject of recipients if an email is in German for example. Therefore reopening this.

![Screenshot from 2021-11-20 07-02-12](https://user-images.githubusercontent.com/1583873/142716343-1b03a722-2a28-4197-87ca-f11e29835d31.png)

Kindly asign me this issue
@anjali1102 We don't assign issues to external contributors. Please start working on the issue and make a draft PR. We'll help you along the way.

Resolving patch:
diff --git a/app/api/helpers/system_mails.py b/app/api/helpers/system_mails.py
--- a/app/api/helpers/system_mails.py
+++ b/app/api/helpers/system_mails.py
@@ -3,7 +3,7 @@
 Register a mail here before using it
 """
 
-from flask_babel import _
+from flask_babel import lazy_gettext
 
 class MailType:
     USER_REGISTER = 'user_registration'
@@ -60,7 +60,7 @@ def entries():
     MailType.SESSION_STATE_CHANGE: {
         'recipient': 'Speaker',
         'pending': {
-            'subject': _('Your speaker submission for {event_name} titled {session_name}'),
+            'subject': lazy_gettext('Your speaker submission for {event_name} titled {session_name}'),
             'message': "Hello,<br/><br/>"
             "This is an automatic message from {app_name}.<br/><br/>"
             "We have received your submission {session_name} for {event_name}<br/><br/>"
@@ -71,7 +71,7 @@ def entries():
             "{frontend_link}",
         },
         'accepted': {
-            'subject': _('Accepted! Congratulations Your submission for {event_name} titled {session_name} has been Accepted'),
+            'subject': lazy_gettext('Accepted! Congratulations Your submission for {event_name} titled {session_name} has been Accepted'),
             'message': "Hello,<br/><br/>"
             "This is an automatic message from {app_name}.<br/><br/>"
             "Your session status for the submission {session_name} for {event_name} was changed to \"Accepted\". Congratulations!<br/><br/>"
@@ -82,7 +82,7 @@ def entries():
             "{frontend_link}",
         },
         'confirmed': {
-            'subject': _('Confirmed! Congratulations Your submission for {event_name} titled {session_name} has been Confirmed'),
+            'subject': lazy_gettext('Confirmed! Congratulations Your submission for {event_name} titled {session_name} has been Confirmed'),
             'message': "Hello,<br/><br/>"
             "This is an automatic message from {app_name}.<br/><br/>"
             "Your session status for the submission {session_name} for {event_name} was changed to \"Confirmed\". Congratulations!<br/><br/>"
@@ -93,7 +93,7 @@ def entries():
             "{frontend_link}",
         },
         'rejected': {
-            'subject': _('Not Accepted. Your submission for {event_name} titled {session_name} was not accepted'),
+            'subject': lazy_gettext('Not Accepted. Your submission for {event_name} titled {session_name} was not accepted'),
             'message': "Hello,<br/><br/>"
             "This is an automatic message from {app_name}.<br/><br/>"
             "Unfortunately your submission {session_name} for {event_name} was not accepted. Your session status was changed to \"Rejected\".<br/><br/>"
@@ -104,7 +104,7 @@ def entries():
             "{frontend_link}",
         },
         'canceled': {
-            'subject': _('Canceled! Your submission for {event_name} titled {session_name} has been Canceled'),
+            'subject': lazy_gettext('Canceled! Your submission for {event_name} titled {session_name} has been Canceled'),
             'message': "Hello,<br/><br/>"
             "This is an automatic message from {app_name}.<br/><br/>"
             "Your session status for the submission {session_name} for {event_name} was changed to \"Canceled\".<br/><br/>"
@@ -115,7 +115,7 @@ def entries():
             "{frontend_link}",
         },
         'withdrawn': {
-            'subject': _('Withdrawn! Your submission for {event_name} titled {session_name} has been Withdrawn'),
+            'subject': lazy_gettext('Withdrawn! Your submission for {event_name} titled {session_name} has been Withdrawn'),
             'message': "Hello,<br/><br/>"
             "This is an automatic message from {app_name}.<br/><br/>"
             "Your session status for the submission {session_name} for {event_name} was changed to \"Withdrawn\".<br/><br/>"
@@ -128,131 +128,131 @@ def entries():
     },
     MailType.TICKET_SALES_END: {
         'recipient': 'Owner, Organizer',
-        'subject': _('Ticket Sales Period for One or Several Tickets for {event_name} Ended'),
+        'subject': lazy_gettext('Ticket Sales Period for One or Several Tickets for {event_name} Ended'),
         'template': 'email/ticket_sales_end.html',
     },
     MailType.TICKET_SALES_END_TOMORROW: {
         'recipient': 'Owner, Organizer',
-        'subject': _('Ticket Sales Period for One or Several Tickets for {event_name} Ending in 24 Hours'),
+        'subject': lazy_gettext('Ticket Sales Period for One or Several Tickets for {event_name} Ending in 24 Hours'),
         'template': 'email/ticket_sales_end_tomorrow.html',
     },
     MailType.TICKET_SALES_END_NEXT_WEEK: {
         'recipient': 'Owner, Organizer',
-        'subject': _('Ticket Sales Period fors One or Several Tickets for {event_name} Ending in 7 Days'),
+        'subject': lazy_gettext('Ticket Sales Period fors One or Several Tickets for {event_name} Ending in 7 Days'),
         'template': 'email/ticket_sales_end_next_week.html',
     },
     MailType.NEW_SESSION: {
         'recipient': 'Owner, Organizer',
-        'subject': _('New session proposal for {session.event.name} titled {session.title}'),
+        'subject': lazy_gettext('New session proposal for {session.event.name} titled {session.title}'),
         'template': 'email/new_session.html',
     },
     MailType.USER_REGISTER: {
         'recipient': 'User',
-        'subject': _('Welcome to {app_name}. Please verify your account'),
+        'subject': lazy_gettext('Welcome to {app_name}. Please verify your account'),
         'template': 'email/user_register.html',
     },
     MailType.USER_CONFIRM: {
         'recipient': 'User',
-        'subject': _('Email Confirmation to Create Account for {app_name}'),
+        'subject': lazy_gettext('Email Confirmation to Create Account for {app_name}'),
         'template': 'email/user_confirm.html',
     },
     MailType.USER_CHANGE_EMAIL: {
         'recipient': 'User',
-        'subject': _('Your email has been already changed'),
+        'subject': lazy_gettext('Your email has been already changed'),
         'template': 'email/user_change_email.html',
     },
     MailType.PASSWORD_RESET: {
         'recipient': 'User',
-        'subject': _('{app_name}: Password Reset'),
+        'subject': lazy_gettext('{app_name}: Password Reset'),
         'template': 'email/password_reset.html',
     },
     MailType.PASSWORD_RESET_AND_VERIFY: {
         'recipient': 'User',
-        'subject': _('{app_name}: Reset your password and verify your account'),
+        'subject': lazy_gettext('{app_name}: Reset your password and verify your account'),
         'template': 'email/password_reset_and_verify.html',
     },
     MailType.PASSWORD_CHANGE: {
         'recipient': 'User',
-        'subject': _('{app_name}: Password Change'),
+        'subject': lazy_gettext('{app_name}: Password Change'),
         'template': 'email/password_change.html',
     },
     MailType.EVENT_ROLE: {
         'recipient': 'User',
-        'subject': _('Invitation to be {role} at Event: {event}'),
+        'subject': lazy_gettext('Invitation to be {role} at Event: {event}'),
         'template': 'email/event_role.html',
     },
     MailType.SPEAKER_INVITE: {
         'recipient': 'User',
-        'subject': _('Invitation to be speaker at Session: {session}'),
+        'subject': lazy_gettext('Invitation to be speaker at Session: {session}'),
         'template': 'email/speaker_invite.html',
     },
     MailType.GROUP_ROLE: {
         'recipient': 'User',
-        'subject': _('Invitation to be {role} at Group: {group}'),
+        'subject': lazy_gettext('Invitation to be {role} at Group: {group}'),
         'template': 'email/group_role.html',
     },
     MailType.TICKET_PURCHASED: {
         'recipient': 'User',
-        'subject': _('See you at {event_name} on {event_date} at {event_time} ({invoice_id}) '),
+        'subject': lazy_gettext('See you at {event_name} on {event_date} at {event_time} ({invoice_id}) '),
         'template': 'email/ticket_purchased.html',
     },
     MailType.TICKET_PURCHASED_ATTENDEE: {
         'recipient': 'Attendee',
-        'subject': _('Your tickets for {event_name} on {event_date} at {event_time} ({invoice_id}) '),
+        'subject': lazy_gettext('Your tickets for {event_name} on {event_date} at {event_time} ({invoice_id}) '),
         'template': 'email/ticket_purchased_attendee.html',
     },
     MailType.TICKET_PURCHASED_ORGANIZER: {
         'recipient': 'Owner, Organizer, Coorganizer',
-        'subject': _('New order for {event_name} on {event_date} by {buyer_name}, {buyer_email} ({invoice_id}) '),
+        'subject': lazy_gettext('New order for {event_name} on {event_date} by {buyer_name}, {buyer_email} ({invoice_id}) '),
         'template': 'email/ticket_purchased_organizer.html',
     },
     MailType.TICKET_CANCELLED: {
         'recipient': 'User',
-        'subject': _('Your order for {event_name} has been cancelled ({invoice_id})'),
+        'subject': lazy_gettext('Your order for {event_name} has been cancelled ({invoice_id})'),
         'template': 'email/ticket_cancelled.html',
     },
     MailType.EVENT_EXPORTED: {
         'recipient': 'User',
-        'subject': _('Event {event_name} has been exported'),
+        'subject': lazy_gettext('Event {event_name} has been exported'),
         'template': 'email/event_exported.html',
     },
     MailType.EVENT_EXPORT_FAIL: {
         'recipient': 'User',
-        'subject': _('Export of event {event_name} failed'),
+        'subject': lazy_gettext('Export of event {event_name} failed'),
         'template': 'email/event_export_fail.html',
     },
     MailType.MONTHLY_PAYMENT: {
         'recipient': 'Owner',
-        'subject': _('Your invoice for {event_name} for {date} is available on {app_name}'),
+        'subject': lazy_gettext('Your invoice for {event_name} for {date} is available on {app_name}'),
         'sent_at': '1st day of the month',
         'template': 'email/monthly_payment_email.html',
     },
     MailType.MONTHLY_PAYMENT_FOLLOWUP: {
         'recipient': 'Owner',
-        'subject': _('Reminder: Your invoice for {event_name} for {date} is available on {app_name}'),
+        'subject': lazy_gettext('Reminder: Your invoice for {event_name} for {date} is available on {app_name}'),
         'sent_at': '15th day of the month',
         'template': 'email/monthly_payment_followup_email.html',
     },
     MailType.MONTHLY_PAYMENT_PRE_DUE: {
         'recipient': 'Owner',
-        'subject': _('Reminder: Your invoice for {event_name} for {date} is available on {app_name}'),
+        'subject': lazy_gettext('Reminder: Your invoice for {event_name} for {date} is available on {app_name}'),
         'sent_at': '27th day of the month',
         'template': 'email/monthly_payment_pre_due_email.html',
     },
     MailType.MONTHLY_PAYMENT_POST_DUE: {
         'recipient': 'Owner',
-        'subject': _('Please pay your overdue invoice for {event_name} for {date} on {app_name}'),
+        'subject': lazy_gettext('Please pay your overdue invoice for {event_name} for {date} on {app_name}'),
         'sent_at': '30th day of the month',
         'template': 'email/monthly_payment_post_due_email.html',
     },
     MailType.EVENT_IMPORTED: {
         'recipient': 'User',
-        'subject': _('Event {event_name} has been imported'),
+        'subject': lazy_gettext('Event {event_name} has been imported'),
         'template': 'email/event_imported.html',
     },
     MailType.EVENT_IMPORT_FAIL: {
         'recipient': 'User',
-        'subject': _('Import of event failed'),
+        'subject': lazy_gettext('Import of event failed'),
         'template': 'email/event_import_fail.html',
     },
     MailType.CONTACT_ORGANIZERS: {
@@ -265,27 +265,27 @@ def entries():
     },
     MailType.TEST_MAIL: {
         'recipient': 'User',
-        'subject': _('Test Mail Subject'),
+        'subject': lazy_gettext('Test Mail Subject'),
         'message': ("This is a  <strong> Test </strong> E-mail."),
     },
     MailType.VIDEO_MODERATOR_INVITE: {
         'recipient': 'User',
-        'subject': _('Video Moderator of video {video_name} at event {event_name}'),
+        'subject': lazy_gettext('Video Moderator of video {video_name} at event {event_name}'),
         'template': 'email/video_stream_moderator.html',
     },
     MailType.ANNOUNCE_EVENT: {
         'recipient': 'User',
-        'subject': _('Join {event_name} from {group_name} on {event_date}'),
+        'subject': lazy_gettext('Join {event_name} from {group_name} on {event_date}'),
         'template': 'email/announce_event.html',
     },
     MailType.AFTER_EVENT: {
         'recipient': 'Owner, Organizer, Coorganizer',
-        'subject': _('{event_name} is over. Thank you for using {app_name}!'),
+        'subject': lazy_gettext('{event_name} is over. Thank you for using {app_name}!'),
         'template': 'email/after_event.html',
     },
     MailType.AFTER_EVENT_SPEAKER: {
         'recipient': 'User',
-        'subject': _('{event_name} is over. Thank you for participating!'),
+        'subject': lazy_gettext('{event_name} is over. Thank you for participating!'),
         'template': 'email/after_event_speaker.html',
     },
 }


Test patch: