mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-05 17:02:32 -05:00
[Core/Core Cogs] Prevent translation errors and use formatting utils (#5435)
* Use proper syntax for inline formatting in core_commands * use proper formating utils in core and core cogs wherever reasonable * tests are awesome * ensure "(continued)" is translated in help.py * add colons to translatable strings for easier context comprehension by translators * Thx flame :) Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com> * good point Co-authored-by: Dav <dav@mail.stopdavabuse.de> Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>
This commit is contained in:
@@ -3,7 +3,7 @@ from redbot.core.bot import Red
|
||||
from redbot.core import checks, commands, Config
|
||||
from redbot.core.i18n import cog_i18n, Translator, set_contextual_locales_from_guild
|
||||
from redbot.core.utils._internal_utils import send_to_owners_with_prefix_replaced
|
||||
from redbot.core.utils.chat_formatting import escape, pagify
|
||||
from redbot.core.utils.chat_formatting import escape, inline, pagify
|
||||
|
||||
from .streamtypes import (
|
||||
PicartoStream,
|
||||
@@ -143,7 +143,7 @@ class Streams(commands.Cog):
|
||||
message = _(
|
||||
"You need a client secret key if you want to use the Twitch API on this cog.\n"
|
||||
"Follow these steps:\n"
|
||||
"1. Go to this page: https://dev.twitch.tv/console/apps.\n"
|
||||
"1. Go to this page: {link}.\n"
|
||||
'2. Click "Manage" on your application.\n'
|
||||
'3. Click on "New secret".\n'
|
||||
"5. Copy your client ID and your client secret into:\n"
|
||||
@@ -152,9 +152,12 @@ class Streams(commands.Cog):
|
||||
"Note: These tokens are sensitive and should only be used in a private channel "
|
||||
"or in DM with the bot."
|
||||
).format(
|
||||
command="`[p]set api twitch client_id {} client_secret {}`".format(
|
||||
_("<your_client_id_here>"), _("<your_client_secret_here>")
|
||||
)
|
||||
link="https://dev.twitch.tv/console/apps",
|
||||
command=inline(
|
||||
"[p]set api twitch client_id {} client_secret {}".format(
|
||||
_("<your_client_id_here>"), _("<your_client_secret_here>")
|
||||
)
|
||||
),
|
||||
)
|
||||
if notified_owner_missing_twitch_secret is False:
|
||||
await send_to_owners_with_prefix_replaced(self.bot, message)
|
||||
@@ -258,14 +261,14 @@ class Streams(commands.Cog):
|
||||
except InvalidTwitchCredentials:
|
||||
await ctx.send(
|
||||
_("The Twitch token is either invalid or has not been set. See {command}.").format(
|
||||
command=f"`{ctx.clean_prefix}streamset twitchtoken`"
|
||||
command=inline(f"{ctx.clean_prefix}streamset twitchtoken")
|
||||
)
|
||||
)
|
||||
except InvalidYoutubeCredentials:
|
||||
await ctx.send(
|
||||
_(
|
||||
"The YouTube API key is either invalid or has not been set. See {command}."
|
||||
).format(command=f"`{ctx.clean_prefix}streamset youtubekey`")
|
||||
).format(command=inline(f"{ctx.clean_prefix}streamset youtubekey"))
|
||||
)
|
||||
except YoutubeQuotaExceeded:
|
||||
await ctx.send(
|
||||
@@ -416,7 +419,7 @@ class Streams(commands.Cog):
|
||||
await ctx.send(
|
||||
_(
|
||||
"The Twitch token is either invalid or has not been set. See {command}."
|
||||
).format(command=f"`{ctx.clean_prefix}streamset twitchtoken`")
|
||||
).format(command=inline(f"{ctx.clean_prefix}streamset twitchtoken"))
|
||||
)
|
||||
return
|
||||
except InvalidYoutubeCredentials:
|
||||
@@ -424,7 +427,7 @@ class Streams(commands.Cog):
|
||||
_(
|
||||
"The YouTube API key is either invalid or has not been set. See "
|
||||
"{command}."
|
||||
).format(command=f"`{ctx.clean_prefix}streamset youtubekey`")
|
||||
).format(command=inline(f"{ctx.clean_prefix}streamset youtubekey"))
|
||||
)
|
||||
return
|
||||
except YoutubeQuotaExceeded:
|
||||
@@ -475,9 +478,9 @@ class Streams(commands.Cog):
|
||||
"""Explain how to set the twitch token."""
|
||||
message = _(
|
||||
"To set the twitch API tokens, follow these steps:\n"
|
||||
"1. Go to this page: https://dev.twitch.tv/dashboard/apps.\n"
|
||||
"1. Go to this page: {link}.\n"
|
||||
"2. Click *Register Your Application*.\n"
|
||||
"3. Enter a name, set the OAuth Redirect URI to `http://localhost`, and "
|
||||
"3. Enter a name, set the OAuth Redirect URI to {localhost}, and "
|
||||
"select an Application Category of your choosing.\n"
|
||||
"4. Click *Register*.\n"
|
||||
"5. Copy your client ID and your client secret into:\n"
|
||||
@@ -486,9 +489,11 @@ class Streams(commands.Cog):
|
||||
"Note: These tokens are sensitive and should only be used in a private channel\n"
|
||||
"or in DM with the bot.\n"
|
||||
).format(
|
||||
link="https://dev.twitch.tv/dashboard/apps",
|
||||
localhost=inline("http://localhost"),
|
||||
command="`{}set api twitch client_id {} client_secret {}`".format(
|
||||
ctx.clean_prefix, _("<your_client_id_here>"), _("<your_client_secret_here>")
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
await ctx.maybe_send_embed(message)
|
||||
@@ -501,19 +506,22 @@ class Streams(commands.Cog):
|
||||
message = _(
|
||||
"To get one, do the following:\n"
|
||||
"1. Create a project\n"
|
||||
"(see https://support.google.com/googleapi/answer/6251787 for details)\n"
|
||||
"(see {link1} for details)\n"
|
||||
"2. Enable the YouTube Data API v3 \n"
|
||||
"(see https://support.google.com/googleapi/answer/6158841 for instructions)\n"
|
||||
"(see {link2} for instructions)\n"
|
||||
"3. Set up your API key \n"
|
||||
"(see https://support.google.com/googleapi/answer/6158862 for instructions)\n"
|
||||
"(see {link3} for instructions)\n"
|
||||
"4. Copy your API key and run the command "
|
||||
"{command}\n\n"
|
||||
"Note: These tokens are sensitive and should only be used in a private channel\n"
|
||||
"or in DM with the bot.\n"
|
||||
).format(
|
||||
link1="https://support.google.com/googleapi/answer/6251787",
|
||||
link2="https://support.google.com/googleapi/answer/6158841",
|
||||
link3="https://support.google.com/googleapi/answer/6158862",
|
||||
command="`{}set api youtube api_key {}`".format(
|
||||
ctx.clean_prefix, _("<your_api_key_here>")
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
await ctx.maybe_send_embed(message)
|
||||
@@ -576,10 +584,18 @@ class Streams(commands.Cog):
|
||||
current_setting = await self.config.guild(guild).mention_everyone()
|
||||
if current_setting:
|
||||
await self.config.guild(guild).mention_everyone.set(False)
|
||||
await ctx.send(_("`@\u200beveryone` will no longer be mentioned for stream alerts."))
|
||||
await ctx.send(
|
||||
_("{everyone} will no longer be mentioned for stream alerts.").format(
|
||||
everyone=inline("@\u200beveryone")
|
||||
)
|
||||
)
|
||||
else:
|
||||
await self.config.guild(guild).mention_everyone.set(True)
|
||||
await ctx.send(_("When a stream is live, `@\u200beveryone` will be mentioned."))
|
||||
await ctx.send(
|
||||
_("When a stream is live, {everyone} will be mentioned.").format(
|
||||
everyone=inline("@\u200beveryone")
|
||||
)
|
||||
)
|
||||
|
||||
@mention.command(aliases=["here"])
|
||||
@commands.guild_only()
|
||||
@@ -589,10 +605,18 @@ class Streams(commands.Cog):
|
||||
current_setting = await self.config.guild(guild).mention_here()
|
||||
if current_setting:
|
||||
await self.config.guild(guild).mention_here.set(False)
|
||||
await ctx.send(_("`@\u200bhere` will no longer be mentioned for stream alerts."))
|
||||
await ctx.send(
|
||||
_("{here} will no longer be mentioned for stream alerts.").format(
|
||||
here=inline("@\u200bhere")
|
||||
)
|
||||
)
|
||||
else:
|
||||
await self.config.guild(guild).mention_here.set(True)
|
||||
await ctx.send(_("When a stream is live, `@\u200bhere` will be mentioned."))
|
||||
await ctx.send(
|
||||
_("When a stream is live, {here} will be mentioned.").format(
|
||||
here=inline("@\u200bhere")
|
||||
)
|
||||
)
|
||||
|
||||
@mention.command()
|
||||
@commands.guild_only()
|
||||
@@ -602,15 +626,15 @@ class Streams(commands.Cog):
|
||||
if current_setting:
|
||||
await self.config.role(role).mention.set(False)
|
||||
await ctx.send(
|
||||
_("`@\u200b{role.name}` will no longer be mentioned for stream alerts.").format(
|
||||
role=role
|
||||
_("{role} will no longer be mentioned for stream alerts.").format(
|
||||
role=inline(f"@\u200b{role.name}")
|
||||
)
|
||||
)
|
||||
else:
|
||||
await self.config.role(role).mention.set(True)
|
||||
msg = _(
|
||||
"When a stream or community is live, `@\u200b{role.name}` will be mentioned."
|
||||
).format(role=role)
|
||||
msg = _("When a stream or community is live, {role} will be mentioned.").format(
|
||||
role=inline(f"@\u200b{role.name}")
|
||||
)
|
||||
if not role.mentionable:
|
||||
msg += " " + _(
|
||||
"Since the role is not mentionable, it will be momentarily made mentionable "
|
||||
|
||||
Reference in New Issue
Block a user