Repository: zulip/zulip

Issue:
Notification bot uses the language of the user that triggered the notification
Notification bot uses the language of the user that triggered the notification.
See image:
<img width="404" alt="Screen Shot 2022-07-17 at 15 28 30" src="https://user-images.githubusercontent.com/322822/179425453-2d38f403-d633-41a2-a281-fa2055cdb050.png">
I find this odd, but perhaps hard to prevent, as I assume these are messages written to the server, and thus unrealistic there would be a different framework just to handle notification bot messages.



Discussion:
Hello @zulip/server-i18n members, this issue was labeled with the "area: internationalization" label, so you may want to check it out!

<!-- areaLabelAddition -->


Resolving patch:
diff --git a/zerver/actions/create_user.py b/zerver/actions/create_user.py
--- a/zerver/actions/create_user.py
+++ b/zerver/actions/create_user.py
@@ -77,14 +77,16 @@ def create_historical_user_messages(*, user_id: int, message_ids: List[int]) ->
 
 
 def send_message_to_signup_notification_stream(
-    sender: UserProfile, realm: Realm, message: str, topic_name: str = _("signups")
+    sender: UserProfile, realm: Realm, message: str
 ) -> None:
     signup_notifications_stream = realm.get_signup_notifications_stream()
     if signup_notifications_stream is None:
         return
 
     with override_language(realm.default_language):
-        internal_send_stream_message(sender, signup_notifications_stream, topic_name, message)
+        topic_name = _("signups")
+
+    internal_send_stream_message(sender, signup_notifications_stream, topic_name, message)
 
 
 def notify_new_user(user_profile: UserProfile) -> None:
@@ -94,9 +96,10 @@ def notify_new_user(user_profile: UserProfile) -> None:
 
     is_first_user = user_count == 1
     if not is_first_user:
-        message = _("{user} just signed up for Zulip. (total: {user_count})").format(
-            user=silent_mention_syntax_for_user(user_profile), user_count=user_count
-        )
+        with override_language(user_profile.realm.default_language):
+            message = _("{user} just signed up for Zulip. (total: {user_count})").format(
+                user=silent_mention_syntax_for_user(user_profile), user_count=user_count
+            )
 
         if settings.BILLING_ENABLED:
             from corporate.lib.registration import generate_licenses_low_warning_message_if_required
@@ -117,9 +120,10 @@ def notify_new_user(user_profile: UserProfile) -> None:
         # Check whether the stream exists
         signups_stream = get_signups_stream(admin_realm)
         # We intentionally use the same strings as above to avoid translation burden.
-        message = _("{user} just signed up for Zulip. (total: {user_count})").format(
-            user=f"{user_profile.full_name} <`{user_profile.email}`>", user_count=user_count
-        )
+        with override_language(admin_realm.default_language):
+            message = _("{user} just signed up for Zulip. (total: {user_count})").format(
+                user=f"{user_profile.full_name} <`{user_profile.email}`>", user_count=user_count
+            )
         internal_send_stream_message(
             admin_realm_sender, signups_stream, user_profile.realm.display_subdomain, message
         )


Test patch: