topics: Fix translation issue with moved topic notifications.

Since the calls to the translation function `_()` are made outside
of the `send_message_moved_breadcrumbs` function, these strings are
translated outside of the `with override_language` block, leading to
translated strings even when we don't intend them to be translated.

We now use gettext_lazy with appropriate testing to avoid this.
This commit is contained in:
Eeshan Garg
2021-10-04 16:04:38 -04:00
committed by Tim Abbott
parent 3922b171a8
commit c4aeb159c4
2 changed files with 23 additions and 4 deletions

View File

@@ -35,6 +35,7 @@ from django.db.models.query import QuerySet
from django.utils.html import escape
from django.utils.timezone import now as timezone_now
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
from django.utils.translation import override as override_language
from psycopg2.extras import execute_values
from psycopg2.sql import SQL
@@ -6489,11 +6490,13 @@ def do_update_message(
# Notify users that the topic was moved.
old_thread_notification_string = None
if send_notification_to_old_thread:
old_thread_notification_string = _("This topic was moved by {user} to {new_location}")
old_thread_notification_string = gettext_lazy(
"This topic was moved by {user} to {new_location}"
)
new_thread_notification_string = None
if send_notification_to_new_thread:
new_thread_notification_string = _(
new_thread_notification_string = gettext_lazy(
"This topic was moved here from {old_location} by {user}"
)