onboarding: Fix topic names not being translated correctly.

In 'send_initial_realm_messages', the topics names were not
being translated properly as they were computed outside the
with `override_language` block.

Now, we use 'send_initial_realm_messages' inside a with
'override_language' block in the caller. This fixes the bug.

Note: We are using 'override_language' block in the caller
and not within the function as it helps to avoid indenting
everything inside the function.
This commit is contained in:
Prakhar Pratyush 2024-05-13 13:00:12 +05:30 committed by Tim Abbott
parent aad66674e7
commit 0cddc8a6a6
2 changed files with 41 additions and 41 deletions

View File

@ -582,6 +582,7 @@ def do_create_user(
if realm_creation: if realm_creation:
from zerver.lib.onboarding import send_initial_realm_messages from zerver.lib.onboarding import send_initial_realm_messages
with override_language(realm.default_language):
send_initial_realm_messages(realm) send_initial_realm_messages(realm)
return user_profile return user_profile

View File

@ -271,7 +271,6 @@ def send_initial_realm_messages(realm: Realm) -> None:
# at least one message. # at least one message.
welcome_bot = get_system_bot(settings.WELCOME_BOT, realm.id) welcome_bot = get_system_bot(settings.WELCOME_BOT, realm.id)
with override_language(realm.default_language):
# Content is declared here to apply translation properly. # Content is declared here to apply translation properly.
# #
# remove_single_newlines needs to be called on any multiline # remove_single_newlines needs to be called on any multiline