i18n: Update translated string variables for stream to channel rename.

Generally updates variables that appear in translated strings that use
"stream" to instead use "channel".

Two exceptions are ErrorCode.STREAM_DOES_NOT_EXIST JsonableErrors as
changing the variable would also change the fields returned by these
errors to clients.

Changes to context variables in emails and variables in onboarding
welcome bot messages are addressed in separate commits.

Part of stream to channel rename project.
This commit is contained in:
Lauryn Menard
2024-04-15 21:24:26 +02:00
committed by Tim Abbott
parent 4dcb0258a5
commit abc6f5b8a2
6 changed files with 41 additions and 41 deletions

View File

@@ -93,8 +93,8 @@ def do_create_default_stream_group(
if stream.id in default_stream_ids:
raise JsonableError(
_(
"'{stream_name}' is a default stream and cannot be added to '{group_name}'",
).format(stream_name=stream.name, group_name=group_name)
"'{channel_name}' is a default stream and cannot be added to '{group_name}'",
).format(channel_name=stream.name, group_name=group_name)
)
check_default_stream_group_name(group_name)
@@ -120,14 +120,14 @@ def do_add_streams_to_default_stream_group(
if stream.id in default_stream_ids:
raise JsonableError(
_(
"'{stream_name}' is a default stream and cannot be added to '{group_name}'",
).format(stream_name=stream.name, group_name=group.name)
"'{channel_name}' is a default stream and cannot be added to '{group_name}'",
).format(channel_name=stream.name, group_name=group.name)
)
if stream in group.streams.all():
raise JsonableError(
_(
"Stream '{stream_name}' is already present in default stream group '{group_name}'",
).format(stream_name=stream.name, group_name=group.name)
"Stream '{channel_name}' is already present in default stream group '{group_name}'",
).format(channel_name=stream.name, group_name=group.name)
)
group.streams.add(stream)
@@ -143,8 +143,8 @@ def do_remove_streams_from_default_stream_group(
if stream.id not in group_stream_ids:
raise JsonableError(
_(
"Stream '{stream_name}' is not present in default stream group '{group_name}'",
).format(stream_name=stream.name, group_name=group.name)
"Stream '{channel_name}' is not present in default stream group '{group_name}'",
).format(channel_name=stream.name, group_name=group.name)
)
delete_stream_ids = {stream.id for stream in streams}

View File

