diff --git a/newsroom/email.py b/newsroom/email.py index d7aee7ca6..ca90a8825 100644 --- a/newsroom/email.py +++ b/newsroom/email.py @@ -7,7 +7,7 @@ from superdesk import get_resource_service from flask import current_app, render_template, url_for -from flask_babel import gettext +from flask_babel import gettext, force_locale from flask_mail import Attachment, Message from jinja2 import TemplateNotFound from newsroom.auth import get_company @@ -204,13 +204,14 @@ def send_template_email( try: set_template_locale(language) - send_email( - to=group["emails"], - subject=subject, - text_body=render_template(group["text_template"], **template_kwargs), - html_body=render_template(group["html_template"], **template_kwargs), - **kwargs, - ) + with force_locale(language): + send_email( + to=group["emails"], + subject=subject, + text_body=render_template(group["text_template"], **template_kwargs), + html_body=render_template(group["html_template"], **template_kwargs), + **kwargs, + ) finally: set_template_locale() diff --git a/newsroom/template_filters.py b/newsroom/template_filters.py index 6975ec8e5..d7dd0efd9 100644 --- a/newsroom/template_filters.py +++ b/newsroom/template_filters.py @@ -14,7 +14,6 @@ from superdesk.text_utils import get_text, get_word_count, get_char_count from superdesk.utc import utcnow from datetime import datetime -from newsroom.template_loaders import get_template_locale from newsroom.user_roles import UserRole @@ -24,7 +23,7 @@ def get_client_format(key) -> Optional[str]: - locale = str(get_template_locale() or get_locale()) + locale = str(get_locale()) try: return app.config["CLIENT_LOCALE_FORMATS"][locale][key] except KeyError: