mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-26 04:51:06 -05:00
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.
This commit is contained in:
parent
b76a6db1a9
commit
c31dbfd76b
@ -1,5 +1,5 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2010-2021, Valentin Lorentz
|
# Copyright (c) 2010-2024, Valentin Lorentz
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -263,15 +263,14 @@ class _PluginInternationalization:
|
|||||||
"""Main function.
|
"""Main function.
|
||||||
|
|
||||||
This is the function which is called when a plugin runs _()"""
|
This is the function which is called when a plugin runs _()"""
|
||||||
|
if untranslated.__class__ is InternationalizedString:
|
||||||
|
untranslated = untranslated._origin
|
||||||
|
|
||||||
normalizedUntranslated = normalize(untranslated, True)
|
normalizedUntranslated = normalize(untranslated, True)
|
||||||
try:
|
try:
|
||||||
string = self._translate(normalizedUntranslated)
|
string = self._translate(normalizedUntranslated)
|
||||||
return self._addTracker(string, untranslated)
|
return self._addTracker(string, untranslated)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
|
||||||
if untranslated.__class__ is InternationalizedString:
|
|
||||||
return untranslated._original
|
|
||||||
else:
|
|
||||||
return untranslated
|
return untranslated
|
||||||
|
|
||||||
def _translate(self, string):
|
def _translate(self, string):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user