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.
This commit is contained in:
Prakhar Pratyush 2024-03-29 19:55:35 +05:30 committed by Tim Abbott
parent 61e606f656
commit 7ea66dbec5
5 changed files with 13 additions and 11 deletions

View File

@ -101,9 +101,10 @@ IGNORED_PHRASES = [
r"in 1 hour", r"in 1 hour",
r"in 20 minutes", r"in 20 minutes",
r"in 3 hours", r"in 3 hours",
# these are used as topics # these are used as channel or topic names
r"^new channels$", r"^new channels$",
r"^channel events$", r"^channel events$",
r"^general$",
# These are used as example short names (e.g. an uncapitalized context): # These are used as example short names (e.g. an uncapitalized context):
r"^marketing$", r"^marketing$",
r"^cookie$", r"^cookie$",

View File

@ -5,6 +5,7 @@ from typing import Any, Dict, Optional
from django.conf import settings from django.conf import settings
from django.db import transaction from django.db import transaction
from django.utils.timezone import now as timezone_now from django.utils.timezone import now as timezone_now
from django.utils.translation import gettext as _
from confirmation import settings as confirmation_settings from confirmation import settings as confirmation_settings
from zerver.actions.message_send import internal_send_stream_message 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 # Create stream once Realm object has been saved
new_stream_announcements_stream = ensure_stream( new_stream_announcements_stream = ensure_stream(
realm, realm,
Realm.DEFAULT_NOTIFICATION_STREAM_NAME, str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME),
stream_description="Everyone is added to this stream by default. Welcome! :octopus:", stream_description="Everyone is added to this stream by default. Welcome! :octopus:",
acting_user=None, acting_user=None,
) )

View File

@ -273,7 +273,7 @@ def send_initial_realm_messages(realm: Realm) -> None:
"This is a message on channel #**{default_notification_channel_name}** with the " "This is a message on channel #**{default_notification_channel_name}** with the "
"topic `topic demonstration`." "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 = ( content2_of_topic_demonstration_topic_name = (
_("Topics are a lightweight tool to keep conversations organized.") _("Topics are a lightweight tool to keep conversations organized.")
@ -298,7 +298,7 @@ def send_initial_realm_messages(realm: Realm) -> None:
previous message." previous message."
) )
).format( ).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", 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]] = [ welcome_messages: List[Dict[str, str]] = [
{ {
"stream": Realm.DEFAULT_NOTIFICATION_STREAM_NAME, "stream": str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME),
"topic_name": "topic demonstration", "topic_name": "topic demonstration",
"content": content1_of_topic_demonstration_topic_name, "content": content1_of_topic_demonstration_topic_name,
}, },
{ {
"stream": Realm.DEFAULT_NOTIFICATION_STREAM_NAME, "stream": str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME),
"topic_name": "topic demonstration", "topic_name": "topic demonstration",
"content": content2_of_topic_demonstration_topic_name, "content": content2_of_topic_demonstration_topic_name,
}, },
{ {
"stream": realm.DEFAULT_NOTIFICATION_STREAM_NAME, "stream": str(realm.DEFAULT_NOTIFICATION_STREAM_NAME),
"topic_name": "swimming turtles", "topic_name": "swimming turtles",
"content": content_of_swimming_turtles_topic_name, "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), "topic_name": str(Realm.ZULIP_UPDATE_ANNOUNCEMENTS_TOPIC_NAME),
"content": content_of_zulip_update_announcements_topic_name, "content": content_of_zulip_update_announcements_topic_name,
}, },

View File

@ -333,7 +333,7 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
# Defaults for new users # Defaults for new users
default_language = models.CharField(default="en", max_length=MAX_LANGUAGE_ID_LENGTH) 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") STREAM_EVENTS_NOTIFICATION_TOPIC_NAME = gettext_lazy("channel events")
new_stream_announcements_stream = models.ForeignKey( new_stream_announcements_stream = models.ForeignKey(
"Stream", "Stream",

View File

@ -1303,7 +1303,7 @@ class RealmCreationTest(ZulipTestCase):
# Check welcome messages # Check welcome messages
for stream_name, text, message_count in [ 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) stream = get_stream(stream_name, realm)
recipient = stream.recipient recipient = stream.recipient
@ -1742,7 +1742,7 @@ class RealmCreationTest(ZulipTestCase):
# with_the_topic_in_italian = "con l'argomento" # with_the_topic_in_italian = "con l'argomento"
# for stream_name, text, message_count in [ # 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) # stream = get_stream(stream_name, realm)
# recipient = stream.recipient # recipient = stream.recipient