Handle escaped characters correctly

Some characters (like ") are escaped in .po files. These are handled correctly
by polib, but the self written parser did not yet take them into account.
This commit is contained in:
Georg Baum 2015-12-03 20:56:51 +01:00
parent 2041920ce0
commit be7df4a13c

View File

@ -56,7 +56,7 @@ def parse_msg(lines):
if j < 0:
return ''
msg = msg + lines[i][j:].strip('"')
return msg
return polib.unescape(msg)
def translate(msgid, msgstr_lines, po2):
@ -72,7 +72,7 @@ def translate(msgid, msgstr_lines, po2):
obsolete = (msgstr_lines[0].find('#~') == 0)
j = msgstr_lines[0].find('"')
# must not assign to msgstr_lines, because that would not be seen by our caller
new_lines = polib.wrap(msgstr_lines[0][0:j+1] + msgstr, 76, drop_whitespace = False)
new_lines = polib.wrap(msgstr_lines[0][0:j+1] + polib.escape(msgstr), 76, drop_whitespace = False)
del msgstr_lines[:]
for i in range(0, len(new_lines)):
if i == 0: