Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

topics: Fix translation issue with moved topic notifications.

Eeshan Gargc4aeb159c4d5
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index bc4f284e941..2f34f726931 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -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}"
)
diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.py
index 03a23523116..69ff270ab75 100644
--- a/zerver/tests/test_message_edit.py
+++ b/zerver/tests/test_message_edit.py
@@ -79,9 +79,18 @@ class EditMessageTestCase(ZulipTestCase):
)
def prepare_move_topics(
- self, user_email: str, old_stream: str, new_stream: str, topic: str
+ self,
+ user_email: str,
+ old_stream: str,
+ new_stream: str,
+ topic: str,
+ language: Optional[str] = None,
) -> Tuple[UserProfile, Stream, Stream, int, int]:
user_profile = self.example_user(user_email)
+ if language is not None:
+ user_profile.default_language = language
+ user_profile.save(update_fields=["default_language"])
+
self.login(user_email)
stream = self.make_stream(old_stream)
new_stream = self.make_stream(new_stream)
@@ -1286,7 +1295,13 @@ class EditMessageTest(EditMessageTestCase):
def test_move_message_to_stream(self) -> None:
(user_profile, old_stream, new_stream, msg_id, msg_id_lt) = self.prepare_move_topics(
- "iago", "test move stream", "new stream", "test"
+ "iago",
+ "test move stream",
+ "new stream",
+ "test",
+ # Set the user's translation language to German to test that
+ # it is overridden by the realm's default language.
+ "de",
)
result = self.client_patch(
@@ -1296,6 +1311,7 @@ class EditMessageTest(EditMessageTestCase):
"stream_id": new_stream.id,
"propagate_mode": "change_all",
},
+ HTTP_ACCEPT_LANGUAGE="de",
)
self.assert_json_success(result)