From 2f8279c0ec25bee391191f90ca96b0c43a367458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A8re=20S=C3=A9bastien=20Marie?= Date: Mon, 6 Jun 2011 11:27:43 +0200 Subject: [PATCH] BUG6464: check consistency of PO messages At the installation level of translation, count the number of '%s' in msgid and msgstr. A difference issue a warning. --- misc/translator/tmpl_process3.pl | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/misc/translator/tmpl_process3.pl b/misc/translator/tmpl_process3.pl index b916cab..aaa7651 100755 --- a/misc/translator/tmpl_process3.pl +++ b/misc/translator/tmpl_process3.pl @@ -273,6 +273,18 @@ if (defined $href) { # $charset_in = $candidate; # } # } + + # BUG6464: check consistency of PO messages + # - count number of '%s' in msgid and msgstr + for my $msgid (keys %$href) { + my $msgstr = $href->{$msgid}->msgstr; + + my $id_count = scalar(split(/%s/,$msgid)) - 1; + my $str_count = scalar(split(/%s/,$msgstr)) - 1; + + warn_normal "unconsistent %s count: ($id_count/$str_count): msgid=$msgid | msgstr=$msgstr\n", undef + if ( $id_count ne $str_count ); + } } # set our charset in to UTF-8 -- 1.7.2.5