From 30a1ca06b2241ec1a70e4eecbb0a8eb1544f4e5b Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Mon, 1 Nov 2010 15:01:50 +0100 Subject: [PATCH] Fix the @Misc help formatting Stop removing the \n in the translated docstrings --- src/i18n.py | 7 ++++--- src/utils/str.py | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/i18n.py b/src/i18n.py index 8f2351212..4877ec32a 100644 --- a/src/i18n.py +++ b/src/i18n.py @@ -190,16 +190,17 @@ class _PluginInternationalization: def _unescape(self, string): 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): """Main function. his is the function which is called when a plugin runs _()""" - import supybot.utils as utils if untranslated.__class__ == internationalizedString: return untranslated._original - untranslated = utils.str.normalizeWhitespace(untranslated) + untranslated = self._unescape(untranslated) if not 'conf' in globals(): return untranslated if self.currentLocaleName != conf.supybot.language(): diff --git a/src/utils/str.py b/src/utils/str.py index 5eb8cb569..c624fe7bb 100644 --- a/src/utils/str.py +++ b/src/utils/str.py @@ -59,11 +59,14 @@ def rsplit(s, sep=None, maxsplit=-1): else: return s.rsplit(sep, maxsplit) -def normalizeWhitespace(s): +def normalizeWhitespace(s, removeNewline=True): """Normalizes the whitespace in a string; \s+ becomes one space.""" beginning = s.startswith(' ') ending = s.endswith(' ') - s = ' '.join(s.split()) + if removeNewline: + s = ' '.join(s.split()) + else: + s = ' '.join(s.split(' ')) if beginning: s = ' ' + s if ending: