mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-25 12:31:04 -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
912e334f6b
commit
aaeab253a5
17
src/i18n.py
17
src/i18n.py
@ -1,5 +1,5 @@
|
||||
###
|
||||
# Copyright (c) 2010-2021, Valentin Lorentz
|
||||
# Copyright (c) 2010-2024, Valentin Lorentz
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -263,16 +263,17 @@ class _PluginInternationalization:
|
||||
"""Main function.
|
||||
|
||||
This is the function which is called when a plugin runs _()"""
|
||||
normalizedUntranslated = normalize(untranslated, True)
|
||||
if untranslated.__class__ is InternationalizedString:
|
||||
originalUntranslated = untranslated._original
|
||||
else:
|
||||
originalUntranslated = untranslated
|
||||
|
||||
normalizedUntranslated = normalize(originalUntranslated, True)
|
||||
try:
|
||||
string = self._translate(normalizedUntranslated)
|
||||
return self._addTracker(string, untranslated)
|
||||
except KeyError:
|
||||
pass
|
||||
if untranslated.__class__ is InternationalizedString:
|
||||
return untranslated._original
|
||||
else:
|
||||
return untranslated
|
||||
string = originalUntranslated
|
||||
return self._addTracker(string, untranslated)
|
||||
|
||||
def _translate(self, string):
|
||||
"""Translate the string.
|
||||
|
Loading…
x
Reference in New Issue
Block a user