~chromium-team/chromium-browser/translations-pump

« back to all changes in this revision

Viewing changes to fileformats/gettext.py

  • Committer: Chad MILLER
  • Date: 2015-10-20 15:22:06 UTC
  • Revision ID: chad.miller@canonical.com-20151020152206-c3vz78qihtabw0qh
Escape all characters that need it in PO files. There was assymetry between import an export here.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
    text = re.sub(r'<ph\s+name="([^"]+)"\s*/>', r"%{\1}", text)
37
37
    outfile.write('{0} ""\n'.format(header))
38
 
    outfile.write('"' + '\\n"\n"'.join(line.replace("\\", "\\\\") for line in text.split("\n")) + '"\n')
 
38
    outfile.write('"' + '\\n"\n"'.join(re.sub(r'(["\\])', r'\\\1', line) for line in text.split("\n")) + '"\n')
39
39
 
40
40
    return outfile