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