Add scripts for merging suggestions from pootle

This commit is contained in:
Michal Čihař
2011-02-24 15:51:13 +01:00
parent 09b885e265
commit ea9189cdc2
2 changed files with 38 additions and 0 deletions

7
scripts/pending-po Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
# vim: expandtab sw=4 ts=4 sts=4:
LOCS=`ls po/*.po.pending | sed 's@.*/\(.*\)\.po\.pending@\1@'`
for loc in $LOCS ; do
./scripts/pendingpo.py po/$loc.po po/$loc.po.pending
done

31
scripts/pendingpo.py Executable file
View File

@@ -0,0 +1,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()