mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[V3 Customcom] i18n support (fix Cog-Creators/Red-DiscordBot/issues/1018) (#1065)
This commit is contained in:
parent
ad0c75866f
commit
edabd07719
@ -7,7 +7,10 @@ import discord
|
|||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
from redbot.core import Config, checks
|
from redbot.core import Config, checks
|
||||||
from redbot.core.utils.chat_formatting import box
|
from redbot.core.utils.chat_formatting import box, pagify
|
||||||
|
from redbot.core.i18n import CogI18n
|
||||||
|
|
||||||
|
_ = CogI18n("CustomCommands", __file__)
|
||||||
|
|
||||||
|
|
||||||
class CCError(Exception):
|
class CCError(Exception):
|
||||||
@ -38,17 +41,19 @@ class CommandObj:
|
|||||||
return customcommands
|
return customcommands
|
||||||
|
|
||||||
async def get_responses(self, ctx):
|
async def get_responses(self, ctx):
|
||||||
intro = ("Welcome to the interactive random customcommand maker!\n"
|
intro = (_("Welcome to the interactive random {} maker!\n"
|
||||||
"Every message you send will be added as one of the random "
|
"Every message you send will be added as one of the random "
|
||||||
"response to choose from once this customcommand is "
|
"response to choose from once this {} is "
|
||||||
"triggered. To exit this interactive menu, type `exit()`")
|
"triggered. To exit this interactive menu, type `{}`").format(
|
||||||
|
"customcommand", "customcommand", "exit()"
|
||||||
|
))
|
||||||
await ctx.send(intro)
|
await ctx.send(intro)
|
||||||
|
|
||||||
def check(m):
|
def check(m):
|
||||||
return m.channel == ctx.channel and m.author == ctx.message.author
|
return m.channel == ctx.channel and m.author == ctx.message.author
|
||||||
responses = []
|
responses = []
|
||||||
while True:
|
while True:
|
||||||
await ctx.send("Add a random response:")
|
await ctx.send(_("Add a random response:"))
|
||||||
msg = await self.bot.wait_for('message', check=check)
|
msg = await self.bot.wait_for('message', check=check)
|
||||||
|
|
||||||
if msg.content.lower() == 'exit()':
|
if msg.content.lower() == 'exit()':
|
||||||
@ -110,13 +115,15 @@ class CommandObj:
|
|||||||
return m.channel == ctx.channel and m.author == ctx.message.author
|
return m.channel == ctx.channel and m.author == ctx.message.author
|
||||||
|
|
||||||
if not response:
|
if not response:
|
||||||
await ctx.send("Do you want to create a 'randomized' cc? y/n")
|
await ctx.send(
|
||||||
|
_("Do you want to create a 'randomized' cc? {}").format("y/n")
|
||||||
|
)
|
||||||
|
|
||||||
msg = await self.bot.wait_for('message', check=check)
|
msg = await self.bot.wait_for('message', check=check)
|
||||||
if msg.content.lower() == 'y':
|
if msg.content.lower() == 'y':
|
||||||
response = await self.get_responses(ctx=ctx)
|
response = await self.get_responses(ctx=ctx)
|
||||||
else:
|
else:
|
||||||
await ctx.send("What response do you want?")
|
await ctx.send(_("What response do you want?"))
|
||||||
response = (await self.bot.wait_for(
|
response = (await self.bot.wait_for(
|
||||||
'message', check=check)
|
'message', check=check)
|
||||||
).content
|
).content
|
||||||
@ -195,11 +202,13 @@ class CustomCommands:
|
|||||||
await self.commandobj.create(ctx=ctx,
|
await self.commandobj.create(ctx=ctx,
|
||||||
command=command,
|
command=command,
|
||||||
response=responses)
|
response=responses)
|
||||||
await ctx.send("Custom command successfully added.")
|
await ctx.send(_("Custom command successfully added."))
|
||||||
except AlreadyExists:
|
except AlreadyExists:
|
||||||
await ctx.send("This command already exists. Use "
|
await ctx.send(_(
|
||||||
"`{}customcom edit` to edit it."
|
"This command already exists. Use "
|
||||||
"".format(ctx.prefix))
|
"`{}` to edit it.").format(
|
||||||
|
"{}customcom edit".format(ctx.prefix)
|
||||||
|
))
|
||||||
|
|
||||||
# await ctx.send(str(responses))
|
# await ctx.send(str(responses))
|
||||||
|
|
||||||
@ -217,17 +226,19 @@ class CustomCommands:
|
|||||||
guild = ctx.guild
|
guild = ctx.guild
|
||||||
command = command.lower()
|
command = command.lower()
|
||||||
if command in self.bot.all_commands:
|
if command in self.bot.all_commands:
|
||||||
await ctx.send("That command is already a standard command.")
|
await ctx.send(_("That command is already a standard command."))
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
await self.commandobj.create(ctx=ctx,
|
await self.commandobj.create(ctx=ctx,
|
||||||
command=command,
|
command=command,
|
||||||
response=text)
|
response=text)
|
||||||
await ctx.send("Custom command successfully added.")
|
await ctx.send(_("Custom command successfully added."))
|
||||||
except AlreadyExists:
|
except AlreadyExists:
|
||||||
await ctx.send("This command already exists. Use "
|
await ctx.send(_(
|
||||||
"`{}customcom edit` to edit it."
|
"This command already exists. Use "
|
||||||
"".format(ctx.prefix))
|
"`{}` to edit it.").format(
|
||||||
|
"{}customcom edit".format(ctx.prefix)
|
||||||
|
))
|
||||||
|
|
||||||
@customcom.command(name="edit")
|
@customcom.command(name="edit")
|
||||||
@checks.mod_or_permissions(administrator=True)
|
@checks.mod_or_permissions(administrator=True)
|
||||||
@ -247,11 +258,13 @@ class CustomCommands:
|
|||||||
await self.commandobj.edit(ctx=ctx,
|
await self.commandobj.edit(ctx=ctx,
|
||||||
command=command,
|
command=command,
|
||||||
response=text)
|
response=text)
|
||||||
await ctx.send("Custom command successfully edited.")
|
await ctx.send(_("Custom command successfully edited."))
|
||||||
except NotFound:
|
except NotFound:
|
||||||
await ctx.send("That command doesn't exist. Use "
|
await ctx.send(_(
|
||||||
"`{}customcom add` to add it."
|
"That command doesn't exist. Use "
|
||||||
"".format(ctx.prefix))
|
"`{}` to add it.").format(
|
||||||
|
"{}customcom add".format(ctx.prefix)
|
||||||
|
))
|
||||||
|
|
||||||
@customcom.command(name="delete")
|
@customcom.command(name="delete")
|
||||||
@checks.mod_or_permissions(administrator=True)
|
@checks.mod_or_permissions(administrator=True)
|
||||||
@ -266,9 +279,9 @@ class CustomCommands:
|
|||||||
try:
|
try:
|
||||||
await self.commandobj.delete(ctx=ctx,
|
await self.commandobj.delete(ctx=ctx,
|
||||||
command=command)
|
command=command)
|
||||||
await ctx.send("Custom command successfully deleted.")
|
await ctx.send(_("Custom command successfully deleted."))
|
||||||
except NotFound:
|
except NotFound:
|
||||||
await ctx.send("That command doesn't exist.")
|
await ctx.send(_("That command doesn't exist."))
|
||||||
|
|
||||||
@customcom.command(name="list")
|
@customcom.command(name="list")
|
||||||
async def cc_list(self,
|
async def cc_list(self,
|
||||||
@ -278,9 +291,11 @@ class CustomCommands:
|
|||||||
response = await CommandObj.get_commands(self.config.guild(ctx.guild))
|
response = await CommandObj.get_commands(self.config.guild(ctx.guild))
|
||||||
|
|
||||||
if not response:
|
if not response:
|
||||||
await ctx.send("There are no custom commands in this guild."
|
await ctx.send(_(
|
||||||
" Use `{}customcom add` to start adding some."
|
"There are no custom commands in this guild."
|
||||||
"".format(ctx.prefix))
|
" Use `{}` to start adding some.").format(
|
||||||
|
"{}customcom add".format(ctx.prefix)
|
||||||
|
))
|
||||||
return
|
return
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
|
|||||||
67
redbot/cogs/customcom/locales/messages.pot
Normal file
67
redbot/cogs/customcom/locales/messages.pot
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# SOME DESCRIPTIVE TITLE.
|
||||||
|
# Copyright (C) YEAR ORGANIZATION
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
|
"POT-Creation-Date: 2017-10-27 19:40-0800\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=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Generated-By: pygettext.py 1.5\n"
|
||||||
|
|
||||||
|
|
||||||
|
#: customcom.py:44
|
||||||
|
msgid ""
|
||||||
|
"Welcome to the interactive random {} maker!\n"
|
||||||
|
"Every message you send will be added as one of the random response to choose from once this {} is triggered. To exit this interactive menu, type `{}`"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: customcom.py:56
|
||||||
|
msgid "Add a random response:"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: customcom.py:119
|
||||||
|
msgid "Do you want to create a 'randomized' cc? {}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: customcom.py:126
|
||||||
|
msgid "What response do you want?"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: customcom.py:205 customcom.py:235
|
||||||
|
msgid "Custom command successfully added."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: customcom.py:207 customcom.py:237
|
||||||
|
msgid "This command already exists. Use `{}` to edit it."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: customcom.py:229
|
||||||
|
msgid "That command is already a standard command."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: customcom.py:261
|
||||||
|
msgid "Custom command successfully edited."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: customcom.py:263
|
||||||
|
msgid "That command doesn't exist. Use `{}` to add it."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: customcom.py:282
|
||||||
|
msgid "Custom command successfully deleted."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: customcom.py:284
|
||||||
|
msgid "That command doesn't exist."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: customcom.py:294
|
||||||
|
msgid "There are no custom commands in this guild. Use `{}` to start adding some."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user