aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcod <[email protected]>2019-02-08 00:24:58 +0900
committerRapptz <[email protected]>2019-02-14 20:21:06 -0500
commitea0f1ee25f16a41ff392d94dab712ba53402e392 (patch)
tree1f6eb9677e5b8003bd5f3bcefb4e555c648a9d49
parentFix missing imports (diff)
downloaddiscord.py-ea0f1ee25f16a41ff392d94dab712ba53402e392.tar.xz
discord.py-ea0f1ee25f16a41ff392d94dab712ba53402e392.zip
[commands] Add more i18n properties for HelpFormatter
removed fixed strings "Commands:" and help page ending note. and added properties modify these strings. default behavior is not changed. fix #1886
-rw-r--r--discord/ext/commands/formatter.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/discord/ext/commands/formatter.py b/discord/ext/commands/formatter.py
index 396eb359..1ead32c4 100644
--- a/discord/ext/commands/formatter.py
+++ b/discord/ext/commands/formatter.py
@@ -142,11 +142,20 @@ class HelpFormatter:
width: :class:`int`
The maximum number of characters that fit in a line.
Defaults to 80.
+ commands_heading: :class:`str`
+ The command list's heading string used when the help command is invoked with a category name.
+ Useful for i18n. Defaults to ``"Commands:"``
+ no_category: :class:`str`
+ The string used when there is a command which does not belong to any category(cog).
+ Useful for i18n. Defaults to ``"No Category"``
"""
- def __init__(self, show_hidden=False, show_check_failure=False, width=80):
+ def __init__(self, show_hidden=False, show_check_failure=False, width=80,
+ commands_heading="Commands:", no_category="No Category"):
self.width = width
self.show_hidden = show_hidden
self.show_check_failure = show_check_failure
+ self.commands_heading = commands_heading
+ self.no_category = no_category
def has_subcommands(self):
""":class:`bool`: Specifies if the command has subcommands."""
@@ -317,7 +326,7 @@ class HelpFormatter:
cog = tup[1].cog_name
# we insert the zero width space there to give it approximate
# last place sorting position.
- return cog + ':' if cog is not None else '\u200bNo Category:'
+ return cog + ':' if cog is not None else '\u200b' + self.no_category + ':'
filtered = await self.filter_command_list()
if self.is_bot():
@@ -332,7 +341,7 @@ class HelpFormatter:
else:
filtered = sorted(filtered)
if filtered:
- self._paginator.add_line('Commands:')
+ self._paginator.add_line(self.commands_heading)
self._add_subcommands_to_page(max_width, filtered)
# add the ending note