diff options
Diffstat (limited to 'po')
-rwxr-xr-x | po/compile.py | 48 | ||||
-rw-r--r-- | po/en.po | 4 |
2 files changed, 37 insertions, 15 deletions
diff --git a/po/compile.py b/po/compile.py index cfe837ea..6416ea0e 100755 --- a/po/compile.py +++ b/po/compile.py | |||
@@ -38,29 +38,46 @@ def unquote(string): | |||
38 | 38 | ||
39 | def parse_po(src): | 39 | def parse_po(src): |
40 | messages = [] | 40 | messages = [] |
41 | is_multi = False | 41 | is_multi = False # string is multiple lines |
42 | msg_id, msg_str = None, None | 42 | is_plural = False |
43 | msg_id, msg_str, msg_index = None, None, None | ||
43 | for line in open(src, 'rt', encoding='utf-8').readlines(): | 44 | for line in open(src, 'rt', encoding='utf-8').readlines(): |
44 | line = line.strip() | 45 | line = line.strip() |
45 | if is_multi: | 46 | if is_multi: |
46 | if len(line) == 0: | 47 | if len(line) == 0 or line[0] != '"': |
47 | if msg_id: | 48 | if msg_id: |
48 | messages.append((msg_id, msg_str)) | 49 | messages.append((msg_id, msg_str, msg_index)) |
49 | is_multi = False | 50 | is_multi = False |
50 | continue | ||
51 | else: | 51 | else: |
52 | msg_str += unquote(line) | 52 | msg_str += unquote(line) |
53 | if line.startswith('msgid'): | 53 | if line.startswith('msgid_plural'): |
54 | msg_id = unquote(line[12:]) | ||
55 | is_plural = True | ||
56 | elif line.startswith('msgid'): | ||
54 | msg_id = unquote(line[6:]) | 57 | msg_id = unquote(line[6:]) |
55 | elif line == 'msgstr ""': | 58 | is_plural = False |
56 | # Multiline string. | 59 | elif line.startswith('msgstr'): |
57 | is_multi = True | 60 | if line[6] == '[': |
58 | msg_str = '' | 61 | msg_index = int(line[7]) |
59 | elif line.startswith('msgstr'): | 62 | line = line[9:] |
60 | msg_str = unquote(line[7:]) | 63 | else: |
61 | if msg_id: | 64 | msg_index = None |
62 | messages.append((msg_id, msg_str)) | 65 | line = line[6:] |
63 | return messages | 66 | if line.endswith(' ""'): |
67 | is_multi = True | ||
68 | msg_str = '' | ||
69 | else: | ||
70 | msg_str = unquote(line) | ||
71 | if msg_id: | ||
72 | messages.append((msg_id, msg_str, msg_index)) | ||
73 | # Apply plural indices to ids. | ||
74 | pluralized = [] | ||
75 | for msg_id, msg_str, msg_index in messages: | ||
76 | if not msg_index is None: | ||
77 | msg_id = f'{msg_id[:-1]}{msg_index}' | ||
78 | pluralized.append((msg_id, msg_str)) | ||
79 | #print(msg_id, '=>', msg_str) | ||
80 | return pluralized | ||
64 | 81 | ||
65 | 82 | ||
66 | if MODE == 'compile': | 83 | if MODE == 'compile': |
@@ -76,6 +93,7 @@ if MODE == 'compile': | |||
76 | elif MODE == 'new': | 93 | elif MODE == 'new': |
77 | messages = parse_po('en.po') | 94 | messages = parse_po('en.po') |
78 | f = open('new.po', 'wt', encoding='utf-8') | 95 | f = open('new.po', 'wt', encoding='utf-8') |
96 | # TODO: plurals | ||
79 | for msg_id, _ in messages: | 97 | for msg_id, _ in messages: |
80 | print(f'\nmsgid "{msg_id}"\nmsgstr ""\n', file=f) | 98 | print(f'\nmsgid "{msg_id}"\nmsgstr ""\n', file=f) |
81 | 99 | ||
@@ -1,3 +1,4 @@ | |||
1 | # Alt-text of the preformatted logo. | ||
1 | msgid "about.logo" | 2 | msgid "about.logo" |
2 | msgstr "ASCII art: the word \"Lagrange\" using a large font" | 3 | msgstr "ASCII art: the word \"Lagrange\" using a large font" |
3 | 4 | ||
@@ -73,9 +74,11 @@ msgstr "Find on Page" | |||
73 | msgid "macos.menu.find" | 74 | msgid "macos.menu.find" |
74 | msgstr "Find" | 75 | msgstr "Find" |
75 | 76 | ||
77 | # Used on iOS. "Files" refers to Apple's iOS app where you can pick an iCloud folder. | ||
76 | msgid "menu.save.files" | 78 | msgid "menu.save.files" |
77 | msgstr "Save to Files" | 79 | msgstr "Save to Files" |
78 | 80 | ||
81 | # Used on desktop operating systems. "Downloads" refers to the user's configured downloads directory. | ||
79 | msgid "menu.save.downloads" | 82 | msgid "menu.save.downloads" |
80 | msgstr "Save to Downloads" | 83 | msgstr "Save to Downloads" |
81 | 84 | ||
@@ -241,6 +244,7 @@ msgstr "Identities" | |||
241 | msgid "sidebar.outline" | 244 | msgid "sidebar.outline" |
242 | msgstr "Outline" | 245 | msgstr "Outline" |
243 | 246 | ||
247 | # Usage: "(count) Unread" in the sidebar tab title, referring to feed entries. | ||
244 | msgid "sidebar.unread" | 248 | msgid "sidebar.unread" |
245 | msgid_plural "sidebar.unread.n" | 249 | msgid_plural "sidebar.unread.n" |
246 | msgstr[0] "Unread" | 250 | msgstr[0] "Unread" |