@@ -1460,34 +1460,34 @@ def send_pm_if_empty_stream(
if stream_id is not None:
arg_dict = {
**arg_dict,
"stream_id": stream_id,
"channel_id": stream_id,
}
content = _(
"Your bot {bot_identity} tried to send a message to stream ID "
"{stream_id}, but there is no stream with that ID."
"{channel_id}, but there is no stream with that ID."
).format(**arg_dict)
else:
assert stream_name is not None
arg_dict = {
**arg_dict,
"stream_name": f"#**{stream_name}**",
"new_stream_link": "#streams/new",
"channel_name": f"#**{stream_name}**",
"new_channel_link": "#streams/new",
}
content = _(
"Your bot {bot_identity} tried to send a message to stream "
"{stream_name}, but that stream does not exist. "
"Click [here]({new_stream_link}) to create it."
"{channel_name}, but that stream does not exist. "
"Click [here]({new_channel_link}) to create it."
).format(**arg_dict)
else:
if num_subscribers_for_stream_id(stream.id) > 0:
return
arg_dict = {
**arg_dict,
"stream_name": f"#**{stream.name}**",
"channel_name": f"#**{stream.name}**",
}
content = _(
"Your bot {bot_identity} tried to send a message to "
"stream {stream_name}. The stream exists but "
"stream {channel_name}. The stream exists but "
"does not have any subscribers."
).format(**arg_dict)

View File

@@ -241,7 +241,7 @@ def do_unarchive_stream(
raise JsonableError(_("Stream is not currently deactivated"))
if Stream.objects.filter(realm=realm, name=new_name).exists():
raise JsonableError(
_("Stream named {stream_name} already exists").format(stream_name=new_name)
_("Stream named {channel_name} already exists").format(channel_name=new_name)
)
assert stream.recipient_id is not None
@@ -312,7 +312,7 @@ def do_unarchive_stream(
sender,
stream,
str(Realm.STREAM_EVENTS_NOTIFICATION_TOPIC_NAME),
_("Stream {stream_name} un-archived.").format(stream_name=new_name),
_("Stream {channel_name} un-archived.").format(channel_name=new_name),
)
@@ -1467,10 +1467,10 @@ def do_rename_stream(stream: Stream, new_name: str, user_profile: UserProfile) -
sender,
stream,
str(Realm.STREAM_EVENTS_NOTIFICATION_TOPIC_NAME),
_("{user_name} renamed stream {old_stream_name} to {new_stream_name}.").format(
_("{user_name} renamed stream {old_channel_name} to {new_channel_name}.").format(
user_name=silent_mention_syntax_for_user(user_profile),
old_stream_name=f"**{old_name}**",
new_stream_name=f"**{new_name}**",
old_channel_name=f"**{old_name}**",
new_channel_name=f"**{new_name}**",
),
)

View File

@@ -313,7 +313,7 @@ def access_stream_for_send_message(
# All other cases are an error.
raise JsonableError(
_("Not authorized to send to stream '{stream_name}'").format(stream_name=stream.name)
_("Not authorized to send to stream '{channel_name}'").format(channel_name=stream.name)
)
@@ -473,7 +473,7 @@ def check_stream_name_available(realm: Realm, name: str) -> None:
try:
get_stream(name, realm)
raise JsonableError(
_("Stream name '{stream_name}' is already taken.").format(stream_name=name)
_("Stream name '{channel_name}' is already taken.").format(channel_name=name)
)
except Stream.DoesNotExist:
pass
@@ -482,7 +482,7 @@ def check_stream_name_available(realm: Realm, name: str) -> None:
def access_stream_by_name(
user_profile: UserProfile, stream_name: str, allow_realm_admin: bool = False
) -> Tuple[Stream, Optional[Subscription]]:
error = _("Invalid stream name '{stream_name}'").format(stream_name=stream_name)
error = _("Invalid stream name '{channel_name}'").format(channel_name=stream_name)
try:
stream = get_realm_stream(stream_name, user_profile.realm_id)
except Stream.DoesNotExist:
@@ -602,7 +602,7 @@ def can_access_stream_history(user_profile: UserProfile, stream: Stream) -> bool
if stream.is_history_public_to_subscribers():
# In this case, we check if the user is subscribed.
error = _("Invalid stream name '{stream_name}'").format(stream_name=stream.name)
error = _("Invalid stream name '{channel_name}'").format(channel_name=stream.name)
try:
access_stream_common(user_profile, stream, error)
except JsonableError:
@@ -751,8 +751,8 @@ def list_to_streams(
if not autocreate:
raise JsonableError(
_("Stream(s) ({stream_names}) do not exist").format(
stream_names=", ".join(
_("Stream(s) ({channel_names}) do not exist").format(
channel_names=", ".join(
stream_dict["name"] for stream_dict in missing_stream_dicts
),
)

View File

@@ -84,8 +84,8 @@ def invite_users_backend(
(stream, sub) = access_stream_by_id(user_profile, stream_id)
except JsonableError:
raise JsonableError(
_("Stream does not exist with id: {stream_id}. No invites were sent.").format(
stream_id=stream_id
_("Stream does not exist with id: {channel_id}. No invites were sent.").format(
channel_id=stream_id
)
)
streams.append(stream)
@@ -221,8 +221,8 @@ def generate_multiuse_invite_backend(
(stream, sub) = access_stream_by_id(user_profile, stream_id)
except JsonableError:
raise JsonableError(
_("Invalid stream ID {stream_id}. No invites were sent.").format(
stream_id=stream_id
_("Invalid stream ID {channel_id}. No invites were sent.").format(
channel_id=stream_id
)
)
streams.append(stream)

View File

@@ -514,9 +514,9 @@ def you_were_just_subscribed_message(
subscriptions = sorted(stream_names)
if len(subscriptions) == 1:
with override_language(recipient_user.default_language):
return _("{user_full_name} subscribed you to the stream {stream_name}.").format(
return _("{user_full_name} subscribed you to the stream {channel_name}.").format(
user_full_name=f"@**{acting_user.full_name}|{acting_user.id}**",
stream_name=f"#**{subscriptions[0]}**",
channel_name=f"#**{subscriptions[0]}**",
)
with override_language(recipient_user.default_language):
@@ -524,8 +524,8 @@ def you_were_just_subscribed_message(
user_full_name=f"@**{acting_user.full_name}|{acting_user.id}**",
)
message += "\n\n"
for stream_name in subscriptions:
message += f"* #**{stream_name}**\n"
for channel_name in subscriptions:
message += f"* #**{channel_name}**\n"
return message
@@ -636,8 +636,8 @@ def add_subscriptions_backend(
)
if len(unauthorized_streams) > 0 and authorization_errors_fatal:
raise JsonableError(
_("Unable to access stream ({stream_name}).").format(
stream_name=unauthorized_streams[0].name,
_("Unable to access stream ({channel_name}).").format(
channel_name=unauthorized_streams[0].name,
)
)
# Newly created streams are also authorized for the creator
@@ -761,14 +761,14 @@ def send_messages_for_new_subscribers(
if new_stream_announcements_stream is not None:
with override_language(new_stream_announcements_stream.realm.default_language):
if len(created_streams) > 1:
content = _("{user_name} created the following streams: {stream_str}.")
content = _("{user_name} created the following streams: {new_channels}.")
else:
content = _("{user_name} created a new stream {stream_str}.")
content = _("{user_name} created a new stream {new_channels}.")
topic_name = _("new streams")
content = content.format(
user_name=silent_mention_syntax_for_user(user_profile),
stream_str=", ".join(f"#**{s.name}**" for s in created_streams),
new_channels=", ".join(f"#**{s.name}**" for s in created_streams),
)
sender = get_system_bot(
@@ -1016,7 +1016,7 @@ def update_subscription_properties_backend(
(stream, sub) = access_stream_by_id(user_profile, stream_id)
if sub is None:
raise JsonableError(
_("Not subscribed to stream id {stream_id}").format(stream_id=stream_id)
_("Not subscribed to stream id {channel_id}").format(channel_id=stream_id)
)
try: