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.
This commit is contained in:
Gonzalo Odiard 2015-04-14 09:57:23 -03:00 committed by Sam Parkinson
parent 06c3f01998
commit 954be953ca

View File

@ -144,6 +144,11 @@ class Builder(object):
cat = gettext.GNUTranslations(open(mo_file, 'r')) cat = gettext.GNUTranslations(open(mo_file, 'r'))
translated_name = cat.gettext(self.config.activity_name) translated_name = cat.gettext(self.config.activity_name)
translated_summary = cat.gettext(self.config.summary) 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') linfo_file = os.path.join(localedir, 'activity.linfo')
f = open(linfo_file, 'w') f = open(linfo_file, 'w')
f.write('[Activity]\nname = %s\n' % translated_name) f.write('[Activity]\nname = %s\n' % translated_name)