[i18n] Fix some missing i18n strings in the whole bot (#2633)

This commit is contained in:
PredaaA
2019-06-29 17:13:53 +02:00
committed by Toby Harradine
parent 8a72840de0
commit 03fe3ee720
8 changed files with 56 additions and 39 deletions

View File

@@ -183,7 +183,9 @@ class Streams(commands.Cog):
async def twitch_alert_channel(self, ctx: commands.Context, channel_name: str):
"""Toggle alerts in this channel for a Twitch stream."""
if re.fullmatch(r"<#\d+>", channel_name):
await ctx.send("Please supply the name of a *Twitch* channel, not a Discord channel.")
await ctx.send(
_("Please supply the name of a *Twitch* channel, not a Discord channel.")
)
return
await self.stream_alert(ctx, TwitchStream, channel_name.lower())
@@ -374,7 +376,7 @@ class Streams(commands.Cog):
if message is not None:
guild = ctx.guild
await self.db.guild(guild).live_message_mention.set(message)
await ctx.send(_("stream alert message set!"))
await ctx.send(_("Stream alert message set!"))
else:
await ctx.send_help()
@@ -390,7 +392,7 @@ class Streams(commands.Cog):
if message is not None:
guild = ctx.guild
await self.db.guild(guild).live_message_nomention.set(message)
await ctx.send(_("stream alert message set!"))
await ctx.send(_("Stream alert message set!"))
else:
await ctx.send_help()

View File

@@ -5,6 +5,7 @@ from .errors import (
InvalidYoutubeCredentials,
InvalidTwitchCredentials,
)
from redbot.core.i18n import Translator
from random import choice, sample
from string import ascii_letters
from typing import ClassVar, Optional
@@ -22,6 +23,8 @@ YOUTUBE_CHANNELS_ENDPOINT = YOUTUBE_BASE_URL + "/channels"
YOUTUBE_SEARCH_ENDPOINT = YOUTUBE_BASE_URL + "/search"
YOUTUBE_VIDEOS_ENDPOINT = YOUTUBE_BASE_URL + "/videos"
_ = Translator("Streams", __file__)
def rnd(url):
"""Appends a random parameter to the url to avoid Discord's caching"""
@@ -217,13 +220,13 @@ class TwitchStream(Stream):
status += " - Rerun"
embed = discord.Embed(title=status, url=url, color=0x6441A4)
embed.set_author(name=channel["display_name"])
embed.add_field(name="Followers", value=channel["followers"])
embed.add_field(name="Total views", value=channel["views"])
embed.add_field(name=_("Followers"), value=channel["followers"])
embed.add_field(name=_("Total views"), value=channel["views"])
embed.set_thumbnail(url=logo)
if data["stream"]["preview"]["medium"]:
embed.set_image(url=rnd(data["stream"]["preview"]["medium"]))
if channel["game"]:
embed.set_footer(text="Playing: " + channel["game"])
embed.set_footer(text=_("Playing: ") + channel["game"])
return embed
@@ -261,11 +264,11 @@ class HitboxStream(Stream):
url = channel["channel_link"]
embed = discord.Embed(title=livestream["media_status"], url=url, color=0x98CB00)
embed.set_author(name=livestream["media_name"])
embed.add_field(name="Followers", value=channel["followers"])
embed.add_field(name=_("Followers"), value=channel["followers"])
embed.set_thumbnail(url=base_url + channel["user_logo"])
if livestream["media_thumbnail"]:
embed.set_image(url=rnd(base_url + livestream["media_thumbnail"]))
embed.set_footer(text="Playing: " + livestream["category_name"])
embed.set_footer(text=_("Playing: ") + livestream["category_name"])
return embed
@@ -300,8 +303,8 @@ class MixerStream(Stream):
url = "https://mixer.com/" + data["token"]
embed = discord.Embed(title=data["name"], url=url)
embed.set_author(name=user["username"])
embed.add_field(name="Followers", value=data["numFollowers"])
embed.add_field(name="Total views", value=data["viewersTotal"])
embed.add_field(name=_("Followers"), value=data["numFollowers"])
embed.add_field(name=_("Total views"), value=data["viewersTotal"])
if user["avatarUrl"]:
embed.set_thumbnail(url=user["avatarUrl"])
else:
@@ -310,7 +313,7 @@ class MixerStream(Stream):
embed.set_image(url=rnd(data["thumbnail"]["url"]))
embed.color = 0x4C90F3 # pylint: disable=assigning-non-slot
if data["type"] is not None:
embed.set_footer(text="Playing: " + data["type"]["name"])
embed.set_footer(text=_("Playing: ") + data["type"]["name"])
return embed
@@ -346,18 +349,18 @@ class PicartoStream(Stream):
embed = discord.Embed(title=data["title"], url=url, color=0x4C90F3)
embed.set_author(name=data["name"])
embed.set_image(url=rnd(thumbnail))
embed.add_field(name="Followers", value=data["followers"])
embed.add_field(name="Total views", value=data["viewers_total"])
embed.add_field(name=_("Followers"), value=data["followers"])
embed.add_field(name=_("Total views"), value=data["viewers_total"])
embed.set_thumbnail(url=avatar)
data["tags"] = ", ".join(data["tags"])
if not data["tags"]:
data["tags"] = "None"
data["tags"] = _("None")
if data["adult"]:
data["adult"] = "NSFW | "
data["adult"] = _("NSFW | ")
else:
data["adult"] = ""
embed.set_footer(text="{adult}Category: {category} | Tags: {tags}".format(**data))
embed.set_footer(text=_("{adult}Category: {category} | Tags: {tags}").format(**data))
return embed