# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1408469262 -7200 # mar ago 19 19:27:42 2014 +0200 # Node ID ad3cda48cfe58b536ea548a72d3f949e7b571f92 # Parent d5a4ed31fa2afd5820516b8d02ed28565c960bdc [locale] add a script to check parameters in translated strings
Translated strings must use the very same parameter that are in original strings This script check parameters used ineach translation of each po file It need polib
created fixing #1835
diff --git a/locale/check_parameters.py b/locale/check_parameters.py new file mode 100755 --- /dev/null +++ b/locale/check_parameters.py @@ -0,0 +1,30 @@ +#!/usr/bin/python + +import polib +from string import Formatter +import glob + +filelist = glob.glob("*.po") +pos = {filename: polib.pofile(filename) for filename in filelist} + +formatter = Formatter() + +for name, po in pos.iteritems(): + print "Testing", name + for entry in po: + if len(entry.msgstr) > 0: + try: + ids = [field_name + for literal_text, field_name, format_spec, conversion + in formatter.parse(entry.msgid)] + tids = [field_name + for literal_text, field_name, format_spec, conversion + in formatter.parse(entry.msgstr)] + except Exception as e: + print "Got exception!", e, "for entry", entry.msgid + else: + if tids != None: + missing = [name for name in tids + if name is not None and name not in ids] + if len(missing) > 0: + print "Missing parameters", missing, "in translation of", entry.msgid