diff --git a/CHANGES.rst b/CHANGES.rst index 388f8a9ba16..028c054c9d8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,11 @@ Version 3.2.1 *Unreleased* +Internationalization +^^^^^^^^^^^^^^^^^^^^ + +- Make email templates translatable (:issue:`5263`, :pr:`5488`, thanks :user:`Leats`) + Improvements ^^^^^^^^^^^^ diff --git a/indico/modules/auth/controllers.py b/indico/modules/auth/controllers.py index 2f19eacda4b..7aa679a80db 100644 --- a/indico/modules/auth/controllers.py +++ b/indico/modules/auth/controllers.py @@ -29,7 +29,7 @@ from indico.modules.users import User, user_management_settings from indico.modules.users.controllers import RHUserBase from indico.modules.users.models.affiliations import Affiliation -from indico.util.i18n import _ +from indico.util.i18n import _, force_locale from indico.util.marshmallow import LowercaseString, ModelField, not_empty from indico.util.passwords import validate_secure_password from indico.util.signing import secure_serializer @@ -137,8 +137,9 @@ def _send_confirmation(email, salt, endpoint, template, template_args=None, url_ url_args = url_args or {} token = secure_serializer.dumps(data or email, salt=salt) url = url_for(endpoint, token=token, _external=True, **url_args) - template_module = get_template_module(template, email=email, url=url, **template_args) - send_email(make_email(email, template=template_module)) + with force_locale(None) if 'user' not in template_args else template_args['user'].force_user_locale(): + template_module = get_template_module(template, email=email, url=url, **template_args) + send_email(make_email(email, template=template_module)) flash(_('We have sent you a verification email. Please check your mailbox within the next hour and open ' 'the link in that email.')) return redirect(url_for(endpoint, **url_args)) diff --git a/indico/modules/auth/templates/emails/link_identity_verify_email.txt b/indico/modules/auth/templates/emails/link_identity_verify_email.txt index cdebcf01567..2e307ed7ccc 100644 --- a/indico/modules/auth/templates/emails/link_identity_verify_email.txt +++ b/indico/modules/auth/templates/emails/link_identity_verify_email.txt @@ -5,7 +5,7 @@ {%- endblock %} {% block header_recipient -%} - {{ user.first_name }} + {% trans name=user.first_name %}Dear {{ name }},{% endtrans %} {%- endblock %} {% block body -%} diff --git a/indico/modules/auth/templates/emails/register_verify_email.txt b/indico/modules/auth/templates/emails/register_verify_email.txt index 86cd24b7194..e9ebeb9df1f 100644 --- a/indico/modules/auth/templates/emails/register_verify_email.txt +++ b/indico/modules/auth/templates/emails/register_verify_email.txt @@ -5,12 +5,12 @@ {%- endblock %} {% block header_recipient -%} - {% trans %}user{% endtrans %} + {% trans %}Dear user,{% endtrans %} {%- endblock %} {% block body -%} {%- trans notrimmed -%} -You started the Indico profile creation process. To continue, you need to verify +You started the Indico profile creation process. To continue, you need to verify that {{ email }} is indeed your email address. Please click the following link to continue the registration process: diff --git a/indico/modules/categories/templates/display/event_list.html b/indico/modules/categories/templates/display/event_list.html index 705e35272af..94f67bfc23d 100644 --- a/indico/modules/categories/templates/display/event_list.html +++ b/indico/modules/categories/templates/display/event_list.html @@ -104,7 +104,7 @@

{% if session.user and event in session.user.favorite_events %} - {% endif%} + {% endif %} diff --git a/indico/modules/designer/templates/_list.html b/indico/modules/designer/templates/_list.html index 1fc1e8350d9..cfa4c5fb907 100644 --- a/indico/modules/designer/templates/_list.html +++ b/indico/modules/designer/templates/_list.html @@ -85,7 +85,7 @@ {% endif %} {% if not event and tpl.type.name == 'badge' and not tpl.is_ticket %} {% set inherited_default = default_badge == tpl and tpl.category != target and - not target.default_badge_template%} + not target.default_badge_template %} {% set global_default = default_badge == tpl and target.is_root %}

{{- url_for('abstracts.display_abstract', abstract, management=false, _external=true) -}} diff --git a/indico/modules/events/abstracts/templates/emails/default_accept_notification.txt b/indico/modules/events/abstracts/templates/emails/default_accept_notification.txt index a7fc25eb23f..02c9d4287ff 100644 --- a/indico/modules/events/abstracts/templates/emails/default_accept_notification.txt +++ b/indico/modules/events/abstracts/templates/emails/default_accept_notification.txt @@ -1,24 +1,27 @@ {% extends 'events/abstracts/emails/default_notification.txt' %} {% block subject -%} - Abstract Acceptance notification (#{abstract_id}) + {% trans %}Abstract Acceptance notification (#{abstract_id}){% endtrans %} {%- endblock %} {% block body -%} - We're pleased to announce that your abstract "{abstract_title}" with ID #{abstract_id} has been accepted in track "{abstract_track}" ({contribution_type}). + {# TODO: How to handle the placeholders with the translation? #} + {% trans notrimmed -%} + We're pleased to announce that your abstract "{abstract_title}" with ID #{abstract_id} has been accepted in track "{abstract_track}" ({contribution_type}). - See below a summary of your submitted abstract: - Conference: {event_title} - Submitted by: {submitter_name} - Title: {abstract_title} - Primary Authors: {primary_authors} - Co-authors: {co_authors} - Track classification: {abstract_track} - Presentation type: {contribution_type} + See below a summary of your submitted abstract: + Conference: {event_title} + Submitted by: {submitter_name} + Title: {abstract_title} + Primary Authors: {primary_authors} + Co-authors: {co_authors} + Track classification: {abstract_track} + Presentation type: {contribution_type} - For a more detailed summary please visit the page of your abstract: - {abstract_url} + For a more detailed summary please visit the page of your abstract: + {abstract_url} - Kind regards, - The organizers of {event_title} + Kind regards, + The organizers of {event_title} + {%- endtrans %} {%- endblock %} diff --git a/indico/modules/events/abstracts/templates/emails/default_invite_notification.txt b/indico/modules/events/abstracts/templates/emails/default_invite_notification.txt index 211bddb2b7b..af924fe98fd 100644 --- a/indico/modules/events/abstracts/templates/emails/default_invite_notification.txt +++ b/indico/modules/events/abstracts/templates/emails/default_invite_notification.txt @@ -1,15 +1,17 @@ {% extends 'events/abstracts/emails/default_notification.txt' %} {% block subject -%} - Invitation to submit an abstract + {% trans %}Invitation to submit an abstract{% endtrans %} {%- endblock %} {% block body -%} - You have been invited to submit an abstract. - In order to submit your abstract please follow the link below: + {% trans notrimmed -%} + You have been invited to submit an abstract. + In order to submit your abstract please follow the link below: - {invitation_url} + {invitation_url} - Kind regards, - The organizers of {event_title} + Kind regards, + The organizers of {event_title} + {%- endtrans %} {%- endblock %} diff --git a/indico/modules/events/abstracts/templates/emails/default_merge_notification.txt b/indico/modules/events/abstracts/templates/emails/default_merge_notification.txt index c21eff825a6..a18f9f6c701 100644 --- a/indico/modules/events/abstracts/templates/emails/default_merge_notification.txt +++ b/indico/modules/events/abstracts/templates/emails/default_merge_notification.txt @@ -1,12 +1,14 @@ {% extends 'events/abstracts/emails/default_notification.txt' %} {% block subject -%} - Abstract Merge notification (#{abstract_id}) + {% trans %}Abstract Merge notification (#{abstract_id}){% endtrans %} {%- endblock %} {% block body -%} - Your abstract "{abstract_title}" with ID #{abstract_id} has been merged into "{target_abstract_title}". + {% trans notrimmed -%} + Your abstract "{abstract_title}" with ID #{abstract_id} has been merged into "{target_abstract_title}". - Kind regards, - The organizers of {event_title} + Kind regards, + The organizers of {event_title} + {%- endtrans %} {%- endblock %} diff --git a/indico/modules/events/abstracts/templates/emails/default_notification.txt b/indico/modules/events/abstracts/templates/emails/default_notification.txt index d1942ff5df9..cb3473b3ca2 100644 --- a/indico/modules/events/abstracts/templates/emails/default_notification.txt +++ b/indico/modules/events/abstracts/templates/emails/default_notification.txt @@ -4,7 +4,7 @@ {% macro get_body() -%} {%- filter dedent -%} - Dear {submitter_name}, + {% trans %}Dear {submitter_name},{% endtrans %} {% block body %}{% endblock %} {%- endfilter -%} diff --git a/indico/modules/events/abstracts/templates/emails/default_reject_notification.txt b/indico/modules/events/abstracts/templates/emails/default_reject_notification.txt index 468df3a15b1..d3433dc96fb 100644 --- a/indico/modules/events/abstracts/templates/emails/default_reject_notification.txt +++ b/indico/modules/events/abstracts/templates/emails/default_reject_notification.txt @@ -1,12 +1,14 @@ {% extends 'events/abstracts/emails/default_notification.txt' %} {% block subject -%} - Abstract Rejection notification (#{abstract_id}) + {% trans %}Abstract Rejection notification (#{abstract_id}){% endtrans %} {%- endblock %} {% block body -%} - We're sorry to let you know that your abstract "{abstract_title}" with ID #{abstract_id} has been rejected. + {% trans notrimmed -%} + We're sorry to let you know that your abstract "{abstract_title}" with ID #{abstract_id} has been rejected. - Kind regards, - The organizers of {event_title} + Kind regards, + The organizers of {event_title} + {%- endtrans %} {%- endblock %} diff --git a/indico/modules/events/abstracts/templates/emails/default_submit_notification.txt b/indico/modules/events/abstracts/templates/emails/default_submit_notification.txt index 75314d2d9c2..fba207b51a4 100644 --- a/indico/modules/events/abstracts/templates/emails/default_submit_notification.txt +++ b/indico/modules/events/abstracts/templates/emails/default_submit_notification.txt @@ -1,12 +1,14 @@ {% extends 'events/abstracts/emails/default_notification.txt' %} {% block subject -%} - Abstract Submission confirmation (#{abstract_id}) + {% trans %}Abstract Submission confirmation (#{abstract_id}){% endtrans %} {%- endblock %} {% block body -%} - We've received your abstract "{abstract_title}" to which we have assigned id #{abstract_id}. + {% trans notrimmed -%} + We've received your abstract "{abstract_title}" to which we have assigned id #{abstract_id}. - Kind regards, - The organizers of {event_title} + Kind regards, + The organizers of {event_title} + {%- endtrans %} {%- endblock %} diff --git a/indico/modules/events/abstracts/templates/forms/rule_list_widget.html b/indico/modules/events/abstracts/templates/forms/rule_list_widget.html index 05ac9b2dc40..4d45469ba4f 100644 --- a/indico/modules/events/abstracts/templates/forms/rule_list_widget.html +++ b/indico/modules/events/abstracts/templates/forms/rule_list_widget.html @@ -11,7 +11,7 @@

    {% call message_box('info', classes='no-rules-placeholder') %} - {% trans %}No rules have been added{% endtrans%} + {% trans %}No rules have been added{% endtrans %} {% endcall %}
    diff --git a/indico/modules/events/agreements/notifications.py b/indico/modules/events/agreements/notifications.py index c840c2ecf67..34303acfbc8 100644 --- a/indico/modules/events/agreements/notifications.py +++ b/indico/modules/events/agreements/notifications.py @@ -24,19 +24,23 @@ def make_email_template(template, agreement, email_body=None): @email_sender def notify_agreement_new(agreement, email_body=None, cc_addresses=None, from_address=None): - template = make_email_template('events/agreements/emails/agreement_new.html', agreement, email_body) - return make_email(agreement.person_email, cc_list=cc_addresses, from_address=from_address, - template=template, html=True) + with agreement.event.force_event_locale(): + template = make_email_template('events/agreements/emails/agreement_new.html', agreement, email_body) + return make_email(agreement.person_email, cc_list=cc_addresses, from_address=from_address, + template=template, html=True) @email_sender def notify_agreement_reminder(agreement, email_body=None, cc_addresses=None, from_address=None): - template = make_email_template('events/agreements/emails/agreement_reminder.html', agreement, email_body) - return make_email(agreement.person_email, cc_list=cc_addresses, from_address=from_address, - template=template, html=True) + with agreement.event.force_event_locale(): + template = make_email_template('events/agreements/emails/agreement_reminder.html', agreement, email_body) + return make_email(agreement.person_email, cc_list=cc_addresses, from_address=from_address, + template=template, html=True) @email_sender def notify_new_signature_to_manager(agreement): - template = get_template_module('events/agreements/emails/new_signature_email_to_manager.txt', agreement=agreement) - return make_email(agreement.event.all_manager_emails, template=template) + with agreement.event.force_event_locale(): + template = get_template_module('events/agreements/emails/new_signature_email_to_manager.txt', + agreement=agreement) + return make_email(agreement.event.all_manager_emails, template=template) diff --git a/indico/modules/events/agreements/templates/emails/agreement_default_body.html b/indico/modules/events/agreements/templates/emails/agreement_default_body.html index 72124609382..1a2bf9867f2 100644 --- a/indico/modules/events/agreements/templates/emails/agreement_default_body.html +++ b/indico/modules/events/agreements/templates/emails/agreement_default_body.html @@ -1,28 +1,28 @@ -{% extends 'emails/base.html' %} +{% extends 'emails/base_i18n.html' %} {% block header_recipient -%} - {person_name} + {% trans %}Dear {person_name},{% endtrans %} {%- endblock %} {% block body %} {% block body_text %} - There is an agreement you are requested to sign for the event:
    + {% trans %}There is an agreement you are requested to sign for the event:{% endtrans %}
    {{ event.title }}

    {% block body_agreement_request %} - You can sign it on the following page: + {% trans %}You can sign it on the following page:{% endtrans %} {% endblock %}
    {agreement_link} {% endblock %} {% if session %}

    - Best regards
    + {% trans %}Best regards{% endtrans %}
    {{ session.user.full_name }} {% endif %} {%- endblock %} -{% block footer_title %}Agreements{% endblock %} +{% block footer_title %}{% trans %}Agreements{% endtrans %}{% endblock %} {% block footer %} {# Show default footer if sent from command line #} {% if not session.user %} diff --git a/indico/modules/events/agreements/templates/emails/agreement_new.html b/indico/modules/events/agreements/templates/emails/agreement_new.html index 8791d5e62c2..a248fea30e3 100644 --- a/indico/modules/events/agreements/templates/emails/agreement_new.html +++ b/indico/modules/events/agreements/templates/emails/agreement_new.html @@ -1,5 +1,5 @@ -{% extends 'emails/base.html' %} -{% block subject %}Agreement signature required{% endblock %} +{% extends 'emails/base_i18n.html' %} +{% block subject %}{% trans %}Agreement signature required{% endtrans %}{% endblock %} {% block header %}{% endblock %} {% block footer %}{% endblock %} diff --git a/indico/modules/events/agreements/templates/emails/agreement_reminder.html b/indico/modules/events/agreements/templates/emails/agreement_reminder.html index 538fddd6e19..b5616c6b891 100644 --- a/indico/modules/events/agreements/templates/emails/agreement_reminder.html +++ b/indico/modules/events/agreements/templates/emails/agreement_reminder.html @@ -1,2 +1,2 @@ {% extends 'events/agreements/emails/agreement_new.html' %} -{% block subject %}Agreement signature required - Reminder{% endblock %} +{% block subject %}{% trans %}Agreement signature required - Reminder{% endtrans %}{% endblock %} diff --git a/indico/modules/events/agreements/templates/emails/new_signature_email_to_manager.txt b/indico/modules/events/agreements/templates/emails/new_signature_email_to_manager.txt index e22c2ef2088..d8bb9483047 100644 --- a/indico/modules/events/agreements/templates/emails/new_signature_email_to_manager.txt +++ b/indico/modules/events/agreements/templates/emails/new_signature_email_to_manager.txt @@ -1,24 +1,34 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} {% set state = 'accepted' if agreement.accepted else 'rejected' %} -{% block subject %}Agreement {{ state }}{% endblock %} -{% block footer_title %}Agreements{% endblock %} +{% block subject -%} + {%- if state == 'accepted' -%} + {% trans %}Agreement accepted{% endtrans %} + {%- else -%} + {% trans %}Agreement rejected{% endtrans %} + {%- endif -%} +{%- endblock %} +{% block footer_title %}{% trans %}Agreements{% endtrans %}{% endblock %} {% block header_recipient -%} - event managers + {% trans %}Dear event managers,{% endtrans %} {%- endblock %} {% block body -%} -A new agreement has been {{ state }} for the event: + {%- if state == 'accepted' -%} + {% trans %}A new agreement has been accepted for the event:{% endtrans %} + {%- else -%} + {% trans %}A new agreement has been rejected for the event:{% endtrans %} + {%- endif %} {{ agreement.event.title }} -{% filter underline %}Person Info{% endfilter %} -Name: {{ agreement.person_name }} -Email: {{ agreement.person_email }} +{% filter underline %}{% trans %}Person Info{% endtrans %}{% endfilter %} +{% trans %}Name:{% endtrans %} {{ agreement.person_name }} +{% trans %}Email:{% endtrans %} {{ agreement.person_email }} {%- if agreement.reason %} -{% filter underline %}Reason{% endfilter %} +{% filter underline %}{% trans %}Reason{% endtrans %}{% endfilter %} {{ agreement.reason }} {%- endif %} diff --git a/indico/modules/events/editing/notifications.py b/indico/modules/events/editing/notifications.py index 32054b4356e..f77a34fa3a3 100644 --- a/indico/modules/events/editing/notifications.py +++ b/indico/modules/events/editing/notifications.py @@ -41,12 +41,13 @@ def notify_comment(comment): recipients.discard(author) # never bother people about their own comments for recipient in recipients: author_name = author.first_name if editable.can_see_editor_names(recipient, author) else None - tpl = get_template_module('events/editing/emails/comment_notification.txt', - author_name=author_name, - timeline_url=editable.external_timeline_url, - recipient_name=recipient.first_name) - send_email(make_email(recipient.email, template=tpl), editable.event, 'Editing', - log_metadata={'editable_id': editable.id}) + with recipient.force_user_locale(): + tpl = get_template_module('events/editing/emails/comment_notification.txt', + author_name=author_name, + timeline_url=editable.external_timeline_url, + recipient_name=recipient.first_name) + email = make_email(recipient.email, template=tpl) + send_email(email, editable.event, 'Editing', log_metadata={'editable_id': editable.id}) def notify_editor_judgment(revision, editor): @@ -54,12 +55,13 @@ def notify_editor_judgment(revision, editor): submitter = revision.submitter editable = revision.editable editor_name = editor.first_name if editable.can_see_editor_names(submitter) else None - tpl = get_template_module('events/editing/emails/editor_judgment_notification.txt', - editor_name=editor_name, - timeline_url=editable.external_timeline_url, - recipient_name=submitter.first_name) - send_email(make_email(submitter.email, template=tpl), editable.event, 'Editing', - log_metadata={'editable_id': editable.id}) + with submitter.force_user_locale(): + tpl = get_template_module('events/editing/emails/editor_judgment_notification.txt', + editor_name=editor_name, + timeline_url=editable.external_timeline_url, + recipient_name=submitter.first_name) + email = make_email(submitter.email, template=tpl) + send_email(email, editable.event, 'Editing', log_metadata={'editable_id': editable.id}) def notify_submitter_upload(revision): @@ -69,12 +71,13 @@ def notify_submitter_upload(revision): editor = revision.editable.editor if not editor: return - tpl = get_template_module('events/editing/emails/submitter_upload_notification.txt', - submitter_name=submitter.first_name, - timeline_url=editable.external_timeline_url, - recipient_name=editor.first_name) - send_email(make_email(editor.email, template=tpl), editable.event, 'Editing', - log_metadata={'editable_id': editable.id}) + with editor.force_user_locale(): + tpl = get_template_module('events/editing/emails/submitter_upload_notification.txt', + submitter_name=submitter.first_name, + timeline_url=editable.external_timeline_url, + recipient_name=editor.first_name) + email = make_email(editor.email, template=tpl) + send_email(email, editable.event, 'Editing', log_metadata={'editable_id': editable.id}) def notify_submitter_confirmation(revision, submitter, action): @@ -89,9 +92,10 @@ def notify_submitter_confirmation(revision, submitter, action): else: template_path = 'events/editing/emails/submitter_rejection_notification.txt' for recipient in recipients: - tpl = get_template_module(template_path, - submitter_name=submitter.first_name, - timeline_url=revision.editable.external_timeline_url, - recipient_name=recipient.first_name) - send_email(make_email(recipient.email, template=tpl), editable.event, 'Editing', - log_metadata={'editable_id': editable.id}) + with recipient.force_user_locale(): + tpl = get_template_module(template_path, + submitter_name=submitter.first_name, + timeline_url=revision.editable.external_timeline_url, + recipient_name=recipient.first_name) + email = make_email(recipient.email, template=tpl) + send_email(email, editable.event, 'Editing', log_metadata={'editable_id': editable.id}) diff --git a/indico/modules/events/editing/templates/emails/base_email.txt b/indico/modules/events/editing/templates/emails/base_email.txt index acf2707e13a..469834fc6bb 100644 --- a/indico/modules/events/editing/templates/emails/base_email.txt +++ b/indico/modules/events/editing/templates/emails/base_email.txt @@ -1,9 +1,9 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} -{% block header_recipient -%}{{ recipient_name }}{%- endblock %} +{% block header_recipient -%}{% trans name=recipient_name %}Dear {{ name }},{% endtrans %}{%- endblock %} {% block body -%} {% block body_text %}{% endblock %} -You can view details on the following URL: +{% trans %}You can view details on the following URL:{% endtrans %} {{ timeline_url }} {%- endblock %} diff --git a/indico/modules/events/editing/templates/emails/comment_notification.txt b/indico/modules/events/editing/templates/emails/comment_notification.txt index 1957a3da180..dd2dcd35a0a 100644 --- a/indico/modules/events/editing/templates/emails/comment_notification.txt +++ b/indico/modules/events/editing/templates/emails/comment_notification.txt @@ -1,7 +1,11 @@ {% extends 'events/editing/emails/base_email.txt' %} -{% block subject -%}New comment{%- endblock %} +{% block subject -%}{% trans %}New comment{% endtrans %}{%- endblock %} {% block body_text -%} -{{ author_name or 'Someone' }} has posted a new comment. +{% if author_name -%} + {% trans name=author_name %}{{ name }} has posted a new comment.{% endtrans %} +{%- else -%} + {% trans %}Someone has posted a new comment.{% endtrans %} +{%- endif %} {% endblock %} diff --git a/indico/modules/events/editing/templates/emails/editor_judgment_notification.txt b/indico/modules/events/editing/templates/emails/editor_judgment_notification.txt index 5b26c26ce21..afa8ebae86b 100644 --- a/indico/modules/events/editing/templates/emails/editor_judgment_notification.txt +++ b/indico/modules/events/editing/templates/emails/editor_judgment_notification.txt @@ -1,7 +1,11 @@ {% extends 'events/editing/emails/base_email.txt' %} -{% block subject -%}New editor judgment{%- endblock %} +{% block subject -%}{% trans %}New editor judgment{% endtrans %}{%- endblock %} {% block body_text -%} -{{ editor_name or 'Someone' }} has left a judgment to an editable you are submitter of. +{% if editor_name -%} + {% trans name=editor_name %}{{ name }} has left a judgment to an editable you are submitter of.{% endtrans %} +{%- else -%} + {% trans %}Someone has left a judgment to an editable you are submitter of.{% endtrans %} +{%- endif %} {% endblock %} diff --git a/indico/modules/events/editing/templates/emails/submitter_confirmation_notification.txt b/indico/modules/events/editing/templates/emails/submitter_confirmation_notification.txt index 5e9732ca4d8..9e01ccce4c8 100644 --- a/indico/modules/events/editing/templates/emails/submitter_confirmation_notification.txt +++ b/indico/modules/events/editing/templates/emails/submitter_confirmation_notification.txt @@ -1,7 +1,7 @@ {% extends 'events/editing/emails/base_email.txt' %} -{% block subject -%}Submitter confirmed changes{%- endblock %} +{% block subject -%}{% trans %}Submitter confirmed changes{% endtrans %}{%- endblock %} {% block body_text -%} -Your revision changes have been confirmed by {{ submitter_name }}. +{% trans name=submitter_name %}Your revision changes have been confirmed by {{ name }}.{% endtrans %} {% endblock %} diff --git a/indico/modules/events/editing/templates/emails/submitter_rejection_notification.txt b/indico/modules/events/editing/templates/emails/submitter_rejection_notification.txt index 6c881e6fd41..80b8674913f 100644 --- a/indico/modules/events/editing/templates/emails/submitter_rejection_notification.txt +++ b/indico/modules/events/editing/templates/emails/submitter_rejection_notification.txt @@ -1,7 +1,7 @@ {% extends 'events/editing/emails/base_email.txt' %} -{% block subject -%}Submitter rejected changes{%- endblock %} +{% block subject -%}{% trans %}Submitter rejected changes{% endtrans %}{%- endblock %} {% block body_text -%} -Your revision changes have been rejected by {{ submitter_name }}. +{% trans name=submitter_name %}Your revision changes have been rejected by {{ name }}.{% endtrans %} {% endblock %} diff --git a/indico/modules/events/editing/templates/emails/submitter_upload_notification.txt b/indico/modules/events/editing/templates/emails/submitter_upload_notification.txt index b425a741b12..7d8eace4db4 100644 --- a/indico/modules/events/editing/templates/emails/submitter_upload_notification.txt +++ b/indico/modules/events/editing/templates/emails/submitter_upload_notification.txt @@ -1,7 +1,7 @@ {% extends 'events/editing/emails/base_email.txt' %} -{% block subject -%}New submitter upload{%- endblock %} +{% block subject -%}{% trans %}New submitter upload{% endtrans %}{%- endblock %} {% block body_text -%} -{{ submitter_name }} has uploaded a new revision to an editable you are editor of. +{% trans name=submitter_name %}{{ name }} has uploaded a new revision to an editable you are editor of.{% endtrans %} {% endblock %} diff --git a/indico/modules/events/layout/templates/_menu.html b/indico/modules/events/layout/templates/_menu.html index c9e0f666f73..db8c0f51f6c 100644 --- a/indico/modules/events/layout/templates/_menu.html +++ b/indico/modules/events/layout/templates/_menu.html @@ -33,7 +33,7 @@
    {{- url_for('papers.papers_list', event,management=false, _external=true) -}}

    {% else %} -

    Once there are some papers for you to review, you will be able to do so in the reviewing area page:

    +

    {% trans %}Once there are some papers for you to review, you will be able to do so in the reviewing area page:{% endtrans %}

    {{- url_for('papers.reviewing_area', event, _external=true) -}} diff --git a/indico/modules/events/papers/templates/emails/base.html b/indico/modules/events/papers/templates/emails/base.html index 55e1f55e683..bdbc1601e4d 100644 --- a/indico/modules/events/papers/templates/emails/base.html +++ b/indico/modules/events/papers/templates/emails/base.html @@ -1,11 +1,11 @@ -{% extends 'emails/base.html' %} +{% extends 'emails/base_i18n.html' %} {% block header %}{% endblock %} {% block footer %}{% endblock %} {% block subject -%} - {% block subject_message %}Paper Peer Reviewing{% endblock %} + {% block subject_message %}{% trans %}Paper Peer Reviewing{% endtrans %}{% endblock %} {%- block subject_name %}{% endblock %} {%- endblock %} @@ -34,7 +34,7 @@

    - Indico :: Paper Peer Reviewing + Indico :: {% trans %}Paper Peer Reviewing{% endtrans %}

    {% endblock %} diff --git a/indico/modules/events/papers/templates/emails/comment.html b/indico/modules/events/papers/templates/emails/comment.html index b51f6dd7aed..063c5f3fe79 100644 --- a/indico/modules/events/papers/templates/emails/comment.html +++ b/indico/modules/events/papers/templates/emails/comment.html @@ -1,21 +1,23 @@ {% extends 'events/papers/emails/base.html' %} -{% block subject_message %}New paper comment{% endblock %} +{% block subject_message %}{% trans %}New paper comment{% endtrans %}{% endblock %} -{% block header_subtitle %}New paper comment{% endblock %} +{% block header_subtitle %}{% trans %}New paper comment{% endtrans %}{% endblock %} -{% block header_subtitle_ref %}ref #{{ contribution.friendly_id }}{% endblock %} +{% block header_subtitle_ref %}{% trans id=contribution.friendly_id %}ref #{{ id }}{% endtrans %}{% endblock %} {% block content_header %} -

    Dear {{ receiver }},

    -

    {{ submitter.full_name }} commented on the paper {{ contribution.title }}:

    +

    {% trans receiver=receiver %}Dear {{ receiver }},{% endtrans %}

    +

    {% trans name=submitter.full_name, strong=''|safe, endstrong=''|safe, title=contribution.title -%} + {{ name }} commented on the paper {{ strong }}{{ title }}{{ endstrong }}: + {% endtrans %}

    {{ comment }}
    {% endblock %} {% block content_body %} -

    You can reply to this comment from within the paper page:

    +

    {% trans %}You can reply to this comment from within the paper page:{% endtrans %}

    {{- url_for('papers.paper_timeline', contribution, _external=true) -}} diff --git a/indico/modules/events/papers/templates/emails/judgment_reset_to_author.html b/indico/modules/events/papers/templates/emails/judgment_reset_to_author.html index 2b12a244eef..99e96ac0acb 100644 --- a/indico/modules/events/papers/templates/emails/judgment_reset_to_author.html +++ b/indico/modules/events/papers/templates/emails/judgment_reset_to_author.html @@ -1,15 +1,17 @@ {% extends 'events/papers/emails/base.html' %} -{% block subject_message %}Paper assessment withdrawn{% endblock %} +{% block subject_message %}{% trans %}Paper assessment withdrawn{% endtrans %}{% endblock %} -{% block header_subtitle %}Paper assessment withdrawn{% endblock %} +{% block header_subtitle %}{% trans %}Paper assessment withdrawn{% endtrans %}{% endblock %} -{% block header_subtitle_ref %}ref #{{ contribution.friendly_id }}{% endblock %} +{% block header_subtitle_ref %}{% trans id=contribution.friendly_id %}ref #{{ id }}{% endtrans %}{% endblock %} {% block content %} -

    Dear {{ receiver.first_name }},

    -

    Your paper {{ contribution.title }} has been put back to review, after the assessment has been withdrawn.

    -

    To see your paper please use the following link:

    +

    {% trans name=receiver.first_name %}Dear {{ name }},{% endtrans %}

    +

    {% trans notrimmed title=contribution.title, strong=''|safe, endstrong=''|safe -%} + Your paper {{ strong }}{{ title }}{{ endstrong }} has been put back to review, after the assessment has been withdrawn. + {%- endtrans %}

    +

    {% trans %}To see your paper please use the following link:{% endtrans %}

    {{- url_for('papers.paper_timeline', contribution, _external=true) -}} diff --git a/indico/modules/events/papers/templates/emails/judgment_to_author.html b/indico/modules/events/papers/templates/emails/judgment_to_author.html index 4cf70ab3e13..62e95401b01 100644 --- a/indico/modules/events/papers/templates/emails/judgment_to_author.html +++ b/indico/modules/events/papers/templates/emails/judgment_to_author.html @@ -1,21 +1,27 @@ {% extends 'events/papers/emails/base.html' %} -{% block subject_message %}Paper assessment{% endblock %} +{% block subject_message %}{% trans %}Paper assessment{% endtrans %}{% endblock %} -{% block header_subtitle %}Paper assessment{% endblock %} +{% block header_subtitle %}{% trans %}Paper assessment{% endtrans %}{% endblock %} -{% block header_subtitle_ref %}ref #{{ contribution.friendly_id }}{% endblock %} +{% block header_subtitle_ref %}{% trans id=contribution.friendly_id %}ref #{{ id }}{% endtrans %}{% endblock %} {% block content_header %} -

    Dear {{ receiver.first_name }},

    +

    {% trans name=receiver.first_name %}Dear {{name }},{% endtrans %}

    {% if paper.state.name == 'accepted' %} -

    Your paper {{ contribution.title }} has been accepted!

    -

    No further actions are required.

    +

    {% trans strong=''|safe, endstrong=''|safe, title=contribution.title -%} + Your paper {{ strong }}{{ title }}{{ endstrong }} has been {{ strong }}accepted{{ endstrong }}! + {%- endtrans %}

    +

    {% trans %}No further actions are required.{% endtrans %}

    {% elif paper.state.name == 'rejected' %} -

    Your paper {{ contribution.title }} has been rejected.

    -

    No further actions are required.

    +

    {% trans strong=''|safe, endstrong=''|safe, title=contribution.title -%} + Your paper {{ strong }}{{ title }}{{ endstrong }} has been {{ strong }}rejected{{ endstrong }}. + {%- endtrans %}

    +

    {% trans %}No further actions are required.{% endtrans %}

    {% else %} -

    A judge has requested some changes to your paper {{ contribution.title }}.

    +

    {% trans strong=''|safe, endstrong=''|safe, title=contribution.title -%} + A judge has requested some {{ strong }}changes{{ endstrong }} to your paper {{ strong }}{{ title }}{{ endstrong }}. + {%- endtrans %}

    {% endif %} {% endblock %} @@ -23,7 +29,7 @@ {% block content_body %} {% if paper.judgment_comment %}
    -
    Comment:
    +
    {% trans %}Comment:{% endtrans %}
    {{- paper.judgment_comment -}}
    @@ -34,10 +40,10 @@ {% block content_footer %} {% if paper.state.name == 'to_be_corrected' %} -

    You may apply the modifications to your paper and submit the modified version (together with any additional files) for review.

    -

    In order to do that please proceed to your paper page:

    +

    {% trans %}You may apply the modifications to your paper and submit the modified version (together with any additional files) for review.{% endtrans %}

    +

    {% trans %}In order to do that please proceed to your paper page:{% endtrans %}

    {% else %} -

    To see your paper please use the following link:

    +

    {% trans %}To see your paper please use the following link:{% endtrans %}

    {% endif %}

    diff --git a/indico/modules/events/papers/templates/emails/paper_assignment.html b/indico/modules/events/papers/templates/emails/paper_assignment.html index 6ea9f9ef888..0c19b2ba08b 100644 --- a/indico/modules/events/papers/templates/emails/paper_assignment.html +++ b/indico/modules/events/papers/templates/emails/paper_assignment.html @@ -2,34 +2,42 @@ {% block subject_message %} {%- if assign -%} - New paper review assignment + {% trans %}New paper review assignment{% endtrans %} {%- else -%} - Removed from paper review assignment + {% trans %}Removed from paper review assignment{% endtrans %} {%- endif -%} {% endblock %} {% block header_subtitle %} {% if assign -%} - New paper review assignment + {% trans %}New paper review assignment{% endtrans %} {%- else -%} - Removed from paper review assignment + {% trans %}Removed from paper review assignment{% endtrans %} {%- endif %} {% endblock %} {% block content_header %} -

    Dear {{ receiver.first_name }},

    +

    {% trans name=receiver.first_name %}Dear {{name }},{% endtrans %}

    {% if contribs | length == 1 %} {% set contrib = contribs | first %} {% if assign %} -

    You have been assigned as a {{ role.title }} to the paper {{ contrib.title }}.

    +

    {% trans strong=''|safe, endstrong=''|safe, title=contrib.title, role_title=role.title -%} + You have been assigned as a {{ strong }}{{ role_title }}{{ endstrong }} to the paper {{ strong }}{{ title }}{{ endstrong }}. + {%- endtrans %}

    {% else %} -

    You are no longer a {{ role.title }} for the paper {{ contrib.title }}.

    +

    {% trans strong=''|safe, endstrong=''|safe, title=contrib.title, role_title=role.title -%} + You are no longer a {{ strong }}{{ role_title }}{{ endstrong }} for the paper {{ strong }}{{ title }}{{ endstrong }}. + {%- endtrans %}

    {% endif %} {% else %} {% if assign %} -

    You have been assigned as a {{ role.title }} to the following papers:

    +

    {% trans strong=''|safe, endstrong=''|safe, role_title=role.title -%} + You have been assigned as a {{ strong }}{{ role_title }}{{ endstrong }} to the following papers: + {%- endtrans %}

    {% else %} -

    You are no longer a {{ role.title }} for the following papers:

    +

    {% trans strong=''|safe, endstrong=''|safe, role_title=role.title -%} + You are no longer a {{ strong }}{{ role_title }}{{ endstrong }} for the following papers: + {%- endtrans %}

    {% endif %}

    @@ -34,7 +34,7 @@

    - Indico :: Event Registration + Indico :: {% trans %}Event Registration{% endtrans %} {% endblock %} diff --git a/indico/modules/events/registration/templates/emails/base_registration_details.html b/indico/modules/events/registration/templates/emails/base_registration_details.html index 1d54dce64ce..a3cf39f2064 100644 --- a/indico/modules/events/registration/templates/emails/base_registration_details.html +++ b/indico/modules/events/registration/templates/emails/base_registration_details.html @@ -22,7 +22,7 @@

    {{ section.title }}

    {% if old_price != registration.price or registration.price %}

    - Total: + {% trans %}Total:{% endtrans %} {% if old_price != registration.price %} {{- registration._render_price(old_price) -}} diff --git a/indico/modules/events/registration/templates/emails/custom_email.html b/indico/modules/events/registration/templates/emails/custom_email.html index 2131be3c816..21e9ee41136 100644 --- a/indico/modules/events/registration/templates/emails/custom_email.html +++ b/indico/modules/events/registration/templates/emails/custom_email.html @@ -1,4 +1,4 @@ -{% extends 'emails/base.html' %} +{% extends 'emails/base_i18n.html' %} {% block subject %}{{ email_subject | safe }}{% endblock %} {% block header %}{% endblock %} {% block footer %}{% endblock %} diff --git a/indico/modules/events/registration/templates/emails/custom_email_default.html b/indico/modules/events/registration/templates/emails/custom_email_default.html index d3637b48a3e..6c83690faf4 100644 --- a/indico/modules/events/registration/templates/emails/custom_email_default.html +++ b/indico/modules/events/registration/templates/emails/custom_email_default.html @@ -1,26 +1,28 @@ -{% extends 'emails/base.html' %} +{% extends 'emails/base_i18n.html' %} {% block header_recipient -%} - {first_name} + {% trans %}Dear {first_name},{% endtrans %} {%- endblock %} {% block body %} {% block body_text %} - We're contacting you because you registered for the event {event_title}.
    + {% trans strong=''|safe, endstrong=''|safe -%} + We're contacting you because you registered for the event {{ strong }}{event_title}{{ endstrong }}. + {%- endtrans %}


    - You can view your registration details on this page:
    + {% trans %}You can view your registration details on this page:{% endtrans %}
    {link} {% endblock %} {% if session %}

    - Best regards
    + {% trans %}Best regards{% endtrans %}
    {{ session.user.full_name }} {% endif %} {%- endblock %} -{% block footer_title %}Registration{% endblock %} +{% block footer_title %}{% trans %}Registration{% endtrans %}{% endblock %} {% block footer %} {# Show default footer if sent from command line #} {% if not session.user %} diff --git a/indico/modules/events/registration/templates/emails/invitation_default.html b/indico/modules/events/registration/templates/emails/invitation_default.html index ebe3075f12d..eb1d8f516d9 100644 --- a/indico/modules/events/registration/templates/emails/invitation_default.html +++ b/indico/modules/events/registration/templates/emails/invitation_default.html @@ -1,17 +1,17 @@ -{% macro get_subject() %}Invitation to register{% endmacro %} +{% macro get_subject() %}{% trans %}Invitation to register{% endtrans %}{% endmacro %} {% macro get_html_body() %} - Dear {first_name},
    + {% trans %}Dear {first_name},{% endtrans %}

    - We'd like to invite you to register for the following event:
    + {% trans %}We'd like to invite you to register for the following event:{% endtrans %}
    {{ event.title }}

    - You can register (or decline the invitation) by using this link:
    + {% trans %}You can register (or decline the invitation) by using this link:{% endtrans %}
    {invitation_link} {% if session %}

    - Best regards
    + {% trans %}Best regards{% endtrans %}
    {{ session.user.full_name }} {% endif %} {% endmacro %} diff --git a/indico/modules/events/registration/templates/emails/registration_creation_to_managers.html b/indico/modules/events/registration/templates/emails/registration_creation_to_managers.html index 2b9d16a3430..178219b0e4f 100644 --- a/indico/modules/events/registration/templates/emails/registration_creation_to_managers.html +++ b/indico/modules/events/registration/templates/emails/registration_creation_to_managers.html @@ -1,14 +1,20 @@ {% extends 'events/registration/emails/base_registration_details.html' %} {% block subject_message -%} - New {%- if registration.state.name == 'pending' %} pending{% endif %} registration + {% if registration.state.name == 'pending' -%} + {% trans title=event.title %}New pending registration for {{ title }}{% endtrans %} + {%- else -%} + {% trans title=event.title %}New registration for {{ title }}{% endtrans %} + {%- endif %} {%- endblock %} {% block registration_header -%} -

    Dear organizer,

    +

    {% trans %}Dear organizer,{% endtrans %}

    {% block registration_header_text %} - There is a new registration {{ render_registration_info() }}. + {% trans title=event.title, name=registration.full_name, strong=''|safe, endstrong=''|safe -%} + There is a new registration for the event {{ strong }}{{ title }}{{ endstrong }} under {{ strong }}{{ name }}{{ endstrong }}. + {% endtrans %} {{ render_text_pending() }} {{ render_text_manage() }} {% endblock %} @@ -17,35 +23,30 @@ {% block registration_footer %}

    - To manage this registration form follow this link: + {% trans %}To manage this registration form follow this link:{% endtrans %} - Manage registration form + {% trans %}Manage registration form{% endtrans %}

    {% endblock %} -{% macro render_registration_info() -%} - for the event {{ event.title }} - under {{ registration.full_name }} -{%- endmacro %} - - {% macro render_rejection_reason() %} {% if registration.state.name == 'rejected' and registration.rejection_reason %} -
    Rejection reason: {{ registration.rejection_reason }}
    +
    {% trans %}Rejection reason:{% endtrans %} {{ registration.rejection_reason }}
    {% endif %} {% endmacro %} {% macro render_text_pending() %} {% if registration.state.name == 'pending' %} - Please note that it's waiting for manual approval by a manager. + {% trans %}Please note that it's waiting for manual approval by a manager.{% endtrans %} {% endif %} {% endmacro %} {% macro render_text_manage() %} - You can manage this registration - here. + {% trans a=''|safe, enda=''|safe -%} + You can manage this registration {{ a }}here{{ enda }}. + {%- endtrans %} {% endmacro %} diff --git a/indico/modules/events/registration/templates/emails/registration_creation_to_registrant.html b/indico/modules/events/registration/templates/emails/registration_creation_to_registrant.html index 23a92d213d8..3ed744caa73 100644 --- a/indico/modules/events/registration/templates/emails/registration_creation_to_registrant.html +++ b/indico/modules/events/registration/templates/emails/registration_creation_to_registrant.html @@ -2,16 +2,18 @@ {% block subject_name %}{% endblock %} {% block subject_message -%} - Registration + {% trans title=event.title %}Registration for {{ title }}{% endtrans %} {%- endblock %} {% block registration_header -%} {% set event = registration.registration_form.event %} -

    Dear {{ registration.full_name }},

    +

    {% trans name=registration.full_name %}Dear {{ name }},{% endtrans %}

    {% block registration_header_text %} - Thank you! Your registration {{ render_registration_info() }} - has been received. + {% trans title=event.title, strong=''|safe, endstrong=''|safe, at_time=render_registration_info() -%} + Thank you! Your registration for the event {{ strong }}{{ title }}{{ endstrong }} {{ at_time }} + has been received. + {%- endtrans %} {{ render_text_pending() }} {{ render_text_unpaid() }} {% endblock %} @@ -27,16 +29,15 @@ {% block registration_footer %}

    - To manage your registration follow this link: + {% trans %}To manage your registration follow this link:{% endtrans %} - Manage my registration + {% trans %}Manage my registration{% endtrans %}

    {% endblock %} {% macro render_registration_info() %} - for the event {{ event.title }} {% if event.start_dt_local.date() == event.end_dt_local.date() %} ({{ event.start_dt|format_datetime(timezone=event.tzinfo, locale='en_GB') }} - @@ -51,21 +52,25 @@ {% macro render_rejection_reason() %} {% if registration.state.name == 'rejected' and registration.rejection_reason %} -
    Rejection reason: {{ registration.rejection_reason }}
    +
    {% trans %}Rejection reason:{% endtrans %} {{ registration.rejection_reason }}
    {% endif %} {% endmacro %} {% macro render_text_pending() %} {% if registration.state.name == 'pending' %} - Please note that this event requires manual approval. - You will be notified when the registration process is complete. + {% trans notrimmed -%} + Please note that this event requires manual approval. + You will be notified when the registration process is complete. + {%- endtrans %} {% endif %} {% endmacro %} {% macro render_text_unpaid() %} {% if registration.state.name == 'unpaid' %} - Please proceed to the checkout here in order to complete it. + {% trans a=''|safe, enda=''|safe -%} + Please proceed to the checkout {{ a }}here{{ enda }} in order to complete it. + {%- endtrans %} {% endif %} {% endmacro %} diff --git a/indico/modules/events/registration/templates/emails/registration_modification_to_managers.html b/indico/modules/events/registration/templates/emails/registration_modification_to_managers.html index 7473f33c6d8..ca68d46194f 100644 --- a/indico/modules/events/registration/templates/emails/registration_modification_to_managers.html +++ b/indico/modules/events/registration/templates/emails/registration_modification_to_managers.html @@ -1,11 +1,17 @@ {% extends 'events/registration/emails/registration_creation_to_managers.html' %} {% block subject_message -%} - Modified {%- if registration.state.name == 'pending' %} pending{% endif %} registration + {% if registration.state.name == 'pending' -%} + {% trans title=event.title %}Modified pending registration for {{ title }}{% endtrans %} + {%- else -%} + {% trans title=event.title %}Modified registration for {{ title }}{% endtrans %} + {%- endif %} {%- endblock %} {% block registration_header_text -%} - There was a modification for the registration {{ render_registration_info() }}. + {% trans title=event.title, name=registration.full_name, strong=''|safe, endstrong=''|safe -%} + There was a modification for the registration for the event {{ strong }}{{ title }}{{ endstrong }} under {{ strong }}{{ name }}{{ endstrong }}. + {% endtrans %} {{ render_text_pending() }} {{ render_text_manage() }} {%- endblock %} diff --git a/indico/modules/events/registration/templates/emails/registration_modification_to_registrant.html b/indico/modules/events/registration/templates/emails/registration_modification_to_registrant.html index ebab8c3cf76..a89c25ea5ed 100644 --- a/indico/modules/events/registration/templates/emails/registration_modification_to_registrant.html +++ b/indico/modules/events/registration/templates/emails/registration_modification_to_registrant.html @@ -1,11 +1,13 @@ {% extends 'events/registration/emails/registration_creation_to_registrant.html' %} -{% block subject_prefix -%} - Registration modified +{% block subject_message -%} + {% trans title=event.title %}Registration modified for {{ title }}{% endtrans %} {%- endblock %} {% block registration_header_text -%} - Your registration {{ render_registration_info() }} has been modified. + {% trans title=event.title, strong=''|safe, endstrong=''|safe, at_time=render_registration_info() -%} + Your registration for the event {{ strong }}{{ title }}{{ endstrong }}{{ at_time }} has been modified. + {%- endtrans %} {{ render_text_pending() }} {{ render_text_unpaid() }} {%- endblock %} diff --git a/indico/modules/events/registration/templates/emails/registration_state_update_to_managers.html b/indico/modules/events/registration/templates/emails/registration_state_update_to_managers.html index 5e4900ed694..d0d72f6ab3b 100644 --- a/indico/modules/events/registration/templates/emails/registration_state_update_to_managers.html +++ b/indico/modules/events/registration/templates/emails/registration_state_update_to_managers.html @@ -2,12 +2,46 @@ {% block registration_body %}{% endblock %} {% block subject_message -%} - Registration {{ registration.state.title|lower }} + {% if registration.state.name == 'complete' -%} + {% trans title=event.title %}Registration complete for {{ title }}{% endtrans%} + {%- elif registration.state.name == 'pending' -%} + {% trans title=event.title %}Registration pending for {{ title }}{% endtrans%} + {%- elif registration.state.name == 'rejected' -%} + {% trans title=event.title %}Registration rejected for {{ title }}{% endtrans%} + {%- elif registration.state.name == 'withdrawn' -%} + {% trans title=event.title %}Registration withdrawns for {{ title }}{% endtrans%} + {%- else -%} + {% trans title=event.title %}Registration unpaid for {{ title }}{% endtrans%} + {%- endif %} {%- endblock %} {% block registration_header_text %} - The registration {{ render_registration_info() }} - is now {{ registration.state.title|lower }}. + {% if registration.state.name == 'complete' -%} + {% trans title=event.title, name=registration.full_name, strong=''|safe, endstrong=''|safe -%} + The registration for the event {{ strong }}{{ title }}{{ endstrong }} under {{ strong }}{{ name }}{{ endstrong }} + is now {{ strong }}complete{{ endstrong }}. + {%- endtrans %} + {%- elif registration.state.name == 'pending' -%} + {% trans title=event.title, name=registration.full_name, strong=''|safe, endstrong=''|safe -%} + The registration for the event {{ strong }}{{ title }}{{ endstrong }} under {{ strong }}{{ name }}{{ endstrong }} + is now {{ strong }}pending{{ endstrong }}. + {%- endtrans %} + {%- elif registration.state.name == 'rejected' -%} + {% trans title=event.title, name=registration.full_name, strong=''|safe, endstrong=''|safe -%} + The registration for the event {{ strong }}{{ title }}{{ endstrong }} under {{ strong }}{{ name }}{{ endstrong }} + is now {{ strong }}rejected{{ endstrong }}. + {%- endtrans %} + {%- elif registration.state.name == 'withdrawn' -%} + {% trans title=event.title, name=registration.full_name, strong=''|safe, endstrong=''|safe -%} + The registration for the event {{ strong }}{{ title }}{{ endstrong }} under {{ strong }}{{ name }}{{ endstrong }} + is now {{ strong }}withdrawn{{ endstrong }}. + {%- endtrans %} + {%- else -%} + {% trans title=event.title, name=registration.full_name, strong=''|safe, endstrong=''|safe -%} + The registration for the event {{ strong }}{{ title }}{{ endstrong }} under {{ strong }}{{ name }}{{ endstrong }} + is now {{ strong }}unpaid{{ endstrong }}. + {%- endtrans %} + {%- endif %} {{ render_rejection_reason() }} {{ render_text_pending() }} {{ render_text_manage() }} diff --git a/indico/modules/events/registration/templates/emails/registration_state_update_to_registrant.html b/indico/modules/events/registration/templates/emails/registration_state_update_to_registrant.html index f5e7d83af0f..40051e24ec5 100644 --- a/indico/modules/events/registration/templates/emails/registration_state_update_to_registrant.html +++ b/indico/modules/events/registration/templates/emails/registration_state_update_to_registrant.html @@ -2,12 +2,46 @@ {% block registration_body %}{% endblock %} {% block subject_message -%} - Registration {{ registration.state.title|lower }} + {% if registration.state.name == 'complete' -%} + {% trans title=event.title %}Registration complete for {{ title }}{% endtrans %} + {%- elif registration.state.name == 'pending' -%} + {% trans title=event.title %}Registration pending for {{ title }}{% endtrans %} + {%- elif registration.state.name == 'rejected' -%} + {% trans title=event.title %}Registration rejected for {{ title }}{% endtrans %} + {%- elif registration.state.name == 'withdrawn' -%} + {% trans title=event.title %}Registration withdrawns for {{ title }}{% endtrans %} + {%- else -%} + {% trans title=event.title %}Registration unpaid for {{ title }}{% endtrans %} + {%- endif %} {%- endblock %} {% block registration_header_text -%} - Your registration {{ render_registration_info() }} - is now {{ registration.state.title|lower }}. + {% if registration.state.name == 'complete' -%} + {% trans title=event.title, strong=''|safe, endstrong=''|safe, at_time=render_registration_info() -%} + Your registration for the event {{ strong }}{{ title }}{{ endstrong }} {{ at_time }} + is now {{ strong }}complete{{ endstrong }}. + {%- endtrans %} + {%- elif registration.state.name == 'pending' -%} + {% trans title=event.title, strong=''|safe, endstrong=''|safe, at_time=render_registration_info() -%} + Your registration for the event {{ strong }}{{ title }}{{ endstrong }} {{ at_time }} + is now {{ strong }}pending{{ endstrong }}. + {%- endtrans %} + {%- elif registration.state.name == 'rejected' -%} + {% trans title=event.title, strong=''|safe, endstrong=''|safe, at_time=render_registration_info() -%} + Your registration for the event {{ strong }}{{ title }}{{ endstrong }} {{ at_time }} + is now {{ strong }}rejected{{ endstrong }}. + {%- endtrans %} + {%- elif registration.state.name == 'withdrawn' -%} + {% trans title=event.title, strong=''|safe, endstrong=''|safe, at_time=render_registration_info() -%} + Your registration for the event {{ strong }}{{ title }}{{ endstrong }} {{ at_time }} + is now {{ strong }}withdrawn{{ endstrong }}. + {%- endtrans %} + {%- else -%} + {% trans title=event.title, strong=''|safe, endstrong=''|safe, at_time=render_registration_info() -%} + Your registration for the event {{ strong }}{{ title }}{{ endstrong }} {{ at_time }} + is now {{ strong }}unpaid{{ endstrong }}. + {%- endtrans %} + {%- endif %} {{ render_rejection_reason() if attach_rejection_reason }} {{ render_text_pending() }} {{ render_text_unpaid() }} diff --git a/indico/modules/events/registration/templates/management/regform_stats.html b/indico/modules/events/registration/templates/management/regform_stats.html index 2d5e08bcf96..936d5f45040 100644 --- a/indico/modules/events/registration/templates/management/regform_stats.html +++ b/indico/modules/events/registration/templates/management/regform_stats.html @@ -36,7 +36,7 @@ {% set height = stats.countries|length * 24 + 28 %} {% set badges = [(_("Registrations"), stats.registrations|length), (_("Days left
    to register"), stats.days_left), - (_("Countries"), stats.num_countries)]%} + (_("Countries"), stats.num_countries)] %} {% set taken, total, progress = stats.availability %} {% call stats_box(title=stats.title, subtitle=stats.subtitle, diff --git a/indico/modules/events/reminders/models/reminders.py b/indico/modules/events/reminders/models/reminders.py index da2eddb4bbd..42d5d159fe0 100644 --- a/indico/modules/events/reminders/models/reminders.py +++ b/indico/modules/events/reminders/models/reminders.py @@ -223,7 +223,8 @@ def send(self): if not recipients: logger.info('Notification %s has no recipients; not sending anything', self) return - email_tpl = make_reminder_email(self.event, self.include_summary, self.include_description, self.message) + with self.event.force_event_locale(): + email_tpl = make_reminder_email(self.event, self.include_summary, self.include_description, self.message) attachments = [] if self.attach_ical: event_ical = event_to_ical(self.event, skip_access_check=True, method='REQUEST', @@ -231,7 +232,8 @@ def send(self): attachments.append(MIMECalendar('event.ics', event_ical)) for recipient in recipients: - email = self._make_email(recipient, email_tpl, attachments) + with self.event.force_event_locale(): + email = self._make_email(recipient, email_tpl, attachments) send_email(email, self.event, 'Reminder', self.creator, log_metadata={'reminder_id': self.id}) def __repr__(self): diff --git a/indico/modules/events/reminders/templates/emails/_agenda.txt b/indico/modules/events/reminders/templates/emails/_agenda.txt index cd52860b327..f11c16981b3 100644 --- a/indico/modules/events/reminders/templates/emails/_agenda.txt +++ b/indico/modules/events/reminders/templates/emails/_agenda.txt @@ -1,9 +1,9 @@ {%- macro render_agenda(event, agenda) -%} {%- filter underline -%} - Agenda for {{ event.title }} + {% trans title=event.title %}Agenda for {{ title }}{% endtrans %} {%- endfilter %} {% if not agenda -%} - There are no events scheduled. + {% trans %}There are no events scheduled.{% endtrans %} {%- endif -%} {%- for item in agenda %} diff --git a/indico/modules/events/reminders/templates/emails/event_reminder.txt b/indico/modules/events/reminders/templates/emails/event_reminder.txt index e984ff473f8..edcd55ccd3f 100644 --- a/indico/modules/events/reminders/templates/emails/event_reminder.txt +++ b/indico/modules/events/reminders/templates/emails/event_reminder.txt @@ -1,4 +1,4 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} {% from 'events/reminders/emails/_agenda.txt' import render_agenda %} {% set address = event.address %} @@ -7,25 +7,30 @@ {% block subject -%} - [Event reminder] {{ event.title }} ({{ event.start_dt | format_datetime('short', timezone=event.tzinfo) }} {{ event.timezone }}) + [{% trans %}Event reminder{% endtrans %}] {{ event.title }} ({{ event.start_dt | format_datetime('short', timezone=event.tzinfo) }} {{ event.timezone }}) {%- endblock %} {% block header %}{% endblock %} {% block footer_url %}{{ url }}{% endblock %} {% block body -%} -Please note that the event "{{ event.title }}" will start on {{ event.start_dt | format_datetime(timezone=event.tzinfo) }} ({{ event.timezone }}). - -{%- if location or room or address %} -It will take place at {{ render_location() }} +{% trans title=event.title, start=event.start_dt|format_datetime(timezone=event.tzinfo), tz=event.timezone -%} + Please note that the event "{{ title }}" will start on {{ start }} ({{ tz }}). +{%- endtrans %} + +{%- if location or room %} + {% trans loc=render_location() %}It will take place at {{ loc }}{% endtrans %} +{%- elif address %} + {% trans %}It will take place at the following address:{% endtrans %} + {{ address | trim | indent }} {%- endif %} -You can access the full event here: +{% trans %}You can access the full event here:{% endtrans %} {{ url }} {%- if with_description and event.description %} -{% filter underline %}Description{% endfilter %} +{% filter underline %}{% trans %}Description{% endtrans %}{% endfilter %} {{ event.description | html_to_plaintext | trim }} @@ -35,7 +40,7 @@ You can access the full event here: {%- if note %} -{% filter underline %}Note{% endfilter %} +{% filter underline %}{% trans %}Note{% endtrans %}{% endfilter %} {{ note }} {%- endif -%} @@ -69,18 +74,14 @@ You can access the full event here: {%- if location -%} ({{ room | trim }}) {%- else -%} - room {{ room | trim }} + {% trans r=room|trim %}room {{ r }}{% endtrans %} {%- endif -%} {%- endif -%} {%- endmacro -%} {%- macro render_address() -%} {%- if address -%} - {%- if location or room %} -Address: - {%- else -%} -the following address: - {%- endif %} + {% trans %}Address:{% endtrans %} {{ address | trim | indent }} {%- endif -%} diff --git a/indico/modules/events/requests/notifications.py b/indico/modules/events/requests/notifications.py index 8fbb23e04c1..f707a791817 100644 --- a/indico/modules/events/requests/notifications.py +++ b/indico/modules/events/requests/notifications.py @@ -51,9 +51,10 @@ def notify_request_managers(req, template, **context): return context['event'] = event context['req'] = req - tpl_request_managers = _get_template_module(template, **context) - return make_email(request_manager_emails, from_address=config.NO_REPLY_EMAIL, reply_address=reply_addr, - subject=tpl_request_managers.get_subject(), body=tpl_request_managers.get_body()) + with event.force_event_locale(): + tpl_request_managers = _get_template_module(template, **context) + return make_email(request_manager_emails, from_address=config.NO_REPLY_EMAIL, reply_address=reply_addr, + template=tpl_request_managers) def notify_event_managers(req, template, **context): @@ -67,9 +68,10 @@ def notify_event_managers(req, template, **context): reply_addr = _get_notification_reply_email(req) context['event'] = event context['req'] = req - tpl_event_managers = _get_template_module(template, **context) - return make_email(event.all_manager_emails, from_address=config.NO_REPLY_EMAIL, reply_address=reply_addr, - subject=tpl_event_managers.get_subject(), body=tpl_event_managers.get_body()) + with event.force_event_locale(): + tpl_event_managers = _get_template_module(template, **context) + return make_email(event.all_manager_emails, from_address=config.NO_REPLY_EMAIL, reply_address=reply_addr, + template=tpl_event_managers) @email_sender diff --git a/indico/modules/events/requests/templates/emails/accepted_to_event_managers.txt b/indico/modules/events/requests/templates/emails/accepted_to_event_managers.txt index 73142638e43..677e677cbd1 100644 --- a/indico/modules/events/requests/templates/emails/accepted_to_event_managers.txt +++ b/indico/modules/events/requests/templates/emails/accepted_to_event_managers.txt @@ -1,12 +1,12 @@ {% extends 'events/requests/emails/base_to_event_managers.txt' %} {% block request_subject -%} - Request accepted + {% trans %}Request accepted{% endtrans %} {%- endblock %} {% block request_message -%} - The {{ req.definition.title }} request for your event has been accepted. + {% trans title=req.definition.title %}The {{ title }} request for your event has been accepted.{% endtrans %} {%- if req.comment %} - Comment: {{ req.comment }} + {% trans %}Comment:{% endtrans %} {{ req.comment }} {%- endif -%} {%- endblock %} diff --git a/indico/modules/events/requests/templates/emails/accepted_to_request_managers.txt b/indico/modules/events/requests/templates/emails/accepted_to_request_managers.txt index 1ebd57ff939..2018109d009 100644 --- a/indico/modules/events/requests/templates/emails/accepted_to_request_managers.txt +++ b/indico/modules/events/requests/templates/emails/accepted_to_request_managers.txt @@ -1,12 +1,12 @@ {% extends 'events/requests/emails/base_to_request_managers.txt' %} {% block request_subject -%} - Accepted service request + {% trans %}Accepted service request{% endtrans %} {%- endblock %} {% block request_message -%} - A {{ req.definition.title }} request has been accepted. + {% trans title=req.definition.title %}A {{ title }} request has been accepted.{% endtrans %} {%- if req.comment %} - Comment: {{ req.comment }} + {% trans %}Comment:{% endtrans %} {{ req.comment }} {%- endif -%} {%- endblock %} diff --git a/indico/modules/events/requests/templates/emails/base_to_event_managers.txt b/indico/modules/events/requests/templates/emails/base_to_event_managers.txt index 4222382970c..496f8209f28 100644 --- a/indico/modules/events/requests/templates/emails/base_to_event_managers.txt +++ b/indico/modules/events/requests/templates/emails/base_to_event_managers.txt @@ -1,18 +1,18 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} {%- block subject -%} [{{ req.definition.title }}] {% block request_subject %}{% endblock %} for {{ event.title }} {%- endblock -%} -{% block header_recipient %}event managers{% endblock %} +{% block header_recipient %}{% trans %}Dear event managers,{% endtrans %}{% endblock %} {% block body -%} {%- filter dedent -%} {% block request_message %}{% endblock %} - Event: {{ event.title }} - Requested by: {{ req.created_by_user.full_name }} - Details: {{ url_for('requests.event_requests_details', req, _external=True) }} + {% trans %}Event:{% endtrans %} {{ event.title }} + {% trans %}Requested by:{% endtrans %} {{ req.created_by_user.full_name }} + {% trans %}Details:{% endtrans %} {{ url_for('requests.event_requests_details', req, _external=True) }} {%- if self.request_details() %} {# empty line #} {% block request_details %}{% endblock -%} @@ -20,4 +20,4 @@ {%- endfilter %} {% endblock %} -{% block footer_title %}Service Requests{% endblock %} +{% block footer_title %}{% trans %}Service Requests{% endtrans %}{% endblock %} diff --git a/indico/modules/events/requests/templates/emails/base_to_request_managers.txt b/indico/modules/events/requests/templates/emails/base_to_request_managers.txt index 553098e4c10..c98489ee891 100644 --- a/indico/modules/events/requests/templates/emails/base_to_request_managers.txt +++ b/indico/modules/events/requests/templates/emails/base_to_request_managers.txt @@ -1,23 +1,23 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} {% macro user_details(user) -%} - Name: {{ user.full_name }} - Email: {{ user.email }} + {% trans %}Name:{% endtrans %} {{ user.full_name }} + {% trans %}Email:{% endtrans %} {{ user.email }} {%- if user.phone %} - Phone: {{ user.phone }} + {% trans %}Phone:{% endtrans %} {{ user.phone }} {%- endif -%} {%- endmacro %} {% macro event_details(event) -%} - Name: {{ event.title }} + {% trans %}Name:{% endtrans %} {{ event.title }} {% if event.start_dt.date() == event.end_dt.date() -%} - Date: {{ event.start_dt | format_date(timezone=event.tzinfo) }}, {{ event.start_dt | format_time(timezone=event.tzinfo) }} + {% trans %}Date:{% endtrans %} {{ event.start_dt | format_date(timezone=event.tzinfo) }}, {{ event.start_dt | format_time(timezone=event.tzinfo) }} {%- else -%} - Dates: {{ event.start_dt | format_date(timezone=event.tzinfo) }}, {{ event.start_dt | format_time(timezone=event.tzinfo) }} - {{ event.end_dt | format_date(timezone=event.tzinfo) }}, {{ event.end_dt | format_time(timezone=event.tzinfo) }} + {% trans %}Dates:{% endtrans %} {{ event.start_dt | format_date(timezone=event.tzinfo) }}, {{ event.start_dt | format_time(timezone=event.tzinfo) }} - {{ event.end_dt | format_date(timezone=event.tzinfo) }}, {{ event.end_dt | format_time(timezone=event.tzinfo) }} {%- endif %} - Location: {% if event.venue_name %}{{ event.venue_name }}: {% endif %}{{ event.room_name }} - Details: {{ event.external_url }} + {% trans %}Location:{% endtrans %} {% if event.venue_name %}{{ event.venue_name }}: {% endif %}{{ event.room_name }} + {% trans %}Details:{% endtrans %} {{ event.external_url }} {%- endmacro %} @@ -34,24 +34,24 @@ {% block request_message %}{% endblock %} {{ url_for('requests.event_requests_details', req, _external=True) }} - {% filter underline %}Requested by{% endfilter %} + {% filter underline %}{% trans %}Requested by{% endtrans %}{% endfilter %} {{ user_details(req.created_by_user) }} {%- if req.created_by_user != event.creator %} - {% filter underline %}Event created by{% endfilter %} + {% filter underline %}{% trans %}Event created by{% endtrans %}{% endfilter %} {{ user_details(event.creator) }} {%- endif %} - {% filter underline %}Event details{% endfilter %} + {% filter underline %}{% trans %}Event details{% endtrans %}{% endfilter %} {{ event_details(event) }} {%- if self.request_details() %} - {% filter underline %}Request details{% endfilter %} + {% filter underline %}{% trans %}Request details{% endtrans %}{% endfilter %} {% block request_details %}{% endblock -%} {% endif %} {%- endfilter %} {% endblock %} -{% block footer_title %}Service Requests{% endblock %} +{% block footer_title %}{% trans %}Service Requests{% endtrans %}{% endblock %} diff --git a/indico/modules/events/requests/templates/emails/new_modified_to_event_managers.txt b/indico/modules/events/requests/templates/emails/new_modified_to_event_managers.txt index a27d1a52785..2bf7ce4d6ea 100644 --- a/indico/modules/events/requests/templates/emails/new_modified_to_event_managers.txt +++ b/indico/modules/events/requests/templates/emails/new_modified_to_event_managers.txt @@ -1,9 +1,13 @@ {% extends 'events/requests/emails/base_to_event_managers.txt' %} {% block request_subject -%} - {% if new %}New request{% else %}Request modified{% endif %} + {% if new -%}{% trans %}New request{% endtrans %}{%- else -%}{% trans %}Request modified{% endtrans %}{%- endif %} {%- endblock %} {% block request_message -%} - A {{ req.definition.title }} request for your event has been {% if new %}sent{% else %}modified{% endif %}. + {% if new -%} + {% trans title=req.definition.title %}A {{ title }} request for your event has been sent.{% endtrans %} + {%- else -%} + {% trans title=req.definition.title %}A {{ title }} request for your event has been modified.{% endtrans %} + {%- endif %} {%- endblock %} diff --git a/indico/modules/events/requests/templates/emails/new_modified_to_request_managers.txt b/indico/modules/events/requests/templates/emails/new_modified_to_request_managers.txt index 905dba036ad..ce4528a6c9a 100644 --- a/indico/modules/events/requests/templates/emails/new_modified_to_request_managers.txt +++ b/indico/modules/events/requests/templates/emails/new_modified_to_request_managers.txt @@ -1,9 +1,17 @@ {% extends 'events/requests/emails/base_to_request_managers.txt' %} {% block request_subject -%} - {% if new %}New{% else %}Modified{% endif %} service request + {% if new -%} + {% trans %}New service request{% endtrans %} + {%- else -%} + {% trans %}Modified service request{% endtrans %} + {%- endif %} {%- endblock %} {% block request_message -%} - A {{ req.definition.title }} request has been {% if new %}submitted{% else %}modified{% endif %}. + {% if new -%} + {% trans title=req.definition.title %}A {{ title }} request has been submitted.{% endtrans %} + {%- else -%} + {% trans title=req.definition.title %}A {{ title }} request has been modified.{% endtrans %} + {%- endif %} {%- endblock %} diff --git a/indico/modules/events/requests/templates/emails/rejected_to_event_managers.txt b/indico/modules/events/requests/templates/emails/rejected_to_event_managers.txt index 55633f20806..1b5d50cc130 100644 --- a/indico/modules/events/requests/templates/emails/rejected_to_event_managers.txt +++ b/indico/modules/events/requests/templates/emails/rejected_to_event_managers.txt @@ -1,12 +1,12 @@ {% extends 'events/requests/emails/base_to_event_managers.txt' %} {% block request_subject -%} - Request rejected + {% trans %}Request rejected{% endtrans %} {%- endblock %} {% block request_message -%} - The {{ req.definition.title }} request for your event has been rejected. + {% trans title=req.definition.title %}The {{ title }} request for your event has been rejected.{% endtrans %} {%- if req.comment %} - Comment: {{ req.comment }} + {% trans %}Comment:{% endtrans %} {{ req.comment }} {%- endif -%} {%- endblock %} diff --git a/indico/modules/events/requests/templates/emails/rejected_to_request_managers.txt b/indico/modules/events/requests/templates/emails/rejected_to_request_managers.txt index 80a11e5ae6c..ec91f400828 100644 --- a/indico/modules/events/requests/templates/emails/rejected_to_request_managers.txt +++ b/indico/modules/events/requests/templates/emails/rejected_to_request_managers.txt @@ -1,12 +1,12 @@ {% extends 'events/requests/emails/base_to_request_managers.txt' %} {% block request_subject -%} - Rejected service request + {% trans %}Rejected service request{% endtrans %} {%- endblock %} {% block request_message -%} - A {{ req.definition.title }} request has been rejected. + {% trans title=req.definition.title %}A {{ title }} request has been rejected.{% endtrans %} {%- if req.comment %} - Comment: {{ req.comment }} + {% trans %}Comment:{% endtrans %} {{ req.comment }} {%- endif -%} {%- endblock %} diff --git a/indico/modules/events/requests/templates/emails/tests/accepted_to_request_managers.txt b/indico/modules/events/requests/templates/emails/tests/accepted_to_request_managers.txt index c952cf2deb0..de5cdf10ae5 100644 --- a/indico/modules/events/requests/templates/emails/tests/accepted_to_request_managers.txt +++ b/indico/modules/events/requests/templates/emails/tests/accepted_to_request_managers.txt @@ -4,21 +4,21 @@ http://localhost/event/0/manage/requests/meeting/?comment=Meow&created_by_user=% Requested by ------------ -Name: Arthas Menethil -Email: arthas@frozenthrone.wow -Phone: 1337 +Name: Arthas Menethil +Email: arthas@frozenthrone.wow +Phone: 1337 Event created by ---------------- -Name: Guinea Pig -Email: 1337@example.test +Name: Guinea Pig +Email: 1337@example.test Event details ------------- -Name: dummy#0 -Dates: 11 Nov 2022, 13:37 - 13 Nov 2022, 13:37 +Name: dummy#0 +Dates: 11 Nov 2022, 13:37 - 13 Nov 2022, 13:37 Location: -Details: http://localhost/event/0/ +Details: http://localhost/event/0/ -- diff --git a/indico/modules/events/requests/templates/emails/tests/new_modified_to_request_managers.txt b/indico/modules/events/requests/templates/emails/tests/new_modified_to_request_managers.txt index eb5fc3f64df..d2b050e4f33 100644 --- a/indico/modules/events/requests/templates/emails/tests/new_modified_to_request_managers.txt +++ b/indico/modules/events/requests/templates/emails/tests/new_modified_to_request_managers.txt @@ -3,21 +3,21 @@ http://localhost/event/0/manage/requests/meeting/?comment=Meow&created_by_user=% Requested by ------------ -Name: Arthas Menethil -Email: arthas@frozenthrone.wow -Phone: 1337 +Name: Arthas Menethil +Email: arthas@frozenthrone.wow +Phone: 1337 Event created by ---------------- -Name: Guinea Pig -Email: 1337@example.test +Name: Guinea Pig +Email: 1337@example.test Event details ------------- -Name: dummy#0 -Dates: 11 Nov 2022, 13:37 - 13 Nov 2022, 13:37 +Name: dummy#0 +Dates: 11 Nov 2022, 13:37 - 13 Nov 2022, 13:37 Location: -Details: http://localhost/event/0/ +Details: http://localhost/event/0/ -- diff --git a/indico/modules/events/requests/templates/emails/tests/rejected_to_request_managers.txt b/indico/modules/events/requests/templates/emails/tests/rejected_to_request_managers.txt index 5e9f05fb974..8d6f16e1ce3 100644 --- a/indico/modules/events/requests/templates/emails/tests/rejected_to_request_managers.txt +++ b/indico/modules/events/requests/templates/emails/tests/rejected_to_request_managers.txt @@ -4,21 +4,21 @@ http://localhost/event/0/manage/requests/meeting/?comment=Meow&created_by_user=% Requested by ------------ -Name: Arthas Menethil -Email: arthas@frozenthrone.wow -Phone: 1337 +Name: Arthas Menethil +Email: arthas@frozenthrone.wow +Phone: 1337 Event created by ---------------- -Name: Guinea Pig -Email: 1337@example.test +Name: Guinea Pig +Email: 1337@example.test Event details ------------- -Name: dummy#0 -Dates: 11 Nov 2022, 13:37 - 13 Nov 2022, 13:37 +Name: dummy#0 +Dates: 11 Nov 2022, 13:37 - 13 Nov 2022, 13:37 Location: -Details: http://localhost/event/0/ +Details: http://localhost/event/0/ -- diff --git a/indico/modules/events/requests/templates/emails/tests/withdrawn_to_request_managers.txt b/indico/modules/events/requests/templates/emails/tests/withdrawn_to_request_managers.txt index 8c1ca519eb4..ed32e9fcaff 100644 --- a/indico/modules/events/requests/templates/emails/tests/withdrawn_to_request_managers.txt +++ b/indico/modules/events/requests/templates/emails/tests/withdrawn_to_request_managers.txt @@ -3,21 +3,21 @@ http://localhost/event/0/manage/requests/meeting/?comment=Meow&created_by_user=% Requested by ------------ -Name: Arthas Menethil -Email: arthas@frozenthrone.wow -Phone: 1337 +Name: Arthas Menethil +Email: arthas@frozenthrone.wow +Phone: 1337 Event created by ---------------- -Name: Guinea Pig -Email: 1337@example.test +Name: Guinea Pig +Email: 1337@example.test Event details ------------- -Name: dummy#0 -Dates: 11 Nov 2022, 13:37 - 13 Nov 2022, 13:37 +Name: dummy#0 +Dates: 11 Nov 2022, 13:37 - 13 Nov 2022, 13:37 Location: -Details: http://localhost/event/0/ +Details: http://localhost/event/0/ -- diff --git a/indico/modules/events/requests/templates/emails/withdrawn_to_event_managers.txt b/indico/modules/events/requests/templates/emails/withdrawn_to_event_managers.txt index 501f61acc46..5abaf90e7af 100644 --- a/indico/modules/events/requests/templates/emails/withdrawn_to_event_managers.txt +++ b/indico/modules/events/requests/templates/emails/withdrawn_to_event_managers.txt @@ -1,9 +1,9 @@ {% extends 'events/requests/emails/base_to_event_managers.txt' %} {% block request_subject -%} - Request withdrawn + {% trans %}Request withdrawn{% endtrans %} {%- endblock %} {% block request_message -%} - The {{ req.definition.title }} request for your event has been withdrawn. + {% trans title=req.definition.title %}The {{ title }} request for your event has been withdrawn.{% endtrans %} {%- endblock %} diff --git a/indico/modules/events/requests/templates/emails/withdrawn_to_request_managers.txt b/indico/modules/events/requests/templates/emails/withdrawn_to_request_managers.txt index 997ab02b3df..5f4e3b32034 100644 --- a/indico/modules/events/requests/templates/emails/withdrawn_to_request_managers.txt +++ b/indico/modules/events/requests/templates/emails/withdrawn_to_request_managers.txt @@ -1,9 +1,9 @@ {% extends 'events/requests/emails/base_to_request_managers.txt' %} {% block request_subject -%} - Withdrawn service request + {% trans %}Withdrawn service request{% endtrans %} {%- endblock %} {% block request_message -%} - A {{ req.definition.title }} request has been withdrawn. + {% trans title=req.definition.title %}A {{ title }} request has been withdrawn.{% endtrans %} {%- endblock %} diff --git a/indico/modules/events/static/notifications_test.py b/indico/modules/events/static/notifications_test.py index 024e0d358ff..5bee0a5d5ca 100644 --- a/indico/modules/events/static/notifications_test.py +++ b/indico/modules/events/static/notifications_test.py @@ -7,7 +7,6 @@ from pathlib import Path -from indico.modules.events.papers.models.revisions import PaperRevisionState from indico.web.flask.templating import get_template_module @@ -16,13 +15,3 @@ def test_download_notification_email_plaintext(snapshot, dummy_event, dummy_user event=dummy_event, link='http://localhost/', user=dummy_user) snapshot.snapshot_dir = Path(__file__).parent / 'templates/emails/tests' snapshot.assert_match(template.get_body(), 'download_notification_email.txt') - - -def test_paper_judgement_email_plaintext(snapshot, dummy_user, dummy_contribution): - revision = {'submitter': dummy_user, 'state': PaperRevisionState.accepted, - 'judgment_comment': 'This is a\n comment!'} - dummy_contribution.id = 0 - template = get_template_module('events/static/emails/paper_judgment_notification_email.txt', - paper=revision, contribution=dummy_contribution) - snapshot.snapshot_dir = Path(__file__).parent / 'templates/emails/tests' - snapshot.assert_match(template.get_body(), 'paper_judgment_notification_email.txt') diff --git a/indico/modules/events/static/tasks.py b/indico/modules/events/static/tasks.py index 1fb12f268ae..7f34896ca5e 100644 --- a/indico/modules/events/static/tasks.py +++ b/indico/modules/events/static/tasks.py @@ -51,10 +51,11 @@ def build_static_site(static_site): @email_sender def notify_static_site_success(static_site): - template = get_template_module('events/static/emails/download_notification_email.txt', - user=static_site.creator, event=static_site.event, - link=url_for('static_site.download', static_site, _external=True)) - return make_email({static_site.creator.email}, template=template, html=False) + with static_site.creator.force_user_locale(): + template = get_template_module('events/static/emails/download_notification_email.txt', + user=static_site.creator, event=static_site.event, + link=url_for('static_site.download', static_site, _external=True)) + return make_email({static_site.creator.email}, template=template, html=False) @celery.periodic_task(name='static_sites_cleanup', run_every=crontab(minute='30', hour='3', day_of_week='monday')) diff --git a/indico/modules/events/static/templates/emails/download_notification_email.txt b/indico/modules/events/static/templates/emails/download_notification_email.txt index 7172d87c0ca..28a6609508f 100644 --- a/indico/modules/events/static/templates/emails/download_notification_email.txt +++ b/indico/modules/events/static/templates/emails/download_notification_email.txt @@ -1,15 +1,15 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} -{% block subject %}Offline copy of an event ready for download{% endblock %} +{% block subject %}{% trans %}Offline copy of an event ready for download{% endtrans %}{% endblock %} {% block header_recipient -%} - {{ user.first_name }} + {% trans name=user.first_name %}Dear {{ name }},{% endtrans %} {%- endblock %} {% block body -%} -The offline copy of the event "{{ event.title }}" is ready for download. +{% trans title=event.title %}The offline copy of the event "{{ title }}" is ready for download.{% endtrans %} -Download link: {{ link }} +{% trans %}Download link:{% endtrans %} {{ link }} {%- endblock %} {% block footer_url %}{{ event.external_url }}{% endblock %} diff --git a/indico/modules/events/static/templates/emails/paper_judgment_notification_email.txt b/indico/modules/events/static/templates/emails/paper_judgment_notification_email.txt deleted file mode 100644 index ad1bce038f0..00000000000 --- a/indico/modules/events/static/templates/emails/paper_judgment_notification_email.txt +++ /dev/null @@ -1,40 +0,0 @@ -{% extends 'emails/base.txt' %} - -{% macro get_comments() %} - {% filter dedent -%} - Please see the comments from the reviewing team below: - - {{ paper.judgment_comment }} - {%- endfilter %} -{% endmacro %} - -{% block subject -%} - {% if paper.state.name in ('accepted', 'rejected') -%} - Your paper "{{contribution.title}}" was {{ paper.state.name }}. - {% elif paper.state.name == 'to_be_corrected' -%} - Your paper "{{contribution.title}}" requires changes. - {% endif %} -{%- endblock %} - -{% block header_recipient -%} - {{ paper.submitter.first_name }} -{%- endblock %} - -{% block body -%} - {% filter dedent -%} - {% if paper.state.name in ('accepted', 'rejected') %} - After the reviewing process your paper "{{ contribution.title }} (#{{ contribution.friendly_id }})", submitted for "{{ contribution.event.title }}" has been {{ paper.state.name }}. - {{ get_comments() }} - You may proceed to your paper page: - {% elif paper.state.name == 'to_be_corrected' %} - After the reviewing process your paper "{{ contribution.title }} (#{{ contribution.friendly_id }})", submitted for "{{ contribution.event.title }}" is required to be corrected. - {{ get_comments() }} - You may then apply the requested modifications to your paper and submit the modified version for review. - In order to do so, please proceed to your paper page: - {% endif %} - - {{ url_for('papers.paper_timeline', contribution, _external=true) }} - {%- endfilter %} -{%- endblock %} - -{% block footer_url %}{{ contribution.event.external_url }}{% endblock %} diff --git a/indico/modules/events/surveys/models/surveys.py b/indico/modules/events/surveys/models/surveys.py index 2d7dec8f7cb..893464891f4 100644 --- a/indico/modules/events/surveys/models/surveys.py +++ b/indico/modules/events/surveys/models/surveys.py @@ -297,8 +297,9 @@ def close(self): def send_start_notification(self): if not self.notifications_enabled or self.start_notification_sent or not self.event.has_feature('surveys'): return - template_module = get_template_module('events/surveys/emails/start_notification_email.txt', survey=self) - email = make_email(bcc_list=self.start_notification_recipients, template=template_module) + with self.event.force_event_locale(): + template_module = get_template_module('events/surveys/emails/start_notification_email.txt', survey=self) + email = make_email(bcc_list=self.start_notification_recipients, template=template_module) send_email(email, event=self.event, module='Surveys') logger.info('Sending start notification for survey %s', self) self.start_notification_sent = True @@ -306,8 +307,10 @@ def send_start_notification(self): def send_submission_notification(self, submission): if not self.notifications_enabled: return - template_module = get_template_module('events/surveys/emails/new_submission_email.txt', submission=submission) - email = make_email(bcc_list=self.new_submission_emails, template=template_module) + with self.event.force_event_locale(): + template_module = get_template_module('events/surveys/emails/new_submission_email.txt', + submission=submission) + email = make_email(bcc_list=self.new_submission_emails, template=template_module) send_email(email, event=self.event, module='Surveys') logger.info('Sending submission notification for survey %s', self) diff --git a/indico/modules/events/surveys/templates/emails/new_submission_email.txt b/indico/modules/events/surveys/templates/emails/new_submission_email.txt index d0e386a7877..8bcad852a17 100644 --- a/indico/modules/events/surveys/templates/emails/new_submission_email.txt +++ b/indico/modules/events/surveys/templates/emails/new_submission_email.txt @@ -1,27 +1,35 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} {% set survey = submission.survey %} {% block subject -%} - New survey submission for "{{ survey.title }}" on the event "{{ survey.event.title }}" + {% trans sur=survey.title, evt=survey.event.title %}New survey submission for "{{ sur }}" on the event "{{ evt }}"{% endtrans %} {%- endblock %} {% block header -%}{%- endblock %} {% block body -%} {%- filter dedent -%} - A new submission has been made for the survey "{{ survey.title }}" on the event "{{ survey.event.title }}" - {%- if not submission.is_anonymous %} by {{ submission.user.full_name }}{% endif -%}. + {%- if submission.is_anonymous -%} + {%- trans sur=survey.title, evt=survey.event.title -%} + A new submission has been made for the survey "{{ sur }}" on the event "{{ evt }}". + {%- endtrans -%} + {%- else -%} + {%- trans sur=survey.title, evt=survey.event.title, name=submission.user.full_name -%} + A new submission has been made for the survey "{{ sur }}" on the event "{{ evt }}" + by {{ name }}. + {%- endtrans -%} + {%- endif %} - You can access the new submission here: + {% trans %}You can access the new submission here:{% endtrans %} {{ url_for('surveys.display_submission', submission, _external=true) }} - You can access all the submissions by clicking on the link below: + {% trans %}You can access all the submissions by clicking on the link below:{% endtrans %} {{ url_for('surveys.manage_survey', survey, _external=true) }} {%- endfilter -%} {%- endblock %} {% block footer_title -%} - Surveys + {% trans %}Surveys{% endtrans %} {%- endblock %} {% block footer_url -%} diff --git a/indico/modules/events/surveys/templates/emails/start_notification_email.txt b/indico/modules/events/surveys/templates/emails/start_notification_email.txt index 80dfb9c0d8a..6be21c58907 100644 --- a/indico/modules/events/surveys/templates/emails/start_notification_email.txt +++ b/indico/modules/events/surveys/templates/emails/start_notification_email.txt @@ -1,22 +1,22 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} {% block subject -%} - Survey "{{ survey.title }}" started on the event "{{ survey.event.title }}" + {% trans sur=survey.title, evt=survey.event.title %}Survey "{{ sur }}" started on the event "{{ evt }}"{% endtrans %} {%- endblock %} {% block header -%}{%- endblock %} {% block body -%} {%- filter dedent -%} - The survey "{{ survey.title }}" on the event "{{ survey.event.title }}" is now open. + {% trans sur=survey.title, evt=survey.event.title %}The survey "{{ sur }}" on the event "{{ evt }}" is now open.{% endtrans %} - You may answer the survey by clicking the link below: + {% trans %}You may answer the survey by clicking the link below:{% endtrans %} {{ url_for('surveys.display_survey_form', survey, _external=true) }} {%- endfilter -%} {%- endblock %} {% block footer_title -%} - Surveys + {% trans %}Surveys{% endtrans %} {%- endblock %} {% block footer_url -%} diff --git a/indico/modules/events/templates/emails/event_creation.txt b/indico/modules/events/templates/emails/event_creation.txt index 8ddee584be7..f5063c89219 100644 --- a/indico/modules/events/templates/emails/event_creation.txt +++ b/indico/modules/events/templates/emails/event_creation.txt @@ -1,66 +1,73 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} {% block subject -%} - New {{ event.type }} in Indico + {% if event.type == 'conference' -%} + {% trans %}New conference in Indico{% endtrans %} + {%- elif event.type == 'meeting' -%} + {% trans %}New meeting in Indico{% endtrans %} + {%- else -%} + {% trans %}New lecture in Indico{% endtrans %} + {%- endif %} {%- endblock %} {% block header -%}{%- endblock %} {% block body -%} {%- filter dedent -%} - {% filter underline %}Title{% endfilter %} + {% filter underline %}{% trans %}Title{% endtrans %}{% endfilter %} {{ event.title }} - {% filter underline %}Category{% endfilter %} + {% filter underline %}{% trans %}Category{% endtrans %}{% endfilter %} {{ event.category.chain_titles|join(' » ') }} - {% filter underline %}Creator{% endfilter %} + {% filter underline %}{% trans %}Creator{% endtrans %}{% endfilter %} {{ event.creator.full_name }} {%- if event.person_links %} - - {{ ('Speakers' if event.type == 'lecture' else 'Chairpersons' ) | underline }} + {% filter underline -%} + {% if event.type == 'lecture' %}{% trans %}Speakers{% endtrans %}{% else %}{% trans %}Chairpersons{% endtrans %}{% endif %} + {%- endfilter %} {{ event.person_links|sort(attribute='full_name')|join('; ', attribute='full_name') }} {%- endif -%} {%- if event.venue_name and event.room_name %} - {% filter underline %}Location{% endfilter %} + {% filter underline %}{% trans %}Location{% endtrans %}{% endfilter %} {{ event.room_name }} ({{ event.venue_name }}) {%- elif event.venue_name %} - {% filter underline %}Venue{% endfilter %} + {% filter underline %}{% trans %}Venue{% endtrans %}{% endfilter %} {{ event.venue_name }} {%- elif event.room_name %} - {% filter underline %}Room{% endfilter %} + {% filter underline %}{% trans %}Room{% endtrans %}{% endfilter %} {{ event.room_name }} {%- endif -%} {%- if event.description %} - {% filter underline %}Description{% endfilter %} + {% filter underline %}{% trans %}Description{% endtrans %}{% endfilter %} {{ event.description | striptags }} {%- endif %} {% if not occurrences -%} - {% filter underline %}Date{% endfilter %} + {% filter underline %}{% trans %}Date{% endtrans %}{% endfilter %} {{ event.start_dt|format_date(timezone=event.timezone) }} {%- if event.start_dt_local.date() != event.end_dt_local.date() %} {#- #} - {{ event.end_dt|format_date(timezone=event.timezone) }} {%- endif %} - {% filter underline %}Time{% endfilter %} + {% filter underline %}{% trans %}Time{% endtrans %}{% endfilter %} {{ event.start_dt|format_time(timezone=event.timezone) }} - {{ event.end_dt|format_time(timezone=event.timezone) }} {#- #} ({{ event.timezone }}) - {% filter underline %}URL{% endfilter %} + {% filter underline %}{% trans %}URL{% endtrans %}{% endfilter %} {{ event.external_url }} {%- else -%} - {% filter underline %}Timezone{% endfilter %} + {% filter underline %}{% trans %}Timezone{% endtrans %}{% endfilter %} {{ event.timezone }} - {% filter underline %}Occurrences{% endfilter -%} + {% filter underline %}{% trans %}Occurrences{% endtrans %}{% endfilter -%} {% for evt in occurrences|sort(attribute='start_dt') %} {{ evt.start_dt|format_date(timezone=evt.timezone) }}, {# -#} {{ evt.start_dt|format_time(timezone=evt.timezone) }} - {# -#} @@ -72,7 +79,7 @@ {%- endblock %} {% block footer_title -%} - Event notifications + {% trans %}Event notifications{% endtrans %} {%- endblock %} {% block footer_url %}{% endblock %} diff --git a/indico/modules/events/templates/emails/move_request_closure.txt b/indico/modules/events/templates/emails/move_request_closure.txt index 0242abf6d1d..175ce7d1aa4 100644 --- a/indico/modules/events/templates/emails/move_request_closure.txt +++ b/indico/modules/events/templates/emails/move_request_closure.txt @@ -1,10 +1,10 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} {% block subject -%} {%- if accept -%} - Event move request accepted + {% trans %}Event move request accepted{% endtrans %} {%- else -%} - Event move request rejected + {% trans %}Event move request rejected{% endtrans %} {%- endif -%} {%- endblock %} @@ -14,15 +14,15 @@ {%- filter dedent -%} {%- if accept -%} {% if events|length == 1 %} - Event moved: + {% trans %}Event moved:{% endtrans %} {% else %} - The following events have been moved: + {% trans %}The following events have been moved:{% endtrans %} {% endif %} {%- else -%} {% if events|length == 1 %} - Request to move event rejected: + {% trans %}Request to move event rejected:{% endtrans %} {% else %} - Move requests of the following events have been rejected: + {% trans %}Move requests of the following events have been rejected:{% endtrans %} {% endif %} {%- endif %} @@ -30,19 +30,25 @@ - {{ evt.title }} ({{ evt.external_url }}) {%- endfor %} - {% filter underline %}{{ 'New' if accept else 'Requested' }} category{% endfilter %} + {% filter underline %} + {%- if accept -%} + {% trans %}New category{% endtrans %} + {%- else -%} + {% trans %}Requested category{% endtrans %} + {%- endif -%} + {% endfilter %} {{ target_category.chain_titles|join(' » ') -}} {% if not accept and reason %} - {% filter underline %}Rejection reason{% endfilter %} + {% filter underline %}{% trans %}Rejection reason{% endtrans %}{% endfilter %} {{ reason }} {%- endif -%} {%- endfilter -%} {%- endblock %} {% block footer_title -%} - Event notifications + {% trans %}Event notifications{% endtrans %} {%- endblock %} {% block footer_url %}{% endblock %} diff --git a/indico/modules/events/templates/emails/move_request_creation.txt b/indico/modules/events/templates/emails/move_request_creation.txt index 8743948de7d..1a336f22bc1 100644 --- a/indico/modules/events/templates/emails/move_request_creation.txt +++ b/indico/modules/events/templates/emails/move_request_creation.txt @@ -1,7 +1,7 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} {% block subject -%} - Event move request created + {% trans %}Event move request created{% endtrans %} {%- endblock %} {% block header -%}{%- endblock %} @@ -9,30 +9,30 @@ {% block body -%} {%- filter dedent -%} {%- if events|length == 1 -%} - There is a new move request for the category: + {% trans %}There is a new move request for the category:{% endtrans %} {%- else -%} - There are new move requests for the category: + {% trans %}There are new move requests for the category:{% endtrans %} {%- endif %} {{ target_category.chain_titles|join(' » ') }} - {% filter underline %}Requested events{% endfilter %} + {% filter underline %}{% trans %}Requested events{% endtrans %}{% endfilter %} {%- for evt in events %} {{ evt.title }} ({{ evt.external_url }}) {%- endfor -%} {% if comment %} - {% filter underline %}Comment{% endfilter %} + {% filter underline %}{% trans %}Comment{% endtrans %}{% endfilter %} {{ comment }} {%- endif %} - View all move requests here: + {% trans %}View all move requests here:{% endtrans %} {{ url_for('categories.manage_moderation', target_category, _external=true) }} {%- endfilter -%} {%- endblock %} {% block footer_title -%} - Event notifications + {% trans %}Event notifications{% endtrans %} {%- endblock %} {% block footer_url %}{% endblock %} diff --git a/indico/modules/events/timetable/templates/display/_weeks.html b/indico/modules/events/timetable/templates/display/_weeks.html index da9d9094d03..60ef44ed16f 100644 --- a/indico/modules/events/timetable/templates/display/_weeks.html +++ b/indico/modules/events/timetable/templates/display/_weeks.html @@ -215,7 +215,7 @@ {% set start_time_minutes = (start_time.strftime('%-H')|int*60 + start_time.strftime('%-M')|int) %} {% set next_entry = (day_entries.keys()|list)[loop.index] %} {% if next_entry %} - {% set next_start_minutes = (next_entry.strftime('%-H')|int*60 + next_entry.strftime('%-M')|int)%} + {% set next_start_minutes = (next_entry.strftime('%-H')|int*60 + next_entry.strftime('%-M')|int) %} {% else %} {% set next_start_minutes = start_time_minutes %} {% endif %} diff --git a/indico/modules/rb/models/blocked_rooms_test.py b/indico/modules/rb/models/blocked_rooms_test.py index fde5bb00ed4..79ecca09020 100644 --- a/indico/modules/rb/models/blocked_rooms_test.py +++ b/indico/modules/rb/models/blocked_rooms_test.py @@ -33,7 +33,8 @@ def test_reject(dummy_user, dummy_blocking, smtp, with_user, with_reason): kwargs['reason'] = 'foo' br.reject(**kwargs) assert br.state == BlockedRoom.State.rejected - mail = extract_emails(smtp, one=True, to=dummy_blocking.created_by_user.email, subject='Room blocking REJECTED') + mail = extract_emails(smtp, one=True, to=dummy_blocking.created_by_user.email, + subject='[Indico] Room blocking REJECTED') if with_reason: assert kwargs['reason'] in mail.as_string() assert not smtp.outbox @@ -64,7 +65,8 @@ def test_approve(create_user, create_reservation, create_blocking, smtp, for occ in resv2.occurrences: assert occ.is_rejected == (colliding_occurrence and blocking.is_active_at(occ.date)) if notify_blocker: - extract_emails(smtp, one=True, to=blocking.created_by_user.email, subject='Room blocking ACCEPTED') + extract_emails(smtp, one=True, to=blocking.created_by_user.email, + subject='[Indico] Room blocking ACCEPTED') assert len(smtp.outbox) == 2 * (colliding_occurrence + colliding_reservation) # 2 emails per rejection diff --git a/indico/modules/rb/notifications/blockings.py b/indico/modules/rb/notifications/blockings.py index 8da61f8897b..11fcf8c0eee 100644 --- a/indico/modules/rb/notifications/blockings.py +++ b/indico/modules/rb/notifications/blockings.py @@ -5,9 +5,8 @@ # modify it under the terms of the MIT License; see the # LICENSE file for more details. -from flask import render_template - from indico.core.notifications import email_sender, make_email +from indico.web.flask.templating import get_template_module @email_sender @@ -16,10 +15,10 @@ def notify_request(owner, blocking, blocked_rooms): Expect only blockings for rooms owned by the specified owner. """ - subject = 'Confirm room blockings' - body = render_template('rb/emails/blockings/awaiting_confirmation_email_to_manager.txt', - owner=owner, blocking=blocking, blocked_rooms=blocked_rooms) - return make_email(owner.email, subject=subject, body=body) + with owner.force_user_locale(): + tpl = get_template_module('rb/emails/blockings/awaiting_confirmation_email_to_manager.txt', + owner=owner, blocking=blocking, blocked_rooms=blocked_rooms) + return make_email(owner.email, template=tpl) @email_sender @@ -28,9 +27,9 @@ def notify_request_response(blocked_room): Notify blocking creator about approval/rejection of his blocking request for a room. """ - to = blocked_room.blocking.created_by_user.email + user = blocked_room.blocking.created_by_user verb = blocked_room.State(blocked_room.state).title.upper() - subject = f'Room blocking {verb}' - body = render_template('rb/emails/blockings/state_email_to_user.txt', - blocking=blocked_room.blocking, blocked_room=blocked_room, verb=verb) - return make_email(to, subject=subject, body=body) + with user.force_user_locale(): + tpl = get_template_module('rb/emails/blockings/state_email_to_user.txt', + blocking=blocked_room.blocking, blocked_room=blocked_room, verb=verb) + return make_email(user.email, template=tpl) diff --git a/indico/modules/rb/notifications/notifications_test.py b/indico/modules/rb/notifications/notifications_test.py index 4965eccaa2a..12794ac205d 100644 --- a/indico/modules/rb/notifications/notifications_test.py +++ b/indico/modules/rb/notifications/notifications_test.py @@ -14,7 +14,8 @@ from indico.modules.rb.models.blocked_rooms import BlockedRoomState from indico.modules.rb.models.reservation_occurrences import ReservationOccurrenceState -from indico.modules.rb.models.reservations import RepeatFrequency, RepeatMapping +from indico.modules.rb.models.reservations import RepeatFrequency, RepeatMapping, ReservationState +from indico.web.flask.templating import get_template_module pytest_plugins = 'indico.modules.rb.testing.fixtures' @@ -22,10 +23,10 @@ def _assert_snapshot(snapshot, template_name, type, suffix='', /, **context): __tracebackhide__ = True - template = render_template(f'rb/emails/{type}/{template_name}', **context) + template = get_template_module(f'rb/emails/{type}/{template_name}', **context) snapshot.snapshot_dir = Path(__file__).parent.parent / f'templates/emails/{type}/tests' snapshot_name, snapshot_ext = os.path.splitext(template_name) - snapshot.assert_match(template, snapshot_name + suffix + snapshot_ext) + snapshot.assert_match(template.get_body(), snapshot_name + suffix + snapshot_ext) @pytest.mark.parametrize(('suffix', 'rooms'), ( @@ -46,7 +47,7 @@ def test_blocking_confirmation_email_plaintext(snapshot, dummy_room, dummy_user, def test_blocking_state_email_plaintext(snapshot, create_blocking, dummy_room, suffix, state): blocking = create_blocking(id=2) _assert_snapshot(snapshot, 'state_email_to_user.txt', 'blockings', suffix, - blocking=blocking, verb='forgotten', + blocking=blocking, verb=state.title.upper(), blocked_room={'room': dummy_room, 'state': state, 'State': BlockedRoomState}) @@ -85,15 +86,17 @@ def test_reservation_confirmation_emails_plaintext(snapshot, snapshot_name, crea ('creation_email_to_user.txt', '_repeat', None, RepeatFrequency.DAY), ('creation_email_to_user.txt', '_repeat_excluded_1', 1, RepeatFrequency.DAY), ('creation_email_to_user.txt', '_repeat_excluded_2', 2, RepeatFrequency.DAY), - ('creation_pre_email_to_manager.txt', '', None, RepeatFrequency.NEVER), - ('creation_pre_email_to_user.txt', '', None, RepeatFrequency.NEVER), - ('creation_pre_email_to_user.txt', '_repeat', None, RepeatFrequency.DAY), + ('creation_email_to_manager.txt', '', None, RepeatFrequency.NEVER), + ('creation_email_to_user.txt', '_pre', None, RepeatFrequency.NEVER), + ('creation_email_to_user.txt', '_repeat_pre', None, RepeatFrequency.DAY), )) def test_reservation_creation_emails_plaintext( snapshot, snapshot_name, create_reservation, suffix, excluded_days, repeat ): res = create_reservation(id=1337, start_dt=datetime(2022, 11, 11, 13, 37), end_dt=datetime(2022, 11, 21, 14, 37), repeat_frequency=repeat) + if 'pre' in suffix: + res.state = ReservationState.pending if excluded_days: for occ in res.occurrences[1:(excluded_days+1)]: occ.state = ReservationOccurrenceState.cancelled @@ -134,4 +137,6 @@ def test_reservation_rejection_emails_plaintext(snapshot, snapshot_name, create_ def test_reservation_emails_plaintext(snapshot, snapshot_name, create_reservation): res = create_reservation(id=0, start_dt=datetime(2022, 11, 11, 13, 37), end_dt=datetime(2022, 11, 11, 14, 37)) res.room.key_location = 'In a pocket dimension reachable via interpretative dance.' - _assert_snapshot(snapshot, snapshot_name, 'reservations', reservation=res) + template = render_template(f'rb/emails/reservations/{snapshot_name}', reservation=res) + snapshot.snapshot_dir = Path(__file__).parent.parent / 'templates/emails/reservations/tests' + snapshot.assert_match(template, snapshot_name) diff --git a/indico/modules/rb/notifications/reservation_occurrences.py b/indico/modules/rb/notifications/reservation_occurrences.py index d9cb7ec3337..9f44c9acb5a 100644 --- a/indico/modules/rb/notifications/reservation_occurrences.py +++ b/indico/modules/rb/notifications/reservation_occurrences.py @@ -17,12 +17,9 @@ def __init__(self, occurrence): self.occurrence = occurrence self.start_dt = format_datetime(occurrence.start_dt) - def _get_email_subject(self, **mail_params): - return super()._get_email_subject(**mail_params, subject_suffix='(SINGLE OCCURRENCE)') - - def _make_body(self, mail_params, **body_params): + def _make_template(self, mail_params, **body_params): body_params['occurrence'] = self.occurrence - return super()._make_body(mail_params, **body_params) + return super()._make_template(mail_params, **body_params) @email_sender @@ -31,14 +28,8 @@ def notify_cancellation(occurrence): raise ValueError('Occurrence is not cancelled') notification = ReservationOccurrenceNotification(occurrence) return [_f for _f in [ - notification.compose_email_to_user( - subject='Booking cancelled on', - template_name='occurrence_cancellation_email_to_user' - ), - notification.compose_email_to_manager( - subject='Booking cancelled on', - template_name='occurrence_cancellation_email_to_manager' - ), + notification.compose_email_to_user(template_name='occurrence_cancellation_email_to_user'), + notification.compose_email_to_manager(template_name='occurrence_cancellation_email_to_manager'), ] if _f] @@ -48,19 +39,14 @@ def notify_rejection(occurrence): raise ValueError('Occurrence is not rejected') notification = ReservationOccurrenceNotification(occurrence) return [_f for _f in [ - notification.compose_email_to_user( - subject='Booking rejected on', - template_name='occurrence_rejection_email_to_user' - ), - notification.compose_email_to_manager( - subject='Booking rejected on', - template_name='occurrence_rejection_email_to_manager' - ) + notification.compose_email_to_user(template_name='occurrence_rejection_email_to_user'), + notification.compose_email_to_manager(template_name='occurrence_rejection_email_to_manager') ] if _f] @email_sender def notify_upcoming_occurrences(user, occurrences): - tpl = get_template_module('rb/emails/reservations/reminders/upcoming_occurrence.html', - occurrences=occurrences, user=user) - return make_email(to_list={user.email}, template=tpl, html=True) + with user.force_user_locale(): + tpl = get_template_module('rb/emails/reservations/reminders/upcoming_occurrence.html', + occurrences=occurrences, user=user) + return make_email(to_list={user.email}, template=tpl, html=True) diff --git a/indico/modules/rb/notifications/reservations.py b/indico/modules/rb/notifications/reservations.py index 913d804b2f3..e7ff8e6f27d 100644 --- a/indico/modules/rb/notifications/reservations.py +++ b/indico/modules/rb/notifications/reservations.py @@ -5,7 +5,6 @@ # modify it under the terms of the MIT License; see the # LICENSE file for more details. -from flask import render_template from sqlalchemy import and_ from sqlalchemy.orm import load_only @@ -13,6 +12,7 @@ from indico.modules.rb.settings import RoomEmailMode, rb_user_settings from indico.modules.users import User, UserSetting from indico.util.date_time import format_datetime +from indico.util.i18n import force_locale from indico.web.flask.templating import get_template_module @@ -46,50 +46,36 @@ def __init__(self, reservation): self.reservation = reservation self.start_dt = format_datetime(reservation.start_dt) - def _get_email_subject(self, **mail_params): - return '{prefix}[{room}] {subject} ({date}) {suffix}'.format( - prefix=mail_params.get('subject_prefix', ''), - room=self.reservation.room.full_name, - subject=mail_params.get('subject', ''), - date=self.start_dt, - suffix=mail_params.get('subject_suffix', '') - ).strip() - - def _make_body(self, mail_params, **body_params): + def _make_template(self, mail_params, **body_params): from indico.modules.rb.models.reservations import RepeatFrequency, RepeatMapping template_params = mail_params | body_params template_params['RepeatFrequency'] = RepeatFrequency template_params['RepeatMapping'] = RepeatMapping - return render_template('rb/emails/reservations/{}.txt'.format(mail_params['template_name']), **template_params) + return get_template_module('rb/emails/reservations/{}.txt'.format(mail_params['template_name']), + **template_params) def compose_email_to_user(self, **mail_params): creator = self.reservation.created_by_user to_list = {creator.email} if self.reservation.contact_email: to_list.add(self.reservation.contact_email) - subject = self._get_email_subject(**mail_params) - body = self._make_body(mail_params, reservation=self.reservation) - return make_email(to_list=to_list, subject=subject, body=body) + with force_locale(None): + template = self._make_template(mail_params, reservation=self.reservation) + return make_email(to_list=to_list, template=template) def compose_email_to_manager(self, **mail_params): room = self.reservation.room - subject = self._get_email_subject(**mail_params) - body = self._make_body(mail_params, reservation=self.reservation) - return make_email(to_list=get_manager_emails(room), subject=subject, body=body) + with force_locale(None): # No event, and managers are sent in one mail together + template = self._make_template(mail_params, reservation=self.reservation) + return make_email(to_list=get_manager_emails(room), template=template) @email_sender def notify_reset_approval(reservation): notification = ReservationNotification(reservation) return [_f for _f in [ - notification.compose_email_to_user( - subject='Booking approval changed state on', - template_name='change_state_email_to_user' - ), - notification.compose_email_to_manager( - subject='Booking approval changed state on', - template_name='change_state_email_to_manager' - ) + notification.compose_email_to_user(template_name='change_state_email_to_user'), + notification.compose_email_to_manager(template_name='change_state_email_to_manager') ] if _f] @@ -99,14 +85,8 @@ def notify_cancellation(reservation): raise ValueError('Reservation is not cancelled') notification = ReservationNotification(reservation) return [_f for _f in [ - notification.compose_email_to_user( - subject='Booking cancelled', - template_name='cancellation_email_to_user' - ), - notification.compose_email_to_manager( - subject='Booking cancelled', - template_name='cancellation_email_to_manager' - ), + notification.compose_email_to_user(template_name='cancellation_email_to_user'), + notification.compose_email_to_manager(template_name='cancellation_email_to_manager'), ] if _f] @@ -116,16 +96,8 @@ def notify_confirmation(reservation, reason=None): raise ValueError('Reservation is not confirmed') notification = ReservationNotification(reservation) return [_f for _f in [ - notification.compose_email_to_user( - subject='Booking confirmed', - template_name='confirmation_email_to_user', - reason=reason - ), - notification.compose_email_to_manager( - subject='Booking confirmed', - template_name='confirmation_email_to_manager', - reason=reason - ), + notification.compose_email_to_user(template_name='confirmation_email_to_user', reason=reason), + notification.compose_email_to_manager(template_name='confirmation_email_to_manager', reason=reason), ] if _f] @@ -133,14 +105,8 @@ def notify_confirmation(reservation, reason=None): def notify_creation(reservation): notification = ReservationNotification(reservation) return [_f for _f in [ - notification.compose_email_to_user( - subject='New Booking' if reservation.is_accepted else 'Pre-Booking awaiting acceptance', - template_name='creation_email_to_user' if reservation.is_accepted else 'creation_pre_email_to_user' - ), - notification.compose_email_to_manager( - subject='New booking on' if reservation.is_accepted else 'New Pre-Booking on', - template_name='creation_email_to_manager' if reservation.is_accepted else 'creation_pre_email_to_manager' - ), + notification.compose_email_to_user(template_name='creation_email_to_user'), + notification.compose_email_to_manager(template_name='creation_email_to_manager'), ] if _f] @@ -150,14 +116,8 @@ def notify_rejection(reservation): raise ValueError('Reservation is not rejected') notification = ReservationNotification(reservation) return [_f for _f in [ - notification.compose_email_to_user( - subject='Booking rejected', - template_name='rejection_email_to_user', - ), - notification.compose_email_to_manager( - subject='Booking rejected', - template_name='rejection_email_to_manager', - ) + notification.compose_email_to_user(template_name='rejection_email_to_user'), + notification.compose_email_to_manager(template_name='rejection_email_to_manager') ] if _f] @@ -165,19 +125,14 @@ def notify_rejection(reservation): def notify_modification(reservation, changes): notification = ReservationNotification(reservation) return [_f for _f in [ - notification.compose_email_to_user( - subject='Booking modified', - template_name='modification_email_to_user' - ), - notification.compose_email_to_manager( - subject='Booking modified', - template_name='modification_email_to_manager' - ), + notification.compose_email_to_user(template_name='modification_email_to_user'), + notification.compose_email_to_manager(template_name='modification_email_to_manager'), ] if _f] @email_sender def notify_about_finishing_bookings(user, reservations): - tpl = get_template_module('rb/emails/reservations/reminders/finishing_bookings.html', - reservations=reservations, user=user) - return make_email(to_list={user.email}, template=tpl, html=True) + with user.force_user_locale(): + tpl = get_template_module('rb/emails/reservations/reminders/finishing_bookings.html', + reservations=reservations, user=user) + return make_email(to_list={user.email}, template=tpl, html=True) diff --git a/indico/modules/rb/templates/emails/base_email.html b/indico/modules/rb/templates/emails/base_email.html index 37cda10c8ec..1b1fff4d361 100644 --- a/indico/modules/rb/templates/emails/base_email.html +++ b/indico/modules/rb/templates/emails/base_email.html @@ -1,5 +1,5 @@ -{% extends 'emails/base.html' %} +{% extends 'emails/base_i18n.html' %} {% block footer_title -%} - Room Booking + {% trans %}Room Booking{% endtrans %} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/base_email.txt b/indico/modules/rb/templates/emails/base_email.txt index b3d18171d1f..16a0588fc68 100644 --- a/indico/modules/rb/templates/emails/base_email.txt +++ b/indico/modules/rb/templates/emails/base_email.txt @@ -1,4 +1,9 @@ -Dear {% block recipient %}{% endblock %}, +{% extends 'emails/base_i18n.txt' %} -{% block email_body %}{% endblock %} -{% include 'rb/emails/email_footer.txt' %} +{% block body %}{% endblock %} + +{% block footer_title -%} + {% trans %}Room Booking{% endtrans %} +{%- endblock %} + +{% block footer_url %}{{ url_for('rb.roombooking', _external=true) }}{% endblock %} diff --git a/indico/modules/rb/templates/emails/blockings/awaiting_confirmation_email_to_manager.txt b/indico/modules/rb/templates/emails/blockings/awaiting_confirmation_email_to_manager.txt index d8909b3485e..24875cbbc74 100644 --- a/indico/modules/rb/templates/emails/blockings/awaiting_confirmation_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/blockings/awaiting_confirmation_email_to_manager.txt @@ -1,20 +1,33 @@ {% extends 'rb/emails/base_email.txt' %} -{% block recipient %}{{ owner.first_name }}{% endblock %} -{% block email_body -%} -{{ blocking.created_by_user.full_name }} has created a blocking for {{ "some rooms" if blocked_rooms | length > 1 else "a room" }} you manage. +{% block subject -%}{% trans %}Confirm room blockings{% endtrans %}{%- endblock %} + +{% block header_recipient -%} + {% trans name=owner.first_name -%}Dear {{ name }},{%- endtrans %} +{%- endblock %} + +{% block body -%} +{% if blocked_rooms | length > 1 -%} + {% trans name=blocking.created_by_user.full_name -%} + {{ name }} has created a blocking for some rooms you manage. + {%- endtrans %} +{%- else -%} + {% trans name=blocking.created_by_user.full_name -%} + {{ name }} has created a blocking for a room you manage. + {%- endtrans %} +{%- endif %} {% if blocked_rooms | length == 1 -%} -Room: {{ blocked_rooms[0].room.full_name }} + {%- trans %}Room:{% endtrans %} {{ blocked_rooms[0].room.full_name }} {%- else -%} -Rooms: + {%- trans -%}Rooms:{%- endtrans %} {% for blocked_room in blocked_rooms -%} {{ blocked_room.room.full_name }} {% endfor %} {%- endif %} -Reason: {{ blocking.reason }} -Dates: {{ blocking.start_date | format_date(locale='en_GB') }} - {{ blocking.end_date | format_date(locale='en_GB') }} +{% trans %}Reason:{% endtrans %} {{ blocking.reason }} +{% trans %}Dates:{% endtrans %} {{ blocking.start_date | format_date(locale='en_GB') }} - {{ blocking.end_date | format_date(locale='en_GB') }} -You can approve or reject this blocking request here: +{% trans %}You can approve or reject this blocking request here:{% endtrans %} {{ blocking.external_details_url }} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/blockings/state_email_to_user.txt b/indico/modules/rb/templates/emails/blockings/state_email_to_user.txt index 69071f57ef5..ac970f8d635 100644 --- a/indico/modules/rb/templates/emails/blockings/state_email_to_user.txt +++ b/indico/modules/rb/templates/emails/blockings/state_email_to_user.txt @@ -1,15 +1,33 @@ {% extends 'rb/emails/base_email.txt' %} -{% block recipient %}{{ blocking.created_by_user.first_name }}{% endblock %} +{% block subject -%} + {% if blocked_room.state.name == 'accepted' -%} + {% trans %}Room blocking ACCEPTED{% endtrans %} + {%- else -%} + {% trans %}Room blocking REJECTED{% endtrans %} + {%- endif %} +{%- endblock %} -{% block email_body -%} -Your room blocking request has been {{ verb }} by a room manager. +{% block header_recipient -%} + {% trans name=blocking.created_by_user.first_name -%}Dear {{ name }},{%- endtrans %} +{%- endblock %} -Room: {{ blocked_room.room.full_name }} -Action: {{ verb }} -{%- if blocked_room.state == blocked_room.State.rejected %} -Reason: {{ blocked_room.rejection_reason or '(none)' }} +{% block body -%} +{% if blocked_room.state.name == 'accepted' -%} + {% trans %}Your room blocking request has been ACCEPTED by a room manager.{% endtrans %} +{%- else -%} + {% trans %}Your room blocking request has been REJECTED by a room manager.{% endtrans %} {%- endif %} -You can view the details of your blocking here: +{% trans %}Room:{% endtrans %} {{ blocked_room.room.full_name }} +{% filter dedent -%} + {%- if blocked_room.state.name == 'accepted' -%} + {%- trans %}Action: ACCEPTED{% endtrans -%} + {%- else -%} + {% trans %}Action: REJECTED{% endtrans %} + {% trans %}Reason:{% endtrans %} {{ blocked_room.rejection_reason or '(none)' }} + {%- endif -%} +{%- endfilter %} + +{% trans %}You can view the details of your blocking here:{% endtrans %} {{ blocking.external_details_url }} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/blockings/tests/awaiting_confirmation_email_to_manager.txt b/indico/modules/rb/templates/emails/blockings/tests/awaiting_confirmation_email_to_manager.txt index ca729528e22..057434d014a 100644 --- a/indico/modules/rb/templates/emails/blockings/tests/awaiting_confirmation_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/blockings/tests/awaiting_confirmation_email_to_manager.txt @@ -9,8 +9,6 @@ Dates: 11 Nov 2022 - 11 Nov 2022 You can approve or reject this blocking request here: http://localhost/rooms/blocking/1 - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/blockings/tests/awaiting_confirmation_email_to_manager_rooms.txt b/indico/modules/rb/templates/emails/blockings/tests/awaiting_confirmation_email_to_manager_rooms.txt index ff246af2d55..193589f2850 100644 --- a/indico/modules/rb/templates/emails/blockings/tests/awaiting_confirmation_email_to_manager_rooms.txt +++ b/indico/modules/rb/templates/emails/blockings/tests/awaiting_confirmation_email_to_manager_rooms.txt @@ -12,8 +12,6 @@ Dates: 11 Nov 2022 - 11 Nov 2022 You can approve or reject this blocking request here: http://localhost/rooms/blocking/1 - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/blockings/tests/state_email_to_user_accepted.txt b/indico/modules/rb/templates/emails/blockings/tests/state_email_to_user_accepted.txt index 309c538154c..55146f2ad89 100644 --- a/indico/modules/rb/templates/emails/blockings/tests/state_email_to_user_accepted.txt +++ b/indico/modules/rb/templates/emails/blockings/tests/state_email_to_user_accepted.txt @@ -1,15 +1,13 @@ Dear Guinea, -Your room blocking request has been forgotten by a room manager. +Your room blocking request has been ACCEPTED by a room manager. Room: 1/2-3 -Action: forgotten +Action: ACCEPTED You can view the details of your blocking here: http://localhost/rooms/blocking/2 - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/blockings/tests/state_email_to_user_rejected.txt b/indico/modules/rb/templates/emails/blockings/tests/state_email_to_user_rejected.txt index 1bc9480af7e..697a9f5e551 100644 --- a/indico/modules/rb/templates/emails/blockings/tests/state_email_to_user_rejected.txt +++ b/indico/modules/rb/templates/emails/blockings/tests/state_email_to_user_rejected.txt @@ -1,16 +1,14 @@ Dear Guinea, -Your room blocking request has been forgotten by a room manager. +Your room blocking request has been REJECTED by a room manager. Room: 1/2-3 -Action: forgotten +Action: REJECTED Reason: (none) You can view the details of your blocking here: http://localhost/rooms/blocking/2 - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/email_footer.txt b/indico/modules/rb/templates/emails/email_footer.txt index 5ec3a2e9745..9365b6629af 100644 --- a/indico/modules/rb/templates/emails/email_footer.txt +++ b/indico/modules/rb/templates/emails/email_footer.txt @@ -1,6 +1,6 @@ -- -Best regards, -Indico :: Room Booking +{% trans %}Best regards,{% endtrans %} +Indico :: {% trans %}Room Booking{% endtrans %} {{ url_for('rb.roombooking', _external=true) }} diff --git a/indico/modules/rb/templates/emails/reservations/base_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/base_email_to_manager.txt index 50c2ac20e50..2c94f64e71c 100644 --- a/indico/modules/rb/templates/emails/reservations/base_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/base_email_to_manager.txt @@ -1,9 +1,13 @@ {% extends 'rb/emails/base_email.txt' %} -{% block recipient %}{{ reservation.room.owner.first_name }}{% endblock %} +{% block header_recipient -%} + {% trans name=reservation.room.owner.first_name -%}Dear {{ name }},{%- endtrans %} +{%- endblock %} -{% block email_body -%} -{% block body %}{% endblock %} +{% block body -%} + {%- filter dedent -%} + {% block email_body %}{% endblock %} -You can check the details of the booking here: -{{ reservation.external_details_url }} + {% trans %}You can check the details of the booking here:{% endtrans %} + {{ reservation.external_details_url }} + {%- endfilter -%} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/base_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/base_email_to_user.txt index 8f970819e7d..8f62c83c08f 100644 --- a/indico/modules/rb/templates/emails/reservations/base_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/base_email_to_user.txt @@ -1,12 +1,16 @@ {% extends 'rb/emails/base_email.txt' %} -{% block recipient %}{{ reservation.created_by_user.first_name }}{% endblock %} +{% block header_recipient -%} + {% trans name=reservation.created_by_user.first_name -%}Dear {{ name }},{%- endtrans %} +{%- endblock %} -{% block email_body -%} -{% block body %}{% endblock %} +{% block body -%} + {%- filter dedent -%} + {% block email_body %}{% endblock %} -Booking details: -{{ reservation.external_details_url }} + {% trans %}Booking details:{% endtrans %} + {{ reservation.external_details_url }} -Remember you can always check your bookings here: -{{ url_for('rb.my_bookings_link', _external=true) }} + {% trans %}Remember you can always check your bookings here:{% endtrans %} + {{ url_for('rb.my_bookings_link', _external=true) }} + {%- endfilter -%} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/cancellation_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/cancellation_email_to_manager.txt index 88a5c29ea9a..f095787e0b2 100644 --- a/indico/modules/rb/templates/emails/reservations/cancellation_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/cancellation_email_to_manager.txt @@ -1,5 +1,9 @@ {% extends 'rb/emails/reservations/base_email_to_manager.txt' %} +{% block subject_prefix %}{% endblock %} +{% block subject -%}{% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking cancelled ({{ start }}) +{%- endtrans %}{%- endblock %} -{% block body -%} -A booking in your room '{{ reservation.room.full_name }}' has been CANCELLED by the user. +{% block email_body -%} + {% trans room=reservation.room.full_name %}A booking in your room '{{ room }}' has been CANCELLED by the user.{% endtrans %} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/cancellation_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/cancellation_email_to_user.txt index 93f4d13d761..7e231230cda 100644 --- a/indico/modules/rb/templates/emails/reservations/cancellation_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/cancellation_email_to_user.txt @@ -1,7 +1,11 @@ {% extends 'rb/emails/reservations/base_email_to_user.txt' %} +{% block subject_prefix %}{% endblock %} +{% block subject -%}{% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking cancelled ({{ start }}) +{%- endtrans %}{%- endblock %} -{% block body -%} -You have CANCELLED your booking: +{% block email_body -%} + {% trans %}You have CANCELLED your booking:{% endtrans %} -{% include 'rb/emails/reservations/reservation_info.txt' %} + {% include 'rb/emails/reservations/reservation_info.txt' %} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/change_state_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/change_state_email_to_manager.txt index 3a8f1ba0ca6..56754f9eb7c 100644 --- a/indico/modules/rb/templates/emails/reservations/change_state_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/change_state_email_to_manager.txt @@ -1,5 +1,9 @@ {% extends 'rb/emails/reservations/base_email_to_manager.txt' %} +{% block subject_prefix %}{% endblock %} +{% block subject -%}{% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking approval changed state on ({{ start }}) +{%- endtrans %}{%- endblock %} -{% block body -%} -A booking in a room you manage has been MODIFIED and the changes require approval. +{% block email_body -%} + {% trans %}A booking in a room you manage has been MODIFIED and the changes require approval.{% endtrans %} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/change_state_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/change_state_email_to_user.txt index 200caeab8c1..5d874099a0f 100644 --- a/indico/modules/rb/templates/emails/reservations/change_state_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/change_state_email_to_user.txt @@ -1,7 +1,13 @@ {% extends 'rb/emails/reservations/base_email_to_user.txt' %} +{% block subject_prefix %}{% endblock %} +{% block subject -%}{% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking approval changed state on ({{ start }}) +{%- endtrans %}{%- endblock %} -{% block body -%} -Your booking has been MODIFIED and the changes require approval. +{% block email_body -%} + {%- filter dedent -%} + {% trans %}Your booking has been MODIFIED and the changes require approval.{% endtrans %} -{% include 'rb/emails/reservations/reservation_info.txt' %} + {% include 'rb/emails/reservations/reservation_info.txt' %} + {%- endfilter -%} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/confirmation_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/confirmation_email_to_manager.txt index 658753ff9bc..f04c15a28c2 100644 --- a/indico/modules/rb/templates/emails/reservations/confirmation_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/confirmation_email_to_manager.txt @@ -1,11 +1,17 @@ {% extends 'rb/emails/reservations/base_email_to_manager.txt' %} +{% block subject_prefix %}{% endblock %} +{% block subject -%}{% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking confirmed ({{ start }}) +{%- endtrans %}{%- endblock %} -{% block body -%} -A booking in your room '{{ reservation.room.full_name }}' has been CONFIRMED by a room manager. +{% block email_body -%} + {%- filter dedent -%} + {% trans room=reservation.room.full_name %}A booking in your room '{{ room }}' has been CONFIRMED by a room manager.{% endtrans %} -{%- if reason %} + {%- if reason %} -The following message was provided by the room manager: -{{ reason }} -{%- endif -%} + {% trans %}The following message was provided by the room manager:{% endtrans %} + {{ reason }} + {%- endif -%} + {%- endfilter -%} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/confirmation_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/confirmation_email_to_user.txt index f2e58adc0a1..53fd1946eae 100644 --- a/indico/modules/rb/templates/emails/reservations/confirmation_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/confirmation_email_to_user.txt @@ -1,17 +1,23 @@ {% extends 'rb/emails/reservations/base_email_to_user.txt' %} +{% block subject_prefix %}{% endblock %} +{% block subject -%}{% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking confirmed ({{ start }}) +{%- endtrans %}{%- endblock %} -{% block body -%} -{% block state -%} -Your booking has been ACCEPTED. -This is the final confirmation. +{% block email_body -%} + {%- filter dedent -%} + {% block state -%} + {% trans %}Your booking has been ACCEPTED.{% endtrans %} + {% trans %}This is the final confirmation.{% endtrans %} -{%- if reason %} + {%- if reason %} -The following message was provided by the room manager: -{{ reason }} -{%- endif -%} -{%- endblock %} + {% trans %}The following message was provided by the room manager:{% endtrans %} + {{ reason }} + {%- endif -%} + {%- endblock %} -{% include 'rb/emails/reservations/reservation_info.txt' %} -{%- include 'rb/emails/reservations/reservation_key_info.txt' %} + {% include 'rb/emails/reservations/reservation_info.txt' %} + {%- include 'rb/emails/reservations/reservation_key_info.txt' %} + {%- endfilter -%} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/creation_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/creation_email_to_manager.txt index 8d5d1da4e35..cb7ceef4965 100644 --- a/indico/modules/rb/templates/emails/reservations/creation_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/creation_email_to_manager.txt @@ -1,7 +1,26 @@ {% extends 'rb/emails/reservations/base_email_to_manager.txt' %} +{%- set prebooking = not reservation.is_accepted -%} +{% block subject_prefix %}{% endblock %} +{% block subject -%} + {% if prebooking -%} + {% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] New Pre-Booking on ({{ start }}) + {%- endtrans %} + {%- else -%} + {% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] New booking on ({{ start }}) + {%- endtrans %} + {%- endif %} +{%- endblock %} -{% block body -%} -There is a new {% block prebooking_prefix %}{% endblock %}booking for your room. +{% block email_body -%} + {%- filter dedent -%} + {% if prebooking -%} + {% trans %}There is a new pre-booking for your room.{% endtrans %} + {%- else -%} + {% trans %}There is a new booking for your room.{% endtrans %} + {%- endif %} -{% include 'rb/emails/reservations/reservation_info.txt' %} + {% include 'rb/emails/reservations/reservation_info.txt' %} + {%- endfilter -%} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/creation_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/creation_email_to_user.txt index ecc43baf804..cb6461a5f0c 100644 --- a/indico/modules/rb/templates/emails/reservations/creation_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/creation_email_to_user.txt @@ -1,31 +1,78 @@ {% extends 'rb/emails/reservations/base_email_to_user.txt' %} {% set excluded_days = reservation.find_excluded_days().count() %} +{%- set prebooking = not reservation.is_accepted -%} +{% block subject_prefix %}{% endblock %} +{% block subject -%} + {% if prebooking -%} + {% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Pre-Booking awaiting acceptance ({{ start }}) + {%- endtrans %} + {%- else -%} + {% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking confirmed ({{ start }}) + {%- endtrans %} + {%- endif %} +{%- endblock %} -{% block body -%} -{%- block booking_details -%} -The conference room {{ reservation.room.full_name }} -has been {% block prebooked_prefix %}{% endblock %}booked for {{ reservation.booked_for_name }} -{% if reservation.repeat_frequency == RepeatFrequency.NEVER -%} - on {{ reservation.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') }} from {{ reservation.start_dt | format_time(locale='en_GB') }} to {{ reservation.end_dt | format_time(locale='en_GB') }}. -{%- else -%} - {{ RepeatMapping.get_message(reservation.repeat_frequency, reservation.repeat_interval) }} from {{ reservation.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') }} to {{ reservation.end_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') }} between {{ reservation.start_dt | format_time(locale='en_GB') }} and {{ reservation.end_dt | format_time(locale='en_GB') }}. -{%- endif %} -Reason: {{ reservation.booking_reason }} -{%- endblock -%} -{%- block confirmed_booking -%} -{%- if excluded_days %} - (Note that there are {{ excluded_days }} excluded days. For further info, check your reservation) -{%- endif %} +{% block email_body -%} + {%- filter dedent -%} + {%- block booking_details -%} + {% if prebooking -%} + {% if reservation.repeat_frequency == RepeatFrequency.NEVER -%} + {% trans notrimmed room=reservation.room.full_name, name=reservation.booked_for_name, date=reservation.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB'), from=reservation.start_dt | format_time(locale='en_GB'), to=reservation.end_dt | format_time(locale='en_GB') -%} + The conference room {{ room }} + has been pre-booked for {{ name }} + on {{ date }} from {{ from }} to {{ to }}. + {%- endtrans %} + {%- else -%} + {% trans notrimmed room=reservation.room.full_name, name=reservation.booked_for_name, map=RepeatMapping.get_message(reservation.repeat_frequency, reservation.repeat_interval), from=reservation.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB'), to=reservation.end_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB'), start=reservation.start_dt | format_time(locale='en_GB'), end=reservation.end_dt | format_time(locale='en_GB') -%} + The conference room {{ room }} + has been pre-booked for {{ name }} + {{ map }} from {{ from }} to {{ to }} between {{ start }} and {{ end }}. + {%- endtrans %} + {%- endif %} + {%- else -%} + {% if reservation.repeat_frequency == RepeatFrequency.NEVER -%} + {% trans notrimmed room=reservation.room.full_name, name=reservation.booked_for_name, date=reservation.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB'), from=reservation.start_dt | format_time(locale='en_GB'), to=reservation.end_dt | format_time(locale='en_GB') -%} + The conference room {{ room }} + has been booked for {{ name }} + on {{ date }} from {{ from }} to {{ to }}. + {%- endtrans %} + {%- else -%} + {% trans notrimmed room=reservation.room.full_name, name=reservation.booked_for_name, map=RepeatMapping.get_message(reservation.repeat_frequency, reservation.repeat_interval), from=reservation.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB'), to=reservation.end_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB'), start=reservation.start_dt | format_time(locale='en_GB'), end=reservation.end_dt | format_time(locale='en_GB') -%} + The conference room {{ room }} + has been booked for {{ name }} + {{ map }} from {{ from }} to {{ to }} between {{ start }} and {{ end }}. + {%- endtrans %} + {%- endif %} + {%- endif %} + {% trans %}Reason:{% endtrans %} {{ reservation.booking_reason }} + {%- endblock -%} + {%- if not prebooking -%} + {%- if excluded_days %} + {% trans excluded=excluded_days %}(Note that there are {{ excluded }} excluded days. For further info, check your reservation.){% endtrans %} + {%- endif %} -If you end up not needing this room, please cancel the booking from the -booking details so that the room can be booked by somebody else. + {% trans notrimmed -%} + If you end up not needing this room, please cancel the booking from the + booking details so that the room can be booked by somebody else. -Please be aware that in special (rare) cases the person responsible -for this room may reject your booking. Should that happen you will -be instantly notified by e-mail. -{%- endblock %} + Please be aware that in special (rare) cases the person responsible + for this room may reject your booking. Should that happen you will + be instantly notified by e-mail. + {%- endtrans -%} + {%- endif -%} -{%- include 'rb/emails/reservations/reservation_key_info.txt' %} + {%- include 'rb/emails/reservations/reservation_key_info.txt' %} -{%- block prebooking_warning %}{% endblock %} -{%- endblock %} + {%- if prebooking %} + {% trans notrimmed %} + Note: + Your pre-booking is NOT YET ACCEPTED by a room manager. + Please be aware that pre-bookings are subject to acceptance + or rejection. Expect an e-mail with acceptance/rejection + information. + {%- endtrans -%} + {%- endif -%} + {%- endfilter -%} +{%- endblock %} \ No newline at end of file diff --git a/indico/modules/rb/templates/emails/reservations/creation_pre_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/creation_pre_email_to_manager.txt deleted file mode 100644 index 33d597dce88..00000000000 --- a/indico/modules/rb/templates/emails/reservations/creation_pre_email_to_manager.txt +++ /dev/null @@ -1,3 +0,0 @@ -{% extends 'rb/emails/reservations/creation_email_to_manager.txt' %} - -{% block prebooking_prefix %}pre-{% endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/creation_pre_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/creation_pre_email_to_user.txt deleted file mode 100644 index 44849653308..00000000000 --- a/indico/modules/rb/templates/emails/reservations/creation_pre_email_to_user.txt +++ /dev/null @@ -1,13 +0,0 @@ -{% extends 'rb/emails/reservations/creation_email_to_user.txt' %} - -{% block prebooking_warning %} - -Note: -Your pre-booking is NOT YET ACCEPTED by a room manager. -Please be aware that pre-bookings are subject to acceptance -or rejection. Expect an e-mail with acceptance/rejection -information. -{%- endblock %} - -{% block prebooked_prefix %}pre-{% endblock %} -{% block confirmed_booking %}{% endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/modification_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/modification_email_to_manager.txt index 7f000841e37..88695435549 100644 --- a/indico/modules/rb/templates/emails/reservations/modification_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/modification_email_to_manager.txt @@ -1,5 +1,9 @@ {% extends 'rb/emails/reservations/base_email_to_manager.txt' %} +{% block subject_prefix %}{% endblock %} +{% block subject -%}{% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking modified ({{ start }}) +{%- endtrans %}{%- endblock %} -{% block body -%} -A booking in a room you manage has been MODIFIED. +{% block email_body -%} + {% trans %}A booking in a room you manage has been MODIFIED.{% endtrans %} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/modification_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/modification_email_to_user.txt index 70124bce2e0..48dd9657f60 100644 --- a/indico/modules/rb/templates/emails/reservations/modification_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/modification_email_to_user.txt @@ -1,7 +1,13 @@ {% extends 'rb/emails/reservations/base_email_to_user.txt' %} +{% block subject_prefix %}{% endblock %} +{% block subject -%}{% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking modified ({{ start }}) +{%- endtrans %}{%- endblock %} -{% block body -%} -Your booking has been MODIFIED. +{% block email_body -%} + {%- filter dedent -%} + {% trans %}Your booking has been MODIFIED.{% endtrans %} -{% include 'rb/emails/reservations/reservation_info.txt' %} + {% include 'rb/emails/reservations/reservation_info.txt' %} + {%- endfilter -%} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/occurrence_cancellation_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/occurrence_cancellation_email_to_manager.txt index d116f1567e4..bf8230cb4d9 100644 --- a/indico/modules/rb/templates/emails/reservations/occurrence_cancellation_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/occurrence_cancellation_email_to_manager.txt @@ -1,5 +1,11 @@ {% extends 'rb/emails/reservations/base_email_to_manager.txt' %} +{% block subject_prefix %}{% endblock %} +{% block subject -%}{% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking cancelled on ({{ start }}) (SINGLE OCCURRENCE) +{%- endtrans %}{%- endblock %} -{% block body -%} -The date {{ reservation.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') }} from a booking that concerns one of your rooms has been CANCELLED by the user. +{% block email_body -%} + {% trans date=reservation.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') -%} + The date {{ date }} from a booking that concerns one of your rooms has been CANCELLED by the user. + {%- endtrans %} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/occurrence_cancellation_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/occurrence_cancellation_email_to_user.txt index 8032b1e4eb6..356e0b56de3 100644 --- a/indico/modules/rb/templates/emails/reservations/occurrence_cancellation_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/occurrence_cancellation_email_to_user.txt @@ -1,7 +1,15 @@ {% extends 'rb/emails/reservations/base_email_to_user.txt' %} +{% block subject_prefix %}{% endblock %} +{% block subject -%}{% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking cancelled ({{ start }}) (SINGLE OCCURRENCE) +{%- endtrans %}{%- endblock %} -{% block body -%} -You have CANCELLED an occurrence of your booking on {{ occurrence.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') }}. +{% block email_body -%} + {%- filter dedent -%} + {% trans date=occurrence.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') -%} + You have CANCELLED an occurrence of your booking on {{ date }}. + {%- endtrans %} -{% include 'rb/emails/reservations/reservation_info.txt' %} + {% include 'rb/emails/reservations/reservation_info.txt' %} + {%- endfilter -%} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/occurrence_rejection_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/occurrence_rejection_email_to_manager.txt index 60f3d510687..a0cee05fa3d 100644 --- a/indico/modules/rb/templates/emails/reservations/occurrence_rejection_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/occurrence_rejection_email_to_manager.txt @@ -1,10 +1,18 @@ {% extends 'rb/emails/reservations/base_email_to_manager.txt' %} +{% block subject_prefix %}{% endblock %} +{% block subject -%}{% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking rejected on ({{ start }}) (SINGLE OCCURRENCE) +{%- endtrans %}{%- endblock %} -{% block body -%} -A booking has been REJECTED by the manager of the room '{{ reservation.room.full_name }}' for the {{ occurrence.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') }}. +{% block email_body -%} + {%- filter dedent -%} + {% trans name=reservation.room.full_name, date=occurrence.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') -%} + A booking has been REJECTED by the manager of the room '{{ name }}' for the {{ date }}. + {%- endtrans %} -Rejection reason: -{{ occurrence.rejection_reason }} + {% trans %}Rejection reason:{% endtrans %} + {{ occurrence.rejection_reason }} -{% include 'rb/emails/reservations/reservation_info.txt' %} + {% include 'rb/emails/reservations/reservation_info.txt' %} + {%- endfilter -%} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/occurrence_rejection_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/occurrence_rejection_email_to_user.txt index 5b8bf60be63..9f76eb53a39 100644 --- a/indico/modules/rb/templates/emails/reservations/occurrence_rejection_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/occurrence_rejection_email_to_user.txt @@ -1,10 +1,18 @@ {% extends 'rb/emails/reservations/base_email_to_user.txt' %} +{% block subject_prefix %}{% endblock %} +{% block subject -%}{% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking rejected on ({{ start }}) (SINGLE OCCURRENCE) +{%- endtrans %}{%- endblock %} -{% block body -%} -Your booking has been REJECTED by the manager of the room for the {{ occurrence.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') }}. +{% block email_body -%} + {%- filter dedent -%} + {% trans date=occurrence.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') -%} + Your booking has been REJECTED by the manager of the room for the {{ date }}. + {%- endtrans %} -Rejection reason: -{{ occurrence.rejection_reason }} + {% trans %}Rejection reason:{% endtrans %} + {{ occurrence.rejection_reason }} -{% include 'rb/emails/reservations/reservation_info.txt' %} + {% include 'rb/emails/reservations/reservation_info.txt' %} + {%- endfilter -%} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/rejection_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/rejection_email_to_manager.txt index 3f3d587c4e4..de8723c0e36 100644 --- a/indico/modules/rb/templates/emails/reservations/rejection_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/rejection_email_to_manager.txt @@ -1,10 +1,16 @@ {% extends 'rb/emails/reservations/base_email_to_manager.txt' %} +{% block subject_prefix %}{% endblock %} +{% block subject -%}{% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking rejected ({{ start }}) +{%- endtrans %}{%- endblock %} -{% block body -%} -A booking has been REJECTED by the manager of the room '{{ reservation.room.full_name }}'. +{% block email_body -%} + {%- filter dedent -%} + {% trans name=reservation.room.full_name %}A booking has been REJECTED by the manager of the room '{{ name }}'.{% endtrans %} -Rejection reason: -{{ reservation.rejection_reason }} + {% trans %}Rejection reason:{% endtrans %} + {{ reservation.rejection_reason }} -{% include 'rb/emails/reservations/reservation_info.txt' %} + {% include 'rb/emails/reservations/reservation_info.txt' %} + {%- endfilter -%} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/rejection_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/rejection_email_to_user.txt index e6ca5d9075a..34c31d08c7e 100644 --- a/indico/modules/rb/templates/emails/reservations/rejection_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/rejection_email_to_user.txt @@ -1,10 +1,16 @@ {% extends 'rb/emails/reservations/base_email_to_user.txt' %} +{% block subject_prefix %}{% endblock %} +{% block subject -%}{% trans room=reservation.room.full_name, start=reservation.start_dt|format_datetime('dd/MM/yyyy HH:mm', locale='en_GB') -%} + [{{ room }}] Booking rejected ({{ start }}) +{%- endtrans %}{%- endblock %} -{% block body -%} -Your booking has been REJECTED by the manager of the room. +{% block email_body -%} + {%- filter dedent -%} + {% trans %}Your booking has been REJECTED by the manager of the room.{% endtrans %} -Rejection reason: -{{ reservation.rejection_reason }} + {% trans %}Rejection reason:{% endtrans %} + {{ reservation.rejection_reason }} -{% include 'rb/emails/reservations/reservation_info.txt' %} + {% include 'rb/emails/reservations/reservation_info.txt' %} + {%- endfilter -%} {%- endblock %} diff --git a/indico/modules/rb/templates/emails/reservations/reminders/finishing_bookings.html b/indico/modules/rb/templates/emails/reservations/reminders/finishing_bookings.html index 053c3cb068d..a31b14559a9 100644 --- a/indico/modules/rb/templates/emails/reservations/reminders/finishing_bookings.html +++ b/indico/modules/rb/templates/emails/reservations/reminders/finishing_bookings.html @@ -1,11 +1,11 @@ {% extends 'rb/emails/base_email.html' %} -{% block header_recipient %}{{ user.first_name }}{% endblock %} +{% block header_recipient %}{% trans name=user.first_name %}Dear {{ name }},{% endtrans %}{% endblock %} {% block subject -%} {% if reservations|length == 1 -%} - One of your bookings will come to an end soon + {% trans %}One of your bookings will come to an end soon{% endtrans %} {%- else -%} - Some of your bookings will come to an end soon + {% trans %}Some of your bookings will come to an end soon{% endtrans %} {%- endif %} {%- endblock %} @@ -13,9 +13,9 @@ {% block body -%} {% block message %} {%- if reservations|length == 1 -%} - There is a booking under your name that will soon come to an end:
    + {% trans %}There is a booking under your name that will soon come to an end:{% endtrans %}
    {%- else -%} - There are bookings under your name that will soon come to an end:
    + {% trans %}There are bookings under your name that will soon come to an end:{% endtrans %}
    {%- endif %} {% endblock %}
      @@ -34,7 +34,7 @@ {% macro _render_finishing_reservation(reservation) -%} - Dates: {{ _render_dates(reservation) }}
      - Room: {{ reservation.room.full_name }}
      - Reason of the booking: {{ reservation.booking_reason }}
      + {% trans %}Dates:{% endtrans %} {{ _render_dates(reservation) }}
      + {% trans %}Room:{% endtrans %} {{ reservation.room.full_name }}
      + {% trans %}Reason of the booking:{% endtrans %} {{ reservation.booking_reason }}
      {%- endmacro %} diff --git a/indico/modules/rb/templates/emails/reservations/reminders/upcoming_occurrence.html b/indico/modules/rb/templates/emails/reservations/reminders/upcoming_occurrence.html index d24bfb5b901..32ac95858f8 100644 --- a/indico/modules/rb/templates/emails/reservations/reminders/upcoming_occurrence.html +++ b/indico/modules/rb/templates/emails/reservations/reminders/upcoming_occurrence.html @@ -1,15 +1,15 @@ {% extends 'rb/emails/base_email.html' %} -{% block header_recipient %}{{ user.first_name }}{% endblock %} -{% block subject %}Reservation reminder{% endblock %} +{% block header_recipient %}{% trans name=user.first_name %}Dear {{ name }},{% endtrans %}{% endblock %} +{% block subject %}{% trans %}Reservation reminder{% endtrans %}{% endblock %} {% block body -%} {%- if occurrences | length == 1 -%} - This is a reminder about a booking under your name:
      + {% trans %}This is a reminder about a booking under your name:{% endtrans %}
      {%- else -%} - This is a reminder about bookings under your name:
      + {% trans %}This is a reminder about bookings under your name:{% endtrans %}
      {%- endif %}
        {% for occurrence in occurrences %} @@ -30,14 +30,18 @@ {% set reservation = occurrence.reservation -%} {{ occurrence.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') }} ({{ _render_time(occurrence) }})
        - Room: {{ reservation.room.full_name }}
        - Reason: {{ reservation.booking_reason }}
        + {% trans %}Room:{% endtrans %} {{ reservation.room.full_name }}
        + {% trans %}Reason:{% endtrans %} {{ reservation.booking_reason }}

        {%- if reservation.repeat_frequency.name == 'NEVER' -%} - If you do not need to use the room, please - cancel the reservation in Indico. + {% trans a=' '|safe enda=''|safe %} + If you do not need to use the room, please + {{ a }}cancel the reservation in Indico{{ enda }}. + {%- endtrans -%} {%- else -%} - If you do not need to use the room, please - cancel the occurrence in Indico. + {% trans a=' '|safe enda=''|safe %} + If you do not need to use the room, please + {{ a }}cancel the occurrence in Indico{{ enda }}. + {%- endtrans -%} {%- endif -%} {%- endmacro %} diff --git a/indico/modules/rb/templates/emails/reservations/reservation_info.txt b/indico/modules/rb/templates/emails/reservations/reservation_info.txt index dad3a0bb2e7..a348d972579 100644 --- a/indico/modules/rb/templates/emails/reservations/reservation_info.txt +++ b/indico/modules/rb/templates/emails/reservations/reservation_info.txt @@ -1,5 +1,5 @@ -Room: {{ reservation.room.full_name }} -For: {{ reservation.booked_for_name }} -Reason: {{ reservation.booking_reason }} -Dates: {{ reservation.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') }} - {{ reservation.end_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') }} -Hours: {{ reservation.start_dt | format_time(locale='en_GB') }} - {{ reservation.end_dt | format_time(locale='en_GB') }} +{% trans %}Room:{% endtrans %} {{ reservation.room.full_name }} +{% trans %}For:{% endtrans %} {{ reservation.booked_for_name }} +{% trans %}Reason:{% endtrans %} {{ reservation.booking_reason }} +{% trans %}Dates:{% endtrans %} {{ reservation.start_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') }} - {{ reservation.end_dt | format_date('EEEE dd/MM/yyyy', locale='en_GB') }} +{% trans %}Hours:{% endtrans %} {{ reservation.start_dt | format_time(locale='en_GB') }} - {{ reservation.end_dt | format_time(locale='en_GB') }} diff --git a/indico/modules/rb/templates/emails/reservations/reservation_key_info.txt b/indico/modules/rb/templates/emails/reservations/reservation_key_info.txt index 3888ba39f04..4ded6a39b78 100644 --- a/indico/modules/rb/templates/emails/reservations/reservation_key_info.txt +++ b/indico/modules/rb/templates/emails/reservations/reservation_key_info.txt @@ -1,5 +1,5 @@ {% if reservation.room.key_location %} -How to find a key: +{% trans %}How to find a key:{% endtrans %} {{ reservation.room.key_location | striptags }} {%- endif %} diff --git a/indico/modules/rb/templates/emails/reservations/tests/cancellation_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/tests/cancellation_email_to_manager.txt index 0664032787d..812e1a58062 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/cancellation_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/cancellation_email_to_manager.txt @@ -5,8 +5,6 @@ A booking in your room '1/2-3' has been CANCELLED by the user. You can check the details of the booking here: http://localhost/rooms/booking/0 - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/cancellation_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/tests/cancellation_email_to_user.txt index 37d73ec31e9..debe7177ebb 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/cancellation_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/cancellation_email_to_user.txt @@ -2,11 +2,11 @@ Dear Guinea, You have CANCELLED your booking: -Room: 1/2-3 -For: Guinea Pig +Room: 1/2-3 +For: Guinea Pig Reason: Testing -Dates: Friday 11/11/2022 - Friday 11/11/2022 -Hours: 13:37 - 14:37 +Dates: Friday 11/11/2022 - Friday 11/11/2022 +Hours: 13:37 - 14:37 Booking details: http://localhost/rooms/booking/0 @@ -14,8 +14,6 @@ http://localhost/rooms/booking/0 Remember you can always check your bookings here: http://localhost/rooms/my-bookings - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/change_state_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/tests/change_state_email_to_manager.txt index e8b3c8aabf8..e7064c47362 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/change_state_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/change_state_email_to_manager.txt @@ -5,8 +5,6 @@ A booking in a room you manage has been MODIFIED and the changes require approva You can check the details of the booking here: http://localhost/rooms/booking/0 - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/change_state_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/tests/change_state_email_to_user.txt index 211f26fba30..9bdab011463 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/change_state_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/change_state_email_to_user.txt @@ -2,11 +2,11 @@ Dear Guinea, Your booking has been MODIFIED and the changes require approval. -Room: 1/2-3 -For: Guinea Pig +Room: 1/2-3 +For: Guinea Pig Reason: Testing -Dates: Friday 11/11/2022 - Friday 11/11/2022 -Hours: 13:37 - 14:37 +Dates: Friday 11/11/2022 - Friday 11/11/2022 +Hours: 13:37 - 14:37 Booking details: http://localhost/rooms/booking/0 @@ -14,8 +14,6 @@ http://localhost/rooms/booking/0 Remember you can always check your bookings here: http://localhost/rooms/my-bookings - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_manager.txt index a6e7447bd21..9744c10f23e 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_manager.txt @@ -5,8 +5,6 @@ A booking in your room '1/2-3' has been CONFIRMED by a room manager. You can check the details of the booking here: http://localhost/rooms/booking/0 - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_manager_reason.txt b/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_manager_reason.txt index f0bb11b5f5c..6b725d75946 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_manager_reason.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_manager_reason.txt @@ -8,8 +8,6 @@ Because I want to. You can check the details of the booking here: http://localhost/rooms/booking/0 - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_user.txt index 9bcb6f4d829..bb636b73e98 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_user.txt @@ -3,11 +3,11 @@ Dear Guinea, Your booking has been ACCEPTED. This is the final confirmation. -Room: 1/2-3 -For: Guinea Pig +Room: 1/2-3 +For: Guinea Pig Reason: Testing -Dates: Friday 11/11/2022 - Friday 11/11/2022 -Hours: 13:37 - 14:37 +Dates: Friday 11/11/2022 - Friday 11/11/2022 +Hours: 13:37 - 14:37 Booking details: http://localhost/rooms/booking/0 @@ -15,8 +15,6 @@ http://localhost/rooms/booking/0 Remember you can always check your bookings here: http://localhost/rooms/my-bookings - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_user_reason.txt b/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_user_reason.txt index 43606dccb0e..a2b26d4b7b8 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_user_reason.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/confirmation_email_to_user_reason.txt @@ -6,11 +6,11 @@ This is the final confirmation. The following message was provided by the room manager: Because I want to. -Room: 1/2-3 -For: Guinea Pig +Room: 1/2-3 +For: Guinea Pig Reason: Testing -Dates: Friday 11/11/2022 - Friday 11/11/2022 -Hours: 13:37 - 14:37 +Dates: Friday 11/11/2022 - Friday 11/11/2022 +Hours: 13:37 - 14:37 Booking details: http://localhost/rooms/booking/0 @@ -18,8 +18,6 @@ http://localhost/rooms/booking/0 Remember you can always check your bookings here: http://localhost/rooms/my-bookings - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_manager.txt index 48b9f68afdc..12a275d5232 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_manager.txt @@ -2,17 +2,15 @@ Dear Guinea, There is a new booking for your room. -Room: 1/2-3 -For: Guinea Pig +Room: 1/2-3 +For: Guinea Pig Reason: Testing -Dates: Friday 11/11/2022 - Monday 21/11/2022 -Hours: 13:37 - 14:37 +Dates: Friday 11/11/2022 - Monday 21/11/2022 +Hours: 13:37 - 14:37 You can check the details of the booking here: http://localhost/rooms/booking/1337 - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/creation_pre_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_manager_pre.txt similarity index 61% rename from indico/modules/rb/templates/emails/reservations/tests/creation_pre_email_to_manager.txt rename to indico/modules/rb/templates/emails/reservations/tests/creation_email_to_manager_pre.txt index abb444a8bdc..3d0678c6bc9 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/creation_pre_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_manager_pre.txt @@ -2,11 +2,11 @@ Dear Guinea, There is a new pre-booking for your room. -Room: 1/2-3 -For: Guinea Pig +Room: 1/2-3 +For: Guinea Pig Reason: Testing -Dates: Friday 11/11/2022 - Monday 21/11/2022 -Hours: 13:37 - 14:37 +Dates: Friday 11/11/2022 - Monday 21/11/2022 +Hours: 13:37 - 14:37 You can check the details of the booking here: http://localhost/rooms/booking/1337 @@ -15,4 +15,4 @@ http://localhost/rooms/booking/1337 -- Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user.txt index 84bf99fca69..1300f3c623a 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user.txt @@ -18,8 +18,6 @@ http://localhost/rooms/booking/1337 Remember you can always check your bookings here: http://localhost/rooms/my-bookings - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/creation_pre_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_pre.txt similarity index 92% rename from indico/modules/rb/templates/emails/reservations/tests/creation_pre_email_to_user.txt rename to indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_pre.txt index b3e4c873ab5..2f3250ad0bf 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/creation_pre_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_pre.txt @@ -17,8 +17,6 @@ http://localhost/rooms/booking/1337 Remember you can always check your bookings here: http://localhost/rooms/my-bookings - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat.txt b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat.txt index e71abbf5a8c..71f85995f6e 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat.txt @@ -18,8 +18,6 @@ http://localhost/rooms/booking/1337 Remember you can always check your bookings here: http://localhost/rooms/my-bookings - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat_excluded_1.txt b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat_excluded_1.txt index 1350aa689e2..83d9c120526 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat_excluded_1.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat_excluded_1.txt @@ -4,7 +4,7 @@ The conference room 1/2-3 has been booked for Guinea Pig daily booking from Friday 11/11/2022 to Monday 21/11/2022 between 13:37 and 14:37. Reason: Testing - (Note that there are 1 excluded days. For further info, check your reservation) +(Note that there are 1 excluded days. For further info, check your reservation.) If you end up not needing this room, please cancel the booking from the booking details so that the room can be booked by somebody else. @@ -19,8 +19,6 @@ http://localhost/rooms/booking/1337 Remember you can always check your bookings here: http://localhost/rooms/my-bookings - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat_excluded_2.txt b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat_excluded_2.txt index 5f01f46e748..275bb94aeb3 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat_excluded_2.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat_excluded_2.txt @@ -4,7 +4,7 @@ The conference room 1/2-3 has been booked for Guinea Pig daily booking from Friday 11/11/2022 to Monday 21/11/2022 between 13:37 and 14:37. Reason: Testing - (Note that there are 2 excluded days. For further info, check your reservation) +(Note that there are 2 excluded days. For further info, check your reservation.) If you end up not needing this room, please cancel the booking from the booking details so that the room can be booked by somebody else. @@ -19,8 +19,6 @@ http://localhost/rooms/booking/1337 Remember you can always check your bookings here: http://localhost/rooms/my-bookings - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/creation_pre_email_to_user_repeat.txt b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat_pre.txt similarity index 93% rename from indico/modules/rb/templates/emails/reservations/tests/creation_pre_email_to_user_repeat.txt rename to indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat_pre.txt index a284000efe6..be927322c19 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/creation_pre_email_to_user_repeat.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/creation_email_to_user_repeat_pre.txt @@ -17,8 +17,6 @@ http://localhost/rooms/booking/1337 Remember you can always check your bookings here: http://localhost/rooms/my-bookings - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/modification_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/tests/modification_email_to_manager.txt index 0aa85f5b33e..3a87125de45 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/modification_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/modification_email_to_manager.txt @@ -5,8 +5,6 @@ A booking in a room you manage has been MODIFIED. You can check the details of the booking here: http://localhost/rooms/booking/0 - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/modification_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/tests/modification_email_to_user.txt index ee793472cb0..95765308950 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/modification_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/modification_email_to_user.txt @@ -2,11 +2,11 @@ Dear Guinea, Your booking has been MODIFIED. -Room: 1/2-3 -For: Guinea Pig +Room: 1/2-3 +For: Guinea Pig Reason: Testing -Dates: Friday 11/11/2022 - Friday 11/11/2022 -Hours: 13:37 - 14:37 +Dates: Friday 11/11/2022 - Friday 11/11/2022 +Hours: 13:37 - 14:37 Booking details: http://localhost/rooms/booking/0 @@ -14,8 +14,6 @@ http://localhost/rooms/booking/0 Remember you can always check your bookings here: http://localhost/rooms/my-bookings - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/occurrence_cancellation_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/tests/occurrence_cancellation_email_to_manager.txt index f6610ace6a7..8f16ef050a2 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/occurrence_cancellation_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/occurrence_cancellation_email_to_manager.txt @@ -5,8 +5,6 @@ The date Friday 11/11/2022 from a booking that concerns one of your rooms has be You can check the details of the booking here: http://localhost/rooms/booking/0 - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/occurrence_cancellation_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/tests/occurrence_cancellation_email_to_user.txt index cb762f2485e..2e57edbc9ad 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/occurrence_cancellation_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/occurrence_cancellation_email_to_user.txt @@ -2,11 +2,11 @@ Dear Guinea, You have CANCELLED an occurrence of your booking on Friday 11/11/2022. -Room: 1/2-3 -For: Guinea Pig +Room: 1/2-3 +For: Guinea Pig Reason: Testing -Dates: Friday 11/11/2022 - Saturday 12/11/2022 -Hours: 13:37 - 14:37 +Dates: Friday 11/11/2022 - Saturday 12/11/2022 +Hours: 13:37 - 14:37 Booking details: http://localhost/rooms/booking/0 @@ -14,8 +14,6 @@ http://localhost/rooms/booking/0 Remember you can always check your bookings here: http://localhost/rooms/my-bookings - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/occurrence_rejection_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/tests/occurrence_rejection_email_to_manager.txt index 1aba5690b27..d2bf53cfef8 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/occurrence_rejection_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/occurrence_rejection_email_to_manager.txt @@ -5,17 +5,15 @@ A booking has been REJECTED by the manager of the room '1/2-3' for the Friday 11 Rejection reason: A valid reason! -Room: 1/2-3 -For: Guinea Pig +Room: 1/2-3 +For: Guinea Pig Reason: Testing -Dates: Friday 11/11/2022 - Saturday 12/11/2022 -Hours: 13:37 - 14:37 +Dates: Friday 11/11/2022 - Saturday 12/11/2022 +Hours: 13:37 - 14:37 You can check the details of the booking here: http://localhost/rooms/booking/0 - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/occurrence_rejection_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/tests/occurrence_rejection_email_to_user.txt index efe3db5467b..bfdefe6084c 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/occurrence_rejection_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/occurrence_rejection_email_to_user.txt @@ -5,11 +5,11 @@ Your booking has been REJECTED by the manager of the room for the Friday 11/11/2 Rejection reason: A valid reason! -Room: 1/2-3 -For: Guinea Pig +Room: 1/2-3 +For: Guinea Pig Reason: Testing -Dates: Friday 11/11/2022 - Saturday 12/11/2022 -Hours: 13:37 - 14:37 +Dates: Friday 11/11/2022 - Saturday 12/11/2022 +Hours: 13:37 - 14:37 Booking details: http://localhost/rooms/booking/0 @@ -17,8 +17,6 @@ http://localhost/rooms/booking/0 Remember you can always check your bookings here: http://localhost/rooms/my-bookings - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/rejection_email_to_manager.txt b/indico/modules/rb/templates/emails/reservations/tests/rejection_email_to_manager.txt index 1c55899b86d..3b85fa71b24 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/rejection_email_to_manager.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/rejection_email_to_manager.txt @@ -5,17 +5,15 @@ A booking has been REJECTED by the manager of the room '1/2-3'. Rejection reason: None -Room: 1/2-3 -For: Guinea Pig +Room: 1/2-3 +For: Guinea Pig Reason: Testing -Dates: Friday 11/11/2022 - Friday 11/11/2022 -Hours: 13:37 - 14:37 +Dates: Friday 11/11/2022 - Friday 11/11/2022 +Hours: 13:37 - 14:37 You can check the details of the booking here: http://localhost/rooms/booking/0 - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/rejection_email_to_user.txt b/indico/modules/rb/templates/emails/reservations/tests/rejection_email_to_user.txt index b240fa87955..1b9cce56e40 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/rejection_email_to_user.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/rejection_email_to_user.txt @@ -5,11 +5,11 @@ Your booking has been REJECTED by the manager of the room. Rejection reason: None -Room: 1/2-3 -For: Guinea Pig +Room: 1/2-3 +For: Guinea Pig Reason: Testing -Dates: Friday 11/11/2022 - Friday 11/11/2022 -Hours: 13:37 - 14:37 +Dates: Friday 11/11/2022 - Friday 11/11/2022 +Hours: 13:37 - 14:37 Booking details: http://localhost/rooms/booking/0 @@ -17,8 +17,6 @@ http://localhost/rooms/booking/0 Remember you can always check your bookings here: http://localhost/rooms/my-bookings - -- -Best regards, Indico :: Room Booking -http://localhost/rooms/ \ No newline at end of file +http://localhost/rooms/ diff --git a/indico/modules/rb/templates/emails/reservations/tests/reservation_info.txt b/indico/modules/rb/templates/emails/reservations/tests/reservation_info.txt index 24747970ca1..01300154471 100644 --- a/indico/modules/rb/templates/emails/reservations/tests/reservation_info.txt +++ b/indico/modules/rb/templates/emails/reservations/tests/reservation_info.txt @@ -1,5 +1,5 @@ -Room: 1/2-3 -For: Guinea Pig +Room: 1/2-3 +For: Guinea Pig Reason: Testing -Dates: Friday 11/11/2022 - Friday 11/11/2022 -Hours: 13:37 - 14:37 \ No newline at end of file +Dates: Friday 11/11/2022 - Friday 11/11/2022 +Hours: 13:37 - 14:37 \ No newline at end of file diff --git a/indico/modules/users/__init__.py b/indico/modules/users/__init__.py index bb3057bb4bd..95f17c7c8fa 100644 --- a/indico/modules/users/__init__.py +++ b/indico/modules/users/__init__.py @@ -15,7 +15,7 @@ from indico.modules.users.ext import ExtraUserPreferences from indico.modules.users.models.settings import UserSetting, UserSettingsProxy from indico.modules.users.models.users import NameFormat, User -from indico.util.i18n import _ +from indico.util.i18n import _, force_locale from indico.web.flask.templating import get_template_module from indico.web.flask.util import url_for from indico.web.menu import SideMenuItem, TopMenuItem @@ -81,8 +81,10 @@ def _topmenu_items(sender, **kwargs): @signals.users.registration_requested.connect def _registration_requested(req, **kwargs): from indico.modules.users.util import get_admin_emails - tpl = get_template_module('users/emails/profile_requested_admins.txt', req=req) - send_email(make_email(get_admin_emails(), template=tpl)) + with force_locale(None): + tpl = get_template_module('users/emails/profile_requested_admins.txt', req=req) + email = make_email(get_admin_emails(), template=tpl) + send_email(email) @signals.users.registered.connect @@ -91,8 +93,10 @@ def _registered(user, identity, from_moderation, **kwargs): if (from_moderation or identity is None or identity.provider != 'indico' or not user_management_settings.get('notify_account_creation')): return - tpl = get_template_module('users/emails/profile_registered_admins.txt', user=user) - send_email(make_email(get_admin_emails(), template=tpl)) + with force_locale(None): + tpl = get_template_module('users/emails/profile_registered_admins.txt', user=user) + email = make_email(get_admin_emails(), template=tpl) + send_email(email) @signals.core.import_tasks.connect diff --git a/indico/modules/users/controllers.py b/indico/modules/users/controllers.py index 75da67de4cf..a1a35b1dc6a 100644 --- a/indico/modules/users/controllers.py +++ b/indico/modules/users/controllers.py @@ -50,7 +50,7 @@ from indico.modules.users.views import (WPUser, WPUserDashboard, WPUserFavorites, WPUserPersonalData, WPUserProfilePic, WPUsersAdmin) from indico.util.date_time import now_utc -from indico.util.i18n import _ +from indico.util.i18n import _, force_locale from indico.util.images import square from indico.util.marshmallow import HumanizedDate, Principal, validate_with_message from indico.util.signals import values_from_signal @@ -460,8 +460,10 @@ def _send_confirmation(self, email): data = {'email': email, 'user_id': self.user.id} token = make_unique_token(lambda t: not token_storage.get(t)) token_storage.set(token, data, timeout=86400) - send_email(make_email(email, template=get_template_module('users/emails/verify_email.txt', - user=self.user, email=email, token=token))) + with self.user.force_user_locale(): + email_to_send = make_email(email, template=get_template_module('users/emails/verify_email.txt', + user=self.user, email=email, token=token)) + send_email(email_to_send) def _process(self): form = UserEmailsForm() @@ -739,8 +741,10 @@ class RHAcceptRegistrationRequest(RHRegistrationRequestBase): def _process(self): user, identity = register_user(self.request.email, self.request.extra_emails, self.request.user_data, self.request.identity_data, self.request.settings) - tpl = get_template_module('users/emails/registration_request_accepted.txt', user=user) - send_email(make_email(self.request.email, template=tpl)) + with user.force_user_locale(): + tpl = get_template_module('users/emails/registration_request_accepted.txt', user=user) + email = make_email(self.request.email, template=tpl) + send_email(email) flash(_('The request has been approved.'), 'success') return jsonify_data() @@ -750,8 +754,10 @@ class RHRejectRegistrationRequest(RHRegistrationRequestBase): def _process(self): db.session.delete(self.request) - tpl = get_template_module('users/emails/registration_request_rejected.txt', req=self.request) - send_email(make_email(self.request.email, template=tpl)) + with force_locale(None): + tpl = get_template_module('users/emails/registration_request_rejected.txt', req=self.request) + email = make_email(self.request.email, template=tpl) + send_email(email) flash(_('The request has been rejected.'), 'success') return jsonify_data() diff --git a/indico/modules/users/models/users.py b/indico/modules/users/models/users.py index 55de8fed2f7..ed6f66d9377 100644 --- a/indico/modules/users/models/users.py +++ b/indico/modules/users/models/users.py @@ -6,6 +6,7 @@ # LICENSE file for more details. import itertools +from contextlib import contextmanager from enum import Enum from operator import attrgetter from uuid import uuid4 @@ -31,7 +32,7 @@ from indico.modules.users.models.emails import UserEmail from indico.modules.users.models.favorites import favorite_category_table, favorite_event_table, favorite_user_table from indico.util.enum import RichIntEnum -from indico.util.i18n import _ +from indico.util.i18n import _, force_locale from indico.util.locators import locator_property from indico.util.string import format_full_name, format_repr, validate_email from indico.web.flask.util import url_for @@ -783,6 +784,13 @@ def get_merged_from_users_recursive(self): cte = cte_query.union_all(rec_query) return User.query.join(cte, User.id == cte.c.merged_from_id).all() + @contextmanager + def force_user_locale(self): + """Temporarily override the locale to the locale of the user.""" + locale = self.settings.get('lang') or None + with force_locale(locale): + yield + @listens_for(User._primary_email, 'set') @listens_for(User._secondary_emails, 'append') diff --git a/indico/modules/users/templates/emails/profile_registered_admins.txt b/indico/modules/users/templates/emails/profile_registered_admins.txt index ed18df3a123..0149e07f2a7 100644 --- a/indico/modules/users/templates/emails/profile_registered_admins.txt +++ b/indico/modules/users/templates/emails/profile_registered_admins.txt @@ -1,21 +1,21 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} -{% block subject -%}New Indico profile registered{%- endblock %} +{% block subject -%}{% trans %}New Indico profile registered{% endtrans %}{%- endblock %} {% block header -%}{%- endblock %} {% block body -%} {%- filter dedent -%} - A new Indico profile has been registered. + {% trans %}A new Indico profile has been registered.{% endtrans %} - First name: {{ user.first_name }} - Last name: {{ user.last_name }} - Email address: {{ user.email }} + {% trans %}First name:{% endtrans %} {{ user.first_name }} + {% trans %}Last name:{% endtrans %} {{ user.last_name }} + {% trans %}Email address:{% endtrans %} {{ user.email }} {%- if user.affiliation %} - Affiliation: {{ user.affiliation }} + {% trans %}Affiliation:{% endtrans %} {{ user.affiliation }} {%- endif %} - User details: + {% trans %}User details:{% endtrans %} {{ url_for('users.user_profile', user, _external=true) }} {%- endfilter -%} {%- endblock %} diff --git a/indico/modules/users/templates/emails/profile_requested_admins.txt b/indico/modules/users/templates/emails/profile_requested_admins.txt index 203b966dcd5..e34c01cefc2 100644 --- a/indico/modules/users/templates/emails/profile_requested_admins.txt +++ b/indico/modules/users/templates/emails/profile_requested_admins.txt @@ -1,26 +1,28 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} -{% block subject -%}Indico profile requested{%- endblock %} +{% block subject -%}{% trans %}Indico profile requested{% endtrans %}{%- endblock %} {% block header -%}{%- endblock %} {% block body -%} {%- filter dedent -%} - Someone has requested to register a new indico profile. - Please review their registration request and approve/reject it accordingly. + {% trans notrimmed -%} + Someone has requested to register a new indico profile. + Please review their registration request and approve/reject it accordingly. + {%- endtrans %} - First name: {{ req.user_data.first_name }} - Last name: {{ req.user_data.last_name }} - Email address: {{ req.email }} + {% trans %}First name:{% endtrans %} {{ req.user_data.first_name }} + {% trans %}Last name:{% endtrans %} {{ req.user_data.last_name }} + {% trans %}Email address:{% endtrans %} {{ req.email }} {%- if req.user_data.affiliation %} - Affiliation: {{ req.user_data.affiliation }} + {% trans %}Affiliation:{% endtrans %} {{ req.user_data.affiliation }} {%- endif %} {%- if req.comment %} - Comment: + {% trans %}Comment:{% endtrans %} {{ req.comment }} {%- endif %} - Manage pending requests: + {% trans %}Manage pending requests:{% endtrans %} {{ url_for('users.registration_request_list', _external=true) }} {%- endfilter -%} {%- endblock %} diff --git a/indico/modules/users/templates/emails/registration_request_accepted.txt b/indico/modules/users/templates/emails/registration_request_accepted.txt index 99fb4f1734e..85d8e52e92d 100644 --- a/indico/modules/users/templates/emails/registration_request_accepted.txt +++ b/indico/modules/users/templates/emails/registration_request_accepted.txt @@ -1,18 +1,18 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} -{% block subject -%}Your Indico profile has been created{%- endblock %} +{% block subject -%}{% trans %}Your Indico profile has been created{% endtrans %}{%- endblock %} {% block header_recipient -%} - {{ user.first_name }} + {% trans name=user.first_name %}Dear {{ name }},{% endtrans %} {%- endblock %} {% block body -%} {% filter dedent -%} - Your request to create an Indico profile has been approved. - You may now log in to your new account: + {% trans %}Your request to create an Indico profile has been approved.{%- endtrans %} + {% trans %}You may now log in to your new account:{%- endtrans %} {{ url_for('auth.login', _external=true) }} - After logging in your can finish setting up your profile: + {% trans %}After logging in your can finish setting up your profile:{% endtrans %} {{ url_for('users.user_profile', _external=true) }} {%- endfilter %} {%- endblock %} diff --git a/indico/modules/users/templates/emails/registration_request_rejected.txt b/indico/modules/users/templates/emails/registration_request_rejected.txt index fb4413e1740..f77256388a8 100644 --- a/indico/modules/users/templates/emails/registration_request_rejected.txt +++ b/indico/modules/users/templates/emails/registration_request_rejected.txt @@ -1,13 +1,13 @@ -{% extends 'emails/base.txt' %} +{% extends 'emails/base_i18n.txt' %} -{% block subject -%}Your registration request has been rejected{%- endblock %} +{% block subject -%}{% trans %}Your registration request has been rejected{% endtrans %}{%- endblock %} {% block header_recipient -%} - {{ req.user_data.first_name }} + {% trans name=req.user_data.first_name %}Dear {{ name }},{% endtrans %} {%- endblock %} {% block body -%} {% filter dedent -%} - Unfortunately your request to create an Indico profile has been denied. + {% trans %}Unfortunately your request to create an Indico profile has been denied.{% endtrans %} {%- endfilter %} {%- endblock %} diff --git a/indico/modules/users/templates/emails/verify_email.txt b/indico/modules/users/templates/emails/verify_email.txt index f3270913d8d..67250b6e643 100644 --- a/indico/modules/users/templates/emails/verify_email.txt +++ b/indico/modules/users/templates/emails/verify_email.txt @@ -5,13 +5,13 @@ {%- endblock %} {% block header_recipient -%} - {{ user.first_name }} + {% trans name=user.first_name %}Dear {{ name }},{% endtrans %} {%- endblock %} {% block body -%} -{%- trans notrimmed -%} -You recently added the e-mail address {{ email }} to your Indico account. -Please click the following link to confirm this action. +{%- trans notrimmed mail=email -%} + You recently added the e-mail address {{ mail }} to your Indico account. + Please click the following link to confirm this action. {%- endtrans %} {{ url_for('.user_emails_verify', token=token, _external=true) }} diff --git a/indico/modules/vc/notifications.py b/indico/modules/vc/notifications.py index 1321403abf9..d6a95f21cfa 100644 --- a/indico/modules/vc/notifications.py +++ b/indico/modules/vc/notifications.py @@ -17,10 +17,10 @@ def notify_created(plugin, room, room_assoc, event, user): :param event: the event :param user: the user performing the action """ - name = get_overridable_template_name('emails/created.html', plugin, core_prefix='vc/') - tpl = get_template_module(name, plugin=plugin, vc_room=room, event=event, vc_room_event=room_assoc, user=user, - linked_to_title=get_linked_to_description(room_assoc)) + with user.force_user_locale(): + tpl = get_template_module(name, plugin=plugin, vc_room=room, event=event, vc_room_event=room_assoc, user=user, + linked_to_title=get_linked_to_description(room_assoc)) _send('create', user, plugin, event, room, tpl) @@ -32,7 +32,8 @@ def notify_deleted(plugin, room, room_assoc, event, user): :param user: the user performing the action """ name = get_overridable_template_name('emails/deleted.html', plugin, core_prefix='vc/') - tpl = get_template_module(name, plugin=plugin, vc_room=room, event=event, vc_room_event=room_assoc, user=user) + with user.force_user_locale(): + tpl = get_template_module(name, plugin=plugin, vc_room=room, event=event, vc_room_event=room_assoc, user=user) _send('delete', user, plugin, event, room, tpl) @@ -40,6 +41,6 @@ def _send(action, user, plugin, event, room, template_module): to_list = {user.email} cc_list = plugin.get_notification_cc_list(action, room, event) - to_list bcc_list = plugin.get_notification_bcc_list(action, room, event) - cc_list - to_list - - email = make_email(to_list, cc_list, bcc_list, template=template_module, html=True) + with user.force_user_locale(): + email = make_email(to_list, cc_list, bcc_list, template=template_module, html=True) send_email(email, event, plugin.friendly_name) diff --git a/indico/modules/vc/templates/emails/created.html b/indico/modules/vc/templates/emails/created.html index 6ccb4e46f97..cb3a3554dda 100644 --- a/indico/modules/vc/templates/emails/created.html +++ b/indico/modules/vc/templates/emails/created.html @@ -1,16 +1,18 @@ -{% extends 'emails/base.html' %} +{% extends 'emails/base_i18n.html' %} {% block subject -%} - [{{ plugin.friendly_name }}] New videoconference created: {{ vc_room.name }} + [{{ plugin.friendly_name }}] {% trans %}New videoconference created:{% endtrans %} {{ vc_room.name }} {%- endblock %} {% block header -%}

        - A videoconferencing room has just been created for the event "{{ event.title }}". + {% trans a=''|safe, enda=''|safe, title=event.title -%} + A videoconferencing room has just been created for the event "{{ a }}{{ title }}{{ enda }}". + {%- endtrans %}

        - You can manage it from: + {% trans %}You can manage it from:{% endtrans %}
        {{ url_for('.manage_vc_rooms', event, _external=true) }} @@ -18,12 +20,12 @@


        - Room information + {% trans %}Room information{% endtrans %}

          -
        • Name: {{ vc_room.name }}
        • +
        • {% trans %}Name:{% endtrans %} {{ vc_room.name }}
        • {% if vc_room_event.link_type.name != 'event' -%} -
        • Linked to: {{ linked_to_title }}
        • +
        • {% trans %}Linked to:{% endtrans %} {{ linked_to_title }}
        • {%- endif %} {% block plugin_specific_info %}{% endblock %}
        diff --git a/indico/modules/vc/templates/emails/deleted.html b/indico/modules/vc/templates/emails/deleted.html index 90170cace6d..1100b8ac2dd 100644 --- a/indico/modules/vc/templates/emails/deleted.html +++ b/indico/modules/vc/templates/emails/deleted.html @@ -1,13 +1,15 @@ -{% extends 'emails/base.html' %} +{% extends 'emails/base_i18n.html' %} {% block subject -%} {% autoescape false -%} - [{{ plugin.friendly_name }}] Videoconference deleted: {{ vc_room.name }} + [{{ plugin.friendly_name }}] {% trans %}Videoconference deleted:{% endtrans %} {{ vc_room.name }} {%- endautoescape %} {%- endblock %} {% block header -%}

        - The videoconferencing room "{{ vc_room.name }}" has been deleted by {{ user.full_name }}. + {% trans room=vc_room.name, name=user.full_name -%} + The videoconferencing room "{{ room }}" has been deleted by {{ name }}. + {%- endtrans %}

        {%- endblock %} diff --git a/indico/util/i18n_test.py b/indico/util/i18n_test.py index acc10ca0a7c..d747a50ddfb 100644 --- a/indico/util/i18n_test.py +++ b/indico/util/i18n_test.py @@ -203,3 +203,22 @@ def test_pgettext_plurals(): assert pgettext('Dummy context', 'Convener') == 'Lider (Context)' assert pgettext('Dummy context', 'User') == 'User' + + +@pytest.mark.usefixtures('mock_translations') +def test_force_user_locale(dummy_user): + session.lang = 'en_AU' + dt = datetime(2022, 8, 29, 13, 37) + + assert format_datetime(dt, timezone='UTC') == '29 Aug 2022, 1:37 pm' + assert _('I need a drink.') == "I be needin' a bottle of rhum!" + + dummy_user.settings.set('lang', 'fr_CH') + with dummy_user.force_user_locale(): + assert format_datetime(dt, timezone='UTC') == '29 août 2022, 13:37' + assert _('I need a drink.') == 'Booze, svp.' + + assert format_datetime(dt, timezone='UTC') == '29 Aug 2022, 1:37 pm' + assert _('I need a drink.') == "I be needin' a bottle of rhum!" + + assert session.lang == 'en_AU' diff --git a/indico/web/templates/emails/base.txt b/indico/web/templates/emails/base.txt index 095ce48ff9f..d04ba580d90 100644 --- a/indico/web/templates/emails/base.txt +++ b/indico/web/templates/emails/base.txt @@ -3,7 +3,7 @@ {%- endmacro %} {% macro get_body(footer) %} - {%- block header %}Dear {% block header_recipient %}{% endblock %}, + {%- block header %}{% block header_recipient %}{% endblock %}, {% endblock -%} {% block body -%}{%- endblock %} diff --git a/indico/web/templates/emails/base_i18n.html b/indico/web/templates/emails/base_i18n.html new file mode 100644 index 00000000000..93c25b807ce --- /dev/null +++ b/indico/web/templates/emails/base_i18n.html @@ -0,0 +1,11 @@ +{% extends 'emails/base.html' %} + +{% block header_content %} + {% block header_recipient %}{% endblock %} +{% endblock %} + +{% block footer_content %} +
        +
        Indico + :: {% block footer_title %}{% trans %}Email Notifier{% endtrans %}{% endblock %}
        +{% endblock %} diff --git a/indico/web/templates/emails/base_i18n.txt b/indico/web/templates/emails/base_i18n.txt index 4c5478eeb3a..282f387e290 100644 --- a/indico/web/templates/emails/base_i18n.txt +++ b/indico/web/templates/emails/base_i18n.txt @@ -1,6 +1,6 @@ {% extends 'emails/base.txt' %} -{%- block header %}{{ pgettext('greeting', 'Dear') }} {% block header_recipient %}{% endblock %}, +{%- block header %}{% block header_recipient %}{% endblock %} {% endblock -%} diff --git a/indico/web/templates/emails/custom.html b/indico/web/templates/emails/custom.html index 16121899690..a7dc11f004e 100644 --- a/indico/web/templates/emails/custom.html +++ b/indico/web/templates/emails/custom.html @@ -1,4 +1,4 @@ -{% extends 'emails/base.html' %} +{% extends 'emails/base_i18n.html' %} {% block subject %}{{ subject | safe }}{% endblock %} {% block body -%}{{ body | sanitize_html }}{%- endblock %}