From ea9189cdc22b1033b0fd1af6114c7f03c8f98be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 24 Feb 2011 15:51:13 +0100 Subject: [PATCH] Add scripts for merging suggestions from pootle --- scripts/pending-po | 7 +++++++ scripts/pendingpo.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 scripts/pending-po create mode 100755 scripts/pendingpo.py diff --git a/scripts/pending-po b/scripts/pending-po new file mode 100755 index 000000000..aec3a8a58 --- /dev/null +++ b/scripts/pending-po @@ -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 diff --git a/scripts/pendingpo.py b/scripts/pendingpo.py new file mode 100755 index 000000000..307f212da --- /dev/null +++ b/scripts/pendingpo.py @@ -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() +