From ea0f1ee25f16a41ff392d94dab712ba53402e392 Mon Sep 17 00:00:00 2001 From: cod Date: Fri, 8 Feb 2019 00:24:58 +0900 Subject: [PATCH] [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 --- discord/ext/commands/formatter.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/discord/ext/commands/formatter.py b/discord/ext/commands/formatter.py index 396eb3597..1ead32c4b 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