From 954be953ca37ffee552e54c445daf7102c3d7d42 Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Tue, 14 Apr 2015 09:57:23 -0300 Subject: [PATCH] Remove new line chars when create linfo files If a translator add a '\n' char in the summary translation ConfigParser can't parse the linfo file. Remove them when the file is created and show a message to warning to the developer. --- src/sugar3/activity/bundlebuilder.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sugar3/activity/bundlebuilder.py b/src/sugar3/activity/bundlebuilder.py index d1095aa9..23a1ad6a 100644 --- a/src/sugar3/activity/bundlebuilder.py +++ b/src/sugar3/activity/bundlebuilder.py @@ -144,6 +144,11 @@ class Builder(object): cat = gettext.GNUTranslations(open(mo_file, 'r')) translated_name = cat.gettext(self.config.activity_name) translated_summary = cat.gettext(self.config.summary) + if translated_summary.find('\n') > -1: + translated_summary = translated_summary.replace('\n', '') + logging.warn( + 'Translation of summary on file %s have \\n chars. ' + 'Should be removed' % file_name) linfo_file = os.path.join(localedir, 'activity.linfo') f = open(linfo_file, 'w') f.write('[Activity]\nname = %s\n' % translated_name)