# -*- coding: UTF-8 -*- """ Find messages with msgstr[1] == msgstr[2] #For every fuzzy message, the translation and fuzzy data (the flag, #previous fields) are removed. Manual (translator) comments are left in #by default, but can be removed as well. #Obsolete fuzzy messages are completely removed. Sieve options: - C{lokalize}: open catalogs at matched messages in Lokalize @author: Alexander Potashev @license: GPLv3 """ from pology import _, n_ from pology.misc.report import report from pology.misc.msgreport import report_msg_content from pology.misc.msgreport import report_msg_to_lokalize def setup_sieve (p): p.set_desc(_("@info sieve discription", "Find messages with msgstr[1] == msgstr[2]." )) p.add_param("lokalize", bool, defval=False, desc=_("@info sieve parameter discription", "Open catalogs at matched messages in Lokalize." )) class Sieve (object): def __init__ (self, params): self.p = params self.nfound = 0 def process (self, msg, cat): if (msg.msgid_plural is not None and msg.msgstr[1] == msg.msgstr[2] and not msg.obsolete and not msg.fuzzy and not msg.untranslated): self.nfound += 1 report_msg_content(msg, cat) if self.p.lokalize: report_msg_to_lokalize(msg, cat) print "-" * 20 def finalize (self): if self.nfound > 0: msg = n_("@info:progress", "Found %(num)d message of translation.", "Found %(num)d messages of translation.", num=self.nfound) report("===== " + msg)