From 36775d150591142c29ca32bf64cbaafc58d07668 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 5 Jan 2021 22:19:04 +0000 Subject: [PATCH] [convertpottojson] Handle lines ending with " 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 --- util/convertpottojson.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/util/convertpottojson.py b/util/convertpottojson.py index e2637553..298f75df 100755 --- a/util/convertpottojson.py +++ b/util/convertpottojson.py @@ -21,6 +21,13 @@ currentGroup = {} 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() @@ -40,13 +47,9 @@ with open(potFileName, 'r') as infile: 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 = {} -- GitLab