mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Fix the @Misc help formatting
Stop removing the \n in the translated docstrings
This commit is contained in:
parent
1f4b3b83e1
commit
30a1ca06b2
@ -190,16 +190,17 @@ class _PluginInternationalization:
|
|||||||
|
|
||||||
def _unescape(self, string):
|
def _unescape(self, string):
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
return utils.str.normalizeWhitespace(str.replace(string, '\\n', '\n'))
|
string = str.replace(string, '\\n', '\n') # gettext escapes the \n
|
||||||
|
string = utils.str.normalizeWhitespace(string, removeNewline=False)
|
||||||
|
return string
|
||||||
|
|
||||||
def __call__(self, untranslated):
|
def __call__(self, untranslated):
|
||||||
"""Main function.
|
"""Main function.
|
||||||
|
|
||||||
his is the function which is called when a plugin runs _()"""
|
his is the function which is called when a plugin runs _()"""
|
||||||
import supybot.utils as utils
|
|
||||||
if untranslated.__class__ == internationalizedString:
|
if untranslated.__class__ == internationalizedString:
|
||||||
return untranslated._original
|
return untranslated._original
|
||||||
untranslated = utils.str.normalizeWhitespace(untranslated)
|
untranslated = self._unescape(untranslated)
|
||||||
if not 'conf' in globals():
|
if not 'conf' in globals():
|
||||||
return untranslated
|
return untranslated
|
||||||
if self.currentLocaleName != conf.supybot.language():
|
if self.currentLocaleName != conf.supybot.language():
|
||||||
|
@ -59,11 +59,14 @@ def rsplit(s, sep=None, maxsplit=-1):
|
|||||||
else:
|
else:
|
||||||
return s.rsplit(sep, maxsplit)
|
return s.rsplit(sep, maxsplit)
|
||||||
|
|
||||||
def normalizeWhitespace(s):
|
def normalizeWhitespace(s, removeNewline=True):
|
||||||
"""Normalizes the whitespace in a string; \s+ becomes one space."""
|
"""Normalizes the whitespace in a string; \s+ becomes one space."""
|
||||||
beginning = s.startswith(' ')
|
beginning = s.startswith(' ')
|
||||||
ending = s.endswith(' ')
|
ending = s.endswith(' ')
|
||||||
s = ' '.join(s.split())
|
if removeNewline:
|
||||||
|
s = ' '.join(s.split())
|
||||||
|
else:
|
||||||
|
s = ' '.join(s.split(' '))
|
||||||
if beginning:
|
if beginning:
|
||||||
s = ' ' + s
|
s = ' ' + s
|
||||||
if ending:
|
if ending:
|
||||||
|
Loading…
Reference in New Issue
Block a user