mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-07 09:52:30 -05:00
[V3 i18n] Internationalise help for commands and cogs (#1143)
* Framework for internationalised command help * Translator for class docstring of cog * Remove references to old context module * Use CogManagerUI as PoC * Replace all references to RedContext * Rename CogI18n object to avoid confusion * Update docs * Update i18n docs. * Store translators in list instead of dict * Change commands module to package, updated refs in cogs * Updated docs and more references in cogs * Resolve syntax error * Update from merge
This commit is contained in:
@@ -28,7 +28,6 @@ from collections import namedtuple
|
||||
from typing import List
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import formatter
|
||||
import inspect
|
||||
import itertools
|
||||
@@ -36,6 +35,8 @@ import re
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from . import commands
|
||||
|
||||
|
||||
EMPTY_STRING = u'\u200b'
|
||||
|
||||
@@ -133,7 +134,12 @@ class Help(formatter.HelpFormatter):
|
||||
'fields': []
|
||||
}
|
||||
|
||||
description = self.command.description if not self.is_cog() else inspect.getdoc(self.command)
|
||||
if self.is_cog():
|
||||
translator = getattr(self.command, '__translator__', lambda s: s)
|
||||
description = inspect.cleandoc(translator(self.command.__doc__))
|
||||
else:
|
||||
description = self.command.description
|
||||
|
||||
if not description == '' and description is not None:
|
||||
description = '*{0}*'.format(description)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user