Skip to content

Commit

Permalink
fix bug for multi line define po
Browse files Browse the repository at this point in the history
  • Loading branch information
xxnet committed Dec 18, 2015
1 parent 3c4130a commit cbe1278
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions launcher/simple_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,6 @@ def get_os_language(self):
return lang_code

def po_loader(self, file):
def read_msgstr(fp):
msgstr = ""
while True:
line = fp.readline()
if not line or len(line) == 0:
break

if line.startswith("msgstr "):
msgstr += line[8:-2]
elif line.startswith("\""):
msgstr += line[1:-2]
else:
break

return msgstr

po_dict = {}
fp = open(file, "r")
while True:
Expand All @@ -67,7 +51,30 @@ def read_msgstr(fp):

if line.startswith("msgid "):
key = line[7:-2]
value = read_msgstr(fp)
value = ""
while True:
line = fp.readline()
if not line:
break

if line.startswith("\""):
key += line[1:-2]
elif line.startswith("msgstr "):
value += line[8:-2]
break
else:
break

while True:
line = fp.readline()
if not line:
break

if line.startswith("\""):
value += line[1:-2]
else:
break

if key == "":
continue

Expand Down

0 comments on commit cbe1278

Please sign in to comment.