summaryrefslogtreecommitdiff
path: root/po
diff options
context:
space:
mode:
Diffstat (limited to 'po')
-rwxr-xr-xpo/compile.py48
-rw-r--r--po/en.po3
2 files changed, 36 insertions, 15 deletions
diff --git a/po/compile.py b/po/compile.py
index cfe837ea..0a0eab91 100755
--- a/po/compile.py
+++ b/po/compile.py
@@ -38,29 +38,46 @@ def unquote(string):
38 38
39def parse_po(src): 39def 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 if len(line) == 0: continue
51 else: 52 else:
52 msg_str += unquote(line) 53 msg_str += unquote(line)
53 if line.startswith('msgid'): 54 if line.startswith('msgid_plural'):
55 msg_id = unquote(line[12:])
56 is_plural = True
57 elif line.startswith('msgid'):
54 msg_id = unquote(line[6:]) 58 msg_id = unquote(line[6:])
55 elif line == 'msgstr ""': 59 is_plural = False
56 # Multiline string. 60 elif line.startswith('msgstr'):
57 is_multi = True 61 if line[6] == '[':
58 msg_str = '' 62 msg_index = int(line[7])
59 elif line.startswith('msgstr'): 63 line = line[9:]
60 msg_str = unquote(line[7:]) 64 else:
61 if msg_id: 65 msg_index = None
62 messages.append((msg_id, msg_str)) 66 line = line[7:]
63 return messages 67 if line.endswith(' ""'):
68 is_multi = True
69 msg_str = ''
70 else:
71 msg_str = unquote(line)
72 if msg_id:
73 messages.append((msg_id, msg_str, msg_index))
74 # Apply plural indices to ids.
75 pluralized = []
76 for msg_id, msg_str, msg_index in messages:
77 if not msg_index is None:
78 msg_id = f'{msg_id[:-1]}{msg_index}'
79 pluralized.append((msg_id, msg_str))
80 return pluralized
64 81
65 82
66if MODE == 'compile': 83if MODE == 'compile':
@@ -76,6 +93,7 @@ if MODE == 'compile':
76elif MODE == 'new': 93elif 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
diff --git a/po/en.po b/po/en.po
index 36f30eda..ad7864b3 100644
--- a/po/en.po
+++ b/po/en.po
@@ -1,3 +1,4 @@
1# Alt-text of the preformatted logo.
1msgid "about.logo" 2msgid "about.logo"
2msgstr "ASCII art: the word \"Lagrange\" using a large font" 3msgstr "ASCII art: the word \"Lagrange\" using a large font"
3 4
@@ -73,9 +74,11 @@ msgstr "Find on Page"
73msgid "macos.menu.find" 74msgid "macos.menu.find"
74msgstr "Find" 75msgstr "Find"
75 76
77# Used on iOS. "Files" refers to Apple's iOS app where you can pick an iCloud folder.
76msgid "menu.save.files" 78msgid "menu.save.files"
77msgstr "Save to Files" 79msgstr "Save to Files"
78 80
81# Used on desktop operating systems. "Downloads" refers to the user's configured downloads directory.
79msgid "menu.save.downloads" 82msgid "menu.save.downloads"
80msgstr "Save to Downloads" 83msgstr "Save to Downloads"
81 84