Skip to content

Commit

Permalink
Make email templates translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
Leats committed Sep 7, 2022
1 parent 0238e31 commit 5751455
Show file tree
Hide file tree
Showing 163 changed files with 1,198 additions and 790 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Expand Up @@ -7,6 +7,11 @@ Version 3.2.1

*Unreleased*

Internationalization
^^^^^^^^^^^^^^^^^^^^

- Make email templates translatable (:issue:`5263`, :pr:`5488`, thanks :user:`Leats`)

Improvements
^^^^^^^^^^^^

Expand Down
Expand Up @@ -5,7 +5,7 @@
{%- endblock %}

{% block header_recipient -%}
{{ user.first_name }}
{% trans name=user.first_name %}Dear {{ name }},{% endtrans %}
{%- endblock %}

{% block body -%}
Expand Down
Expand Up @@ -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:
Expand Down
10 changes: 6 additions & 4 deletions indico/modules/events/abstracts/controllers/reviewing.py
Expand Up @@ -28,7 +28,7 @@
from indico.modules.events.abstracts.util import get_track_reviewer_abstract_counts, get_user_tracks
from indico.modules.events.abstracts.views import WPDisplayAbstractsReviewing, render_abstract_page
from indico.modules.events.tracks.models.tracks import Track
from indico.util.i18n import _
from indico.util.i18n import _, force_user_locale
from indico.web.flask.templating import get_template_module
from indico.web.util import _pop_injected_js, jsonify_data, jsonify_template

Expand Down Expand Up @@ -204,9 +204,11 @@ def _get_recipients(self, visibility):

def _send_notification(self, recipients, comment):
for recipient in recipients:
tpl = get_template_module('events/abstracts/emails/comment.html', event=self.event, abstract=self.abstract,
submitter=session.user, comment=comment, recipient=recipient)
email = make_email(to_list=recipient.email, template=tpl, html=True)
with force_user_locale(recipient):
tpl = get_template_module('events/abstracts/emails/comment.html', event=self.event,
abstract=self.abstract, submitter=session.user, comment=comment,
recipient=recipient)
email = make_email(to_list=recipient.email, template=tpl, html=True)
send_email(email, self.event, 'Abstracts', session.user)

def _process(self):
Expand Down
@@ -1,4 +1,4 @@
{% extends 'emails/base.txt' %}
{% extends 'emails/base_i18n.txt' %}

{% block subject -%}
{{ subject }}
Expand All @@ -11,10 +11,9 @@
{%- endblock %}

{% block footer_title -%}
Call for Abstracts
{% trans %}Call for Abstracts{% endtrans %}
{%- endblock %}

{% block footer_url -%}
{{ event.external_url }}
{%- endblock %}

6 changes: 3 additions & 3 deletions indico/modules/events/abstracts/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 %}Call for Abstracts{% endblock %}
{% block subject_message %}{% trans %}Call for Abstracts{% endtrans %}{% endblock %}
{%- block subject_name %}{% endblock %}
{%- endblock %}

Expand Down Expand Up @@ -34,7 +34,7 @@ <h3 style="margin: 0; margin-top: 10px; padding-top: 10px; border-top: 1px solid
{% endblock %}
</div>
<div style="text-align: center; padding: 10px; background: #ebebeb; font-size: small; color: #999;">
Indico :: Call for Abstracts
Indico :: {% trans %}Call for Abstracts{% endtrans %}
</div>
</div>
{% endblock %}
18 changes: 11 additions & 7 deletions indico/modules/events/abstracts/templates/emails/comment.html
@@ -1,21 +1,25 @@
{% extends 'events/abstracts/emails/base.html' %}
{% extends 'events/abstracts/emails/base_i18n.html' %}

{% block subject_message %}New abstract comment{% endblock %}
{% block subject_message %}{% trans %}New abstract comment{% endtrans %}{% endblock %}

{% block header_subtitle %}New abstract comment{% endblock %}
{% block header_subtitle %}{% trans %}New abstract comment{% endtrans %}{% endblock %}

{% block header_subtitle_ref %}ref #{{ abstract.friendly_id }}{% endblock %}
{% block header_subtitle_ref %}{% trans id=abstract.friendly_id %}ref #{{ id }}{% endtrans %}{% endblock %}

{% block content_header %}
<p>Dear {{ recipient.first_name }},</p>
<p>{{ submitter.full_name }} commented on the abstract <strong>{{ abstract.title }}</strong>:</p>
<p>{% trans name=recipient.first_name %}Dear {{ name }},{% endtrans %}</p>
<p>
{%- trans name=submitter.full_name title=abstract.title strong='<strong>'|safe, endstrong='</strong>'|safe -%}
{{ name }} commented on the abstract {{ strong }}{{ title }}{{ endstrong }}:
{%- endtrans -%}
</p>
<blockquote style="border-left: 5px solid #dfdfdf; padding-left: 10px; font-style: italic; color: #999;">
{{ comment }}
</blockquote>
{% endblock %}

{% block content_body %}
<p>You can view this comment on the abstract page:</p>
<p>{% trans %}You can view this comment on the abstract page:{% endtrans %}</p>
<p>
<a href="{{ url_for('abstracts.display_abstract', abstract, management=false, _external=true) }}">
{{- url_for('abstracts.display_abstract', abstract, management=false, _external=true) -}}
Expand Down
@@ -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 %}
@@ -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 %}
@@ -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 %}
Expand Up @@ -4,7 +4,7 @@

{% macro get_body() -%}
{%- filter dedent -%}
Dear {submitter_name},
{% trans %}Dear {submitter_name},{% endtrans %}

{% block body %}{% endblock %}
{%- endfilter -%}
Expand Down
@@ -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 %}
@@ -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 %}
21 changes: 13 additions & 8 deletions indico/modules/events/agreements/notifications.py
Expand Up @@ -9,6 +9,7 @@

from indico.core.notifications import email_sender, make_email
from indico.core.plugins import get_plugin_template_module
from indico.util.i18n import force_user_locale
from indico.util.placeholders import replace_placeholders
from indico.web.flask.templating import get_template_module

Expand All @@ -24,19 +25,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 force_user_locale(agreement.user):
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 force_user_locale(agreement.user):
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)
@@ -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:<br>
{% trans %}There is an agreement you are requested to sign for the event:{% endtrans %}<br>
<strong>{{ event.title }}</strong><br><br>

{% block body_agreement_request %}
You can sign it on the following page:
{% trans %}You can sign it on the following page:{% endtrans %}
{% endblock %}<br>
{agreement_link}
{% endblock %}

{% if session %}
<br><br>
Best regards<br>
{% trans %}Best regards{% endtrans %}<br>
{{ 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 %}
Expand Down
@@ -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 %}

Expand Down
@@ -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 %}
@@ -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 %}

Expand Down

0 comments on commit 5751455

Please sign in to comment.