From 7ea66dbec57f64d55e5704d4b664f82fc1412580 Mon Sep 17 00:00:00 2001 From: Prakhar Pratyush Date: Fri, 29 Mar 2024 19:55:35 +0530 Subject: [PATCH] onboarding: Mark channel name for translation. Mark the channel name of the initial channel created during realm creation for translation. It doesn't mark the topic names and description for translation because we are planning to remove these topics and update the description as a part of improving the onboarding experience. --- tools/lib/capitalization.py | 3 ++- zerver/actions/create_realm.py | 3 ++- zerver/lib/onboarding.py | 12 ++++++------ zerver/models/realms.py | 2 +- zerver/tests/test_signup.py | 4 ++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tools/lib/capitalization.py b/tools/lib/capitalization.py index 03917d1e75..fd38834d60 100644 --- a/tools/lib/capitalization.py +++ b/tools/lib/capitalization.py @@ -101,9 +101,10 @@ IGNORED_PHRASES = [ r"in 1 hour", r"in 20 minutes", r"in 3 hours", - # these are used as topics + # these are used as channel or topic names r"^new channels$", r"^channel events$", + r"^general$", # These are used as example short names (e.g. an uncapitalized context): r"^marketing$", r"^cookie$", diff --git a/zerver/actions/create_realm.py b/zerver/actions/create_realm.py index 4d28bac377..8f1f6fee31 100644 --- a/zerver/actions/create_realm.py +++ b/zerver/actions/create_realm.py @@ -5,6 +5,7 @@ from typing import Any, Dict, Optional from django.conf import settings from django.db import transaction from django.utils.timezone import now as timezone_now +from django.utils.translation import gettext as _ from confirmation import settings as confirmation_settings from zerver.actions.message_send import internal_send_stream_message @@ -280,7 +281,7 @@ def do_create_realm( # Create stream once Realm object has been saved new_stream_announcements_stream = ensure_stream( realm, - Realm.DEFAULT_NOTIFICATION_STREAM_NAME, + str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME), stream_description="Everyone is added to this stream by default. Welcome! :octopus:", acting_user=None, ) diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.py index 03ce652a20..b40dba0707 100644 --- a/zerver/lib/onboarding.py +++ b/zerver/lib/onboarding.py @@ -273,7 +273,7 @@ def send_initial_realm_messages(realm: Realm) -> None: "This is a message on channel #**{default_notification_channel_name}** with the " "topic `topic demonstration`." ) - ).format(default_notification_channel_name=Realm.DEFAULT_NOTIFICATION_STREAM_NAME) + ).format(default_notification_channel_name=str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME)) content2_of_topic_demonstration_topic_name = ( _("Topics are a lightweight tool to keep conversations organized.") @@ -298,7 +298,7 @@ def send_initial_realm_messages(realm: Realm) -> None: previous message." ) ).format( - default_notification_channel_name=Realm.DEFAULT_NOTIFICATION_STREAM_NAME, + default_notification_channel_name=str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME), start_topic_help_url="/help/introduction-to-topics#how-to-start-a-new-topic", ) @@ -321,22 +321,22 @@ they can be disabled. [Learn more]({zulip_update_announcements_help_url}). welcome_messages: List[Dict[str, str]] = [ { - "stream": Realm.DEFAULT_NOTIFICATION_STREAM_NAME, + "stream": str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME), "topic_name": "topic demonstration", "content": content1_of_topic_demonstration_topic_name, }, { - "stream": Realm.DEFAULT_NOTIFICATION_STREAM_NAME, + "stream": str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME), "topic_name": "topic demonstration", "content": content2_of_topic_demonstration_topic_name, }, { - "stream": realm.DEFAULT_NOTIFICATION_STREAM_NAME, + "stream": str(realm.DEFAULT_NOTIFICATION_STREAM_NAME), "topic_name": "swimming turtles", "content": content_of_swimming_turtles_topic_name, }, { - "stream": Realm.DEFAULT_NOTIFICATION_STREAM_NAME, + "stream": str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME), "topic_name": str(Realm.ZULIP_UPDATE_ANNOUNCEMENTS_TOPIC_NAME), "content": content_of_zulip_update_announcements_topic_name, }, diff --git a/zerver/models/realms.py b/zerver/models/realms.py index a5c3be5427..8d1ee974b8 100644 --- a/zerver/models/realms.py +++ b/zerver/models/realms.py @@ -333,7 +333,7 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub # Defaults for new users default_language = models.CharField(default="en", max_length=MAX_LANGUAGE_ID_LENGTH) - DEFAULT_NOTIFICATION_STREAM_NAME = "general" + DEFAULT_NOTIFICATION_STREAM_NAME = gettext_lazy("general") STREAM_EVENTS_NOTIFICATION_TOPIC_NAME = gettext_lazy("channel events") new_stream_announcements_stream = models.ForeignKey( "Stream", diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index 93065fba5d..89aefa1db4 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -1303,7 +1303,7 @@ class RealmCreationTest(ZulipTestCase): # Check welcome messages for stream_name, text, message_count in [ - (Realm.DEFAULT_NOTIFICATION_STREAM_NAME, "with the topic", 4), + (str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME), "with the topic", 4), ]: stream = get_stream(stream_name, realm) recipient = stream.recipient @@ -1742,7 +1742,7 @@ class RealmCreationTest(ZulipTestCase): # with_the_topic_in_italian = "con l'argomento" # for stream_name, text, message_count in [ - # (Realm.DEFAULT_NOTIFICATION_STREAM_NAME, with_the_topic_in_italian, 4), + # (str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME), with_the_topic_in_italian, 4), # ]: # stream = get_stream(stream_name, realm) # recipient = stream.recipient