From 9093c8679c9901f2499e8db12362125bd49b3717 Mon Sep 17 00:00:00 2001 From: Kees Bakker Date: Tue, 21 Nov 2006 07:17:45 +0000 Subject: [PATCH] Added a new check to find shortcut in translation when there is no shortcut in the program text. svn: r7662 --- gramps2/po/check_po | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gramps2/po/check_po b/gramps2/po/check_po index 71d12c804..622c21dff 100755 --- a/gramps2/po/check_po +++ b/gramps2/po/check_po @@ -21,7 +21,6 @@ # # TODO # -# * commandline options (for example, "suppress fuzzies in report") # * Check for HTML text in msgstr when there is none in msgid # * Check for matching HTML tag/endtag in msgstr # * Check for shortcut key (_) presence in both msgid and msgstr @@ -168,6 +167,18 @@ class Check_last_char( Check ): elif (msgid_last == '.') != (msgstr_last == '.'): self.msgs.append( msg ) +class Check_shortcut_trans( Check ): + def __init__( self ): + Check.__init__( self ) + self.diag_header = "-------- shortcut key in translation ---------" + self.summary_text = "Shortcut in msgstr:" + def process( self, msg ): + msgid = msg.msgid() + msgstr = msg.msgstr() + + if msgid.count('_') == 0 and msgstr.count('_') > 0: + self.msgs.append( msg ) + class Msgid: fuzzy_pat = re.compile( 'fuzzy' ) tips_xml_pat = re.compile( r'tips\.xml' ) @@ -403,6 +414,7 @@ def analyze_msgs( options, fname, msgs, nr_templates = None, nth = 0 ): checks.append( Check_runaway() ) checks.append( Check_xml_chars() ) checks.append( Check_last_char() ) + checks.append( Check_shortcut_trans() ) for msg in msgs: msgid = msg.msgid()