[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:
Dav
2022-02-16 01:25:21 +00:00
committed by GitHub
parent 9ab307c1ef
commit c6517d5087
8 changed files with 111 additions and 90 deletions

View File

@@ -8,7 +8,7 @@ import discord
from redbot.core import checks, commands, modlog
from redbot.core.bot import Red
from redbot.core.i18n import Translator, cog_i18n
from redbot.core.utils.chat_formatting import box, pagify
from redbot.core.utils.chat_formatting import bold, box, pagify
from redbot.core.utils.menus import DEFAULT_CONTROLS, menu
from redbot.core.utils.predicates import MessagePredicate
@@ -40,10 +40,7 @@ class ModLog(commands.Cog):
if await ctx.embed_requested():
await ctx.send(embed=await case.message_content(embed=True))
else:
message = _("{case}\n**Timestamp:** {timestamp}").format(
case=await case.message_content(embed=False),
timestamp=f"<t:{int(case.created_at)}>",
)
message = f"{await case.message_content(embed=False)}\n{bold(_('Timestamp:'))} <t:{int(case.created_at)}>"
await ctx.send(message)
@commands.command()
@@ -76,10 +73,7 @@ class ModLog(commands.Cog):
else:
rendered_cases = []
for case in cases:
message = _("{case}\n**Timestamp:** {timestamp}").format(
case=await case.message_content(embed=False),
timestamp=f"<t:{int(case.created_at)}>",
)
message = f"{await case.message_content(embed=False)}\n{bold(_('Timestamp:'))} <t:{int(case.created_at)}>"
rendered_cases.append(message)
await menu(ctx, rendered_cases, DEFAULT_CONTROLS)
@@ -110,10 +104,7 @@ class ModLog(commands.Cog):
rendered_cases = []
message = ""
for case in cases:
message += _("{case}\n**Timestamp:** {timestamp}\n\n").format(
case=await case.message_content(embed=False),
timestamp=f"<t:{int(case.created_at)}>",
)
message += f"{await case.message_content(embed=False)}\n{bold(_('Timestamp:'))} <t:{int(case.created_at)}>"
for page in pagify(message, ["\n\n", "\n"], priority=True):
rendered_cases.append(page)
await menu(ctx, rendered_cases, DEFAULT_CONTROLS)