mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 11:12:47 +01:00
Fix internationalization of docstrings of wrap()ed commands.
This commit is contained in:
parent
e1f9d68870
commit
3e35113e02
@ -1071,7 +1071,6 @@ def _wrap(f, specList=[], name=None, checkDoc=True, **kw):
|
||||
name = name or f.func_name
|
||||
assert (not checkDoc) or (hasattr(f, '__doc__') and f.__doc__), \
|
||||
'Command %r has no docstring.' % name
|
||||
f = internationalizeDocstring(f)
|
||||
spec = Spec(specList, **kw)
|
||||
def newf(self, irc, msg, args, **kwargs):
|
||||
state = spec(irc, msg, args, stateAttrs={'cb': self, 'log': self.log})
|
||||
@ -1090,7 +1089,8 @@ def _wrap(f, specList=[], name=None, checkDoc=True, **kw):
|
||||
self.log.debug('Make sure you did not wrap a wrapped '
|
||||
'function ;)')
|
||||
raise
|
||||
return utils.python.changeFunctionName(newf, name, f.__doc__)
|
||||
newf2 = utils.python.changeFunctionName(newf, name, f.__doc__)
|
||||
return internationalizeDocstring(newf2)
|
||||
|
||||
def wrap(f, *args, **kwargs):
|
||||
if callable(f):
|
||||
|
@ -29,6 +29,7 @@
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
from supybot.commands import wrap
|
||||
from supybot.i18n import PluginInternationalization, internationalizeDocstring
|
||||
import supybot.conf as conf
|
||||
|
||||
@ -42,6 +43,11 @@ def foo():
|
||||
"""The operation succeeded."""
|
||||
pass
|
||||
|
||||
@wrap
|
||||
def bar():
|
||||
"""The operation succeeded."""
|
||||
pass
|
||||
|
||||
class I18nTestCase(SupyTestCase):
|
||||
def testPluginInternationalization(self):
|
||||
self.assertEqual(_(msg_en), msg_en)
|
||||
@ -54,6 +60,9 @@ class I18nTestCase(SupyTestCase):
|
||||
|
||||
def testDocstring(self):
|
||||
self.assertEqual(foo.__doc__, msg_en)
|
||||
self.assertEqual(bar.__doc__, msg_en)
|
||||
with conf.supybot.language.context('fr'):
|
||||
self.assertEqual(foo.__doc__, msg_fr)
|
||||
self.assertEqual(bar.__doc__, msg_fr)
|
||||
self.assertEqual(foo.__doc__, msg_en)
|
||||
self.assertEqual(bar.__doc__, msg_en)
|
||||
|
Loading…
Reference in New Issue
Block a user