Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bin/i18n/prop2po.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
TO DO: contribute changes back and go back to installing from pypi
"""

import re

import click
from datetime import datetime

Expand Down Expand Up @@ -47,7 +49,9 @@ def to_po(source, destination, encoding, language, project, copyright):
parts = line.split('=', 1)
# TODO it fails on comments/lines with less than two parts after splitting
try:
destination.write('#:\n' + 'msgid "' + parts[0] + '"\n' 'msgstr "' + parts[1][:-1] + '"\n\n')
# a bare " would end the .po string early; msgfmt then skips the line and the .mo keeps the wrong text
msgstr = re.sub(r'(?<!\\)"', r'\\"', parts[1][:-1])
destination.write('#:\n' + 'msgid "' + parts[0] + '"\n' 'msgstr "' + msgstr + '"\n\n')
except IndexError as e:
print("FAILED on line{}".format(line))

Expand Down
Loading