Skip to content

Commit 67fe565

Browse files
committed
Fix interference of wrap() and internationalizeDocstring()
Most commands are decorated with @internationalizeDocstring then with wrap(). wrap() itself calls internationalizeDocstring(), so that plugins wrapping with @internationalizeDocstring() is now optional; but many still do it. This means that docstrings went twice through the _PluginInternationalization. This fixes the bug that on the second run, it would try to translate again the translated message, which fails (because the translated message is not in English); and then fell back to the original string (which is in English). This commit changes the behavior to return the already-translated string directly instead.
1 parent b76a6db commit 67fe565

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/i18n.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,15 @@ def __call__(self, untranslated):
263263
"""Main function.
264264
265265
This is the function which is called when a plugin runs _()"""
266+
t = "to all the users in" in untranslated or "à tous les utilisateurs sur" in untranslated
267+
if untranslated.__class__ is InternationalizedString:
268+
untranslated = untranslated._origin
269+
266270
normalizedUntranslated = normalize(untranslated, True)
267271
try:
268272
string = self._translate(normalizedUntranslated)
269273
return self._addTracker(string, untranslated)
270274
except KeyError:
271-
pass
272-
if untranslated.__class__ is InternationalizedString:
273-
return untranslated._original
274-
else:
275275
return untranslated
276276

277277
def _translate(self, string):

0 commit comments

Comments
 (0)