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.

18n: Cleanup strings to be translated in add_subscriptions_backend.

Vishnu KSa74cdf3123c3
diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py
index 5b58fa185f8..2f2bba94b50 100644
--- a/zerver/tests/test_subs.py
+++ b/zerver/tests/test_subs.py
@@ -2644,7 +2644,7 @@ class SubscriptionAPITest(ZulipTestCase):
self.assertEqual(msg.recipient.type, msg.recipient.STREAM)
self.assertEqual(msg.topic_name(), 'stream events')
self.assertEqual(msg.sender.email, settings.NOTIFICATION_BOT)
- self.assertIn('Stream created by @_**', msg.content)
+ self.assertIn(f"Stream created by @_**{self.test_user.full_name}|{self.test_user.id}**", msg.content)
def test_multi_user_subscription(self) -> None:
user1 = self.example_user("cordelia")
diff --git a/zerver/views/streams.py b/zerver/views/streams.py
index dc922e005f9..43e32a7b052 100644
--- a/zerver/views/streams.py
+++ b/zerver/views/streams.py
@@ -535,15 +535,15 @@ def add_subscriptions_backend(
if notifications_stream is not None:
with override_language(notifications_stream.realm.default_language):
if len(created_streams) > 1:
- content = _("@_**%(user_name)s|%(user_id)d** created the following streams: %(stream_str)s.")
+ content = _("{user_name} created the following streams: {stream_str}.")
else:
- content = _("@_**%(user_name)s|%(user_id)d** created a new stream %(stream_str)s.")
+ content = _("{user_name} created a new stream {stream_str}.")
topic = _('new streams')
- content = content % {
- 'user_name': user_profile.full_name,
- 'user_id': user_profile.id,
- 'stream_str': ", ".join(f'#**{s.name}**' for s in created_streams)}
+ content = content.format(
+ user_name=f"@_**{user_profile.full_name}|{user_profile.id}**",
+ stream_str=", ".join(f'#**{s.name}**' for s in created_streams)
+ )
sender = get_system_bot(settings.NOTIFICATION_BOT)
@@ -567,9 +567,8 @@ def add_subscriptions_backend(
sender=sender,
stream=stream,
topic=Realm.STREAM_EVENTS_NOTIFICATION_TOPIC,
- content=_('Stream created by @_**{user_name}|{user_id}**.').format(
- user_name=user_profile.full_name,
- user_id=user_profile.id,
+ content=_('Stream created by {user_name}.').format(
+ user_name=f"@_**{user_profile.full_name}|{user_profile.id}**",
),
),
)