mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-20 16:00:29 +00:00
[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
This commit is contained in:
parent
60f9ac3062
commit
ea0f1ee25f
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user