diff options
Diffstat (limited to 'po/compile.py')
-rwxr-xr-x | po/compile.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/po/compile.py b/po/compile.py index 650dc3eb..cfe837ea 100755 --- a/po/compile.py +++ b/po/compile.py | |||
@@ -38,14 +38,28 @@ def unquote(string): | |||
38 | 38 | ||
39 | def parse_po(src): | 39 | def parse_po(src): |
40 | messages = [] | 40 | messages = [] |
41 | is_multi = False | ||
41 | msg_id, msg_str = None, None | 42 | msg_id, msg_str = None, None |
42 | for line in open(src, 'rt', encoding='utf-8').readlines(): | 43 | for line in open(src, 'rt', encoding='utf-8').readlines(): |
43 | line = line.strip() | 44 | line = line.strip() |
45 | if is_multi: | ||
46 | if len(line) == 0: | ||
47 | if msg_id: | ||
48 | messages.append((msg_id, msg_str)) | ||
49 | is_multi = False | ||
50 | continue | ||
51 | else: | ||
52 | msg_str += unquote(line) | ||
44 | if line.startswith('msgid'): | 53 | if line.startswith('msgid'): |
45 | msg_id = unquote(line[6:]) | 54 | msg_id = unquote(line[6:]) |
55 | elif line == 'msgstr ""': | ||
56 | # Multiline string. | ||
57 | is_multi = True | ||
58 | msg_str = '' | ||
46 | elif line.startswith('msgstr'): | 59 | elif line.startswith('msgstr'): |
47 | msg_str = unquote(line[7:]) | 60 | msg_str = unquote(line[7:]) |
48 | messages.append((msg_id, msg_str)) | 61 | if msg_id: |
62 | messages.append((msg_id, msg_str)) | ||
49 | return messages | 63 | return messages |
50 | 64 | ||
51 | 65 | ||