Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
onboarding: Override the language of welcome bot PMs with user setting.
Sahil Batra47c6100da9e2
diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.pyindex ece845fbf12..36018b310e1 100644--- a/zerver/lib/onboarding.py+++ b/zerver/lib/onboarding.py@@ -4,6 +4,7 @@ from django.conf import settingsfrom django.db import transactionfrom django.db.models import Countfrom django.utils.translation import gettext as _+from django.utils.translation import override as override_languagefrom zerver.actions.create_realm import setup_realm_internal_botsfrom zerver.actions.message_send import (@@ -41,40 +42,45 @@ def create_if_missing_realm_internal_bots() -> None:def send_initial_pms(user: UserProfile) -> None:organization_setup_text = ""- if user.is_realm_admin:- help_url = user.realm.uri + "/help/getting-your-organization-started-with-zulip"- organization_setup_text = (- " " + _("We also have a guide for [Setting up your organization]({help_url}).")- ).format(help_url=help_url)- welcome_msg = _("Hello, and welcome to Zulip!") + "👋"- demo_org_warning = ""- if user.realm.demo_organization_scheduled_deletion_date is not None:- demo_org_warning = (- _(- "Note that this is a [demo organization]({demo_org_help_url}) and will be "- "**automatically deleted** in 30 days."- )- + "\n\n"- )+ # We need to override the language in this code path, because it's+ # called from account registration, which is a pre-account API+ # request and thus may not have the user's language context yet.+ with override_language(user.default_language):+ if user.is_realm_admin:+ help_url = user.realm.uri + "/help/getting-your-organization-started-with-zulip"+ organization_setup_text = (+ " " + _("We also have a guide for [Setting up your organization]({help_url}).")+ ).format(help_url=help_url)- content = "".join(- [- welcome_msg + " ",- _("This is a private message from me, Welcome Bot.") + "\n\n",- _(- "If you are new to Zulip, check out our [Getting started guide]({getting_started_url})!"- ),- "{organization_setup_text}" + "\n\n",- "{demo_org_warning}",- _(- "I can also help you get set up! Just click anywhere on this message or press `r` to reply."+ welcome_msg = _("Hello, and welcome to Zulip!") + "👋"+ demo_org_warning = ""+ if user.realm.demo_organization_scheduled_deletion_date is not None:+ demo_org_warning = (+ _(+ "Note that this is a [demo organization]({demo_org_help_url}) and will be "+ "**automatically deleted** in 30 days."+ )+ + "\n\n")- + "\n\n",- _("Here are a few messages I understand:") + " ",- bot_commands(),- ]- )++ content = "".join(+ [+ welcome_msg + " ",+ _("This is a private message from me, Welcome Bot.") + "\n\n",+ _(+ "If you are new to Zulip, check out our [Getting started guide]({getting_started_url})!"+ ),+ "{organization_setup_text}" + "\n\n",+ "{demo_org_warning}",+ _(+ "I can also help you get set up! Just click anywhere on this message or press `r` to reply."+ )+ + "\n\n",+ _("Here are a few messages I understand:") + " ",+ bot_commands(),+ ]+ )content = content.format(organization_setup_text=organization_setup_text,