Add scripts for merging suggestions from pootle
This commit is contained in:
7
scripts/pending-po
Executable file
7
scripts/pending-po
Executable 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
31
scripts/pendingpo.py
Executable 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()
|
||||||
|
|
Reference in New Issue
Block a user