mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-07 01:42:30 -05:00
[i18n] Basic Implementation (#948)
* Initial commit * Beginning of working i18n * Add some translation files * Add more strings to translate * Update and add some more translations * Update spanish translation * Update french translation * Add alias translation templates * Add bank translations * Add economy translations * Add general translations * Add image translations * Add core translations
This commit is contained in:
@@ -6,8 +6,11 @@ from typing import Generator, Tuple, Iterable
|
||||
from core import Config
|
||||
from core.bot import Red
|
||||
from core.utils.chat_formatting import box
|
||||
from core.i18n import CogI18n
|
||||
from .alias_entry import AliasEntry
|
||||
|
||||
_ = CogI18n("Alias", __file__)
|
||||
|
||||
|
||||
class Alias:
|
||||
"""
|
||||
@@ -132,7 +135,7 @@ class Alias:
|
||||
for p in prefixes:
|
||||
if content.startswith(p):
|
||||
return p
|
||||
raise ValueError("No prefix found.")
|
||||
raise ValueError(_("No prefix found."))
|
||||
|
||||
def get_extra_args_from_alias(self, message: discord.Message, prefix: str,
|
||||
alias: AliasEntry) -> str:
|
||||
@@ -228,8 +231,8 @@ class Alias:
|
||||
|
||||
await self.add_alias(ctx, alias_name, command)
|
||||
|
||||
await ctx.send(("A new alias with the trigger `{}`"
|
||||
" has been created.").format(alias_name))
|
||||
await ctx.send(_("A new alias with the trigger `{}`"
|
||||
" has been created.").format(alias_name))
|
||||
|
||||
@global_.command(name="add")
|
||||
async def _add_global_alias(self, ctx: commands.Context,
|
||||
@@ -264,8 +267,8 @@ class Alias:
|
||||
|
||||
await self.add_alias(ctx, alias_name, command, global_=True)
|
||||
|
||||
await ctx.send(("A new global alias with the trigger `{}`"
|
||||
" has been created.").format(alias_name))
|
||||
await ctx.send(_("A new global alias with the trigger `{}`"
|
||||
" has been created.").format(alias_name))
|
||||
|
||||
@alias.command(name="help")
|
||||
@commands.guild_only()
|
||||
@@ -279,7 +282,7 @@ class Alias:
|
||||
new_msg.content = "{}help {}".format(ctx.prefix, base_cmd)
|
||||
await self.bot.process_commands(new_msg)
|
||||
else:
|
||||
ctx.send("No such alias exists.")
|
||||
ctx.send(_("No such alias exists."))
|
||||
|
||||
@alias.command(name="show")
|
||||
@commands.guild_only()
|
||||
@@ -288,10 +291,10 @@ class Alias:
|
||||
is_alias, alias = await self.is_alias(ctx.guild, alias_name)
|
||||
|
||||
if is_alias:
|
||||
await ctx.send(("The `{}` alias will execute the"
|
||||
" command `{}`").format(alias_name, alias.command))
|
||||
await ctx.send(_("The `{}` alias will execute the"
|
||||
" command `{}`").format(alias_name, alias.command))
|
||||
else:
|
||||
await ctx.send("There is no alias with the name `{}`".format(alias_name))
|
||||
await ctx.send(_("There is no alias with the name `{}`").format(alias_name))
|
||||
|
||||
@alias.command(name="del")
|
||||
@commands.guild_only()
|
||||
@@ -303,14 +306,14 @@ class Alias:
|
||||
try:
|
||||
next(aliases)
|
||||
except StopIteration:
|
||||
await ctx.send("There are no aliases on this guild.")
|
||||
await ctx.send(_("There are no aliases on this guild."))
|
||||
return
|
||||
|
||||
if await self.delete_alias(ctx, alias_name):
|
||||
await ctx.send(("Alias with the name `{}` was successfully"
|
||||
" deleted.").format(alias_name))
|
||||
await ctx.send(_("Alias with the name `{}` was successfully"
|
||||
" deleted.").format(alias_name))
|
||||
else:
|
||||
await ctx.send("Alias with name `{}` was not found.".format(alias_name))
|
||||
await ctx.send(_("Alias with name `{}` was not found.").format(alias_name))
|
||||
|
||||
@global_.command(name="del")
|
||||
async def _del_global_alias(self, ctx: commands.Context, alias_name: str):
|
||||
@@ -321,14 +324,14 @@ class Alias:
|
||||
try:
|
||||
next(aliases)
|
||||
except StopIteration:
|
||||
await ctx.send("There are no aliases on this bot.")
|
||||
await ctx.send(_("There are no aliases on this bot."))
|
||||
return
|
||||
|
||||
if await self.delete_alias(ctx, alias_name, global_=True):
|
||||
await ctx.send(("Alias with the name `{}` was successfully"
|
||||
" deleted.").format(alias_name))
|
||||
await ctx.send(_("Alias with the name `{}` was successfully"
|
||||
" deleted.").format(alias_name))
|
||||
else:
|
||||
await ctx.send("Alias with name `{}` was not found.".format(alias_name))
|
||||
await ctx.send(_("Alias with name `{}` was not found.").format(alias_name))
|
||||
|
||||
@alias.command(name="list")
|
||||
@commands.guild_only()
|
||||
@@ -336,9 +339,9 @@ class Alias:
|
||||
"""
|
||||
Lists the available aliases on this server.
|
||||
"""
|
||||
names = ["Aliases:", ] + sorted(["+ " + a.name for a in (await self.unloaded_aliases(ctx.guild))])
|
||||
names = [_("Aliases:"), ] + sorted(["+ " + a.name for a in (await self.unloaded_aliases(ctx.guild))])
|
||||
if len(names) == 0:
|
||||
await ctx.send("There are no aliases on this server.")
|
||||
await ctx.send(_("There are no aliases on this server."))
|
||||
else:
|
||||
await ctx.send(box("\n".join(names), "diff"))
|
||||
|
||||
@@ -347,9 +350,9 @@ class Alias:
|
||||
"""
|
||||
Lists the available global aliases on this bot.
|
||||
"""
|
||||
names = ["Aliases:", ] + sorted(["+ " + a.name for a in await self.unloaded_global_aliases()])
|
||||
names = [_("Aliases:"), ] + sorted(["+ " + a.name for a in await self.unloaded_global_aliases()])
|
||||
if len(names) == 0:
|
||||
await ctx.send("There are no aliases on this server.")
|
||||
await ctx.send(_("There are no aliases on this server."))
|
||||
else:
|
||||
await ctx.send(box("\n".join(names), "diff"))
|
||||
|
||||
|
||||
65
cogs/alias/locales/messages.pot
Normal file
65
cogs/alias/locales/messages.pot
Normal file
@@ -0,0 +1,65 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2017-08-26 17:23+EDT\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: ENCODING\n"
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
|
||||
|
||||
#: ../alias.py:138
|
||||
msgid "No prefix found."
|
||||
msgstr ""
|
||||
|
||||
#: ../alias.py:234
|
||||
msgid "A new alias with the trigger `{}` has been created."
|
||||
msgstr ""
|
||||
|
||||
#: ../alias.py:270
|
||||
msgid "A new global alias with the trigger `{}` has been created."
|
||||
msgstr ""
|
||||
|
||||
#: ../alias.py:285
|
||||
msgid "No such alias exists."
|
||||
msgstr ""
|
||||
|
||||
#: ../alias.py:294
|
||||
msgid "The `{}` alias will execute the command `{}`"
|
||||
msgstr ""
|
||||
|
||||
#: ../alias.py:297
|
||||
msgid "There is no alias with the name `{}`"
|
||||
msgstr ""
|
||||
|
||||
#: ../alias.py:309
|
||||
msgid "There are no aliases on this guild."
|
||||
msgstr ""
|
||||
|
||||
#: ../alias.py:313 ../alias.py:331
|
||||
msgid "Alias with the name `{}` was successfully deleted."
|
||||
msgstr ""
|
||||
|
||||
#: ../alias.py:316 ../alias.py:334
|
||||
msgid "Alias with name `{}` was not found."
|
||||
msgstr ""
|
||||
|
||||
#: ../alias.py:327
|
||||
msgid "There are no aliases on this bot."
|
||||
msgstr ""
|
||||
|
||||
#: ../alias.py:342 ../alias.py:353
|
||||
msgid "Aliases:"
|
||||
msgstr ""
|
||||
|
||||
#: ../alias.py:344 ../alias.py:355
|
||||
msgid "There are no aliases on this server."
|
||||
msgstr ""
|
||||
|
||||
Reference in New Issue
Block a user