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.
master
Gonzalo Odiard 9 years ago committed by Sam Parkinson
parent 06c3f01998
commit 954be953ca

@ -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)

Loading…
Cancel
Save