blob: 307f212dadc655bbb28bac45746da913a381ebc0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/usr/bin/python
'''
Script to automatically merge pending translations from Pootle into po files.
It only accepts those, which are not translated or fuzzy.
'''
import polib
import sys
po = polib.pofile(sys.argv[1])
poupdate = polib.pofile(sys.argv[2])
for updateentry in poupdate:
msgid = updateentry.msgid.split('\n', 1)[1]
if msgid == updateentry.msgstr:
continue
origentry = po.find(msgid)
if origentry is None:
continue
if origentry.msgstr == '' or 'fuzzy' in origentry.flags:
origentry.msgstr = updateentry.msgstr
try:
origentry.msgstr_plural = updateentry.msgstr_plural
except AttributeError:
pass
if 'fuzzy' in origentry.flags:
origentry.flags.remove('fuzzy')
po.save()
|