Skip to content

Commit

Permalink
[convertpottojson] Handle lines ending with "
Browse files Browse the repository at this point in the history
the .pot file has lines starting and ending in quotes
we used strip(\") to get rid of them.

If a string ends in ", it will appear as "" in the file, and both
characters get stripped.

Instead chop the first and last characters
  • Loading branch information
davidedmundson committed Jan 5, 2021
1 parent 84049bf commit 36775d1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions util/convertpottojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
currentId = ""
currentMsg = ""

def cleanupMessage(msg):
# strip wrapping "'s
msg = msg[1:-1]
# unescape quotes in the pot file
msg = msg.replace('\\\"', '\"')
return msg

with open(potFileName, 'r') as infile:
for line in infile.readlines():
line = line.strip()
Expand All @@ -40,13 +47,9 @@
parts = line.split(' ', 1)
if len(parts) != 2:
continue
msg = parts[1].strip('\"')
msg = msg.replace('\\\"', '\"')
currentMsg = msg
currentMsg = cleanupMessage(parts[1])
else:
msg = line.strip('\"')
msg = msg.replace('\\\"', '\"')
currentMsg += msg
currentMsg += cleanupMessage(line)


outTranslations = {}
Expand Down

0 comments on commit 36775d1

Please sign in to comment.