Permalink
Browse files

Add scripts for merging suggestions from pootle

  • Loading branch information...
nijel committed Feb 24, 2011
1 parent 09b885e commit ea9189cdc22b1033b0fd1af6114c7f03c8f98be0
Showing with 38 additions and 0 deletions.
  1. +7 −0 scripts/pending-po
  2. +31 −0 scripts/pendingpo.py
View
@@ -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
View
@@ -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()
+

0 comments on commit ea9189c

Please sign in to comment.