From 92a68bf8331506d1b36cb3ffbc0c9526c0cadd3f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Mon, 6 Jun 2011 14:43:21 +0200 Subject: [PATCH] Bug 6464 Check inconsistent placeholders in translated strings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Display a warning for strings that don't have the same count of %s placeholders that the English original strings. Don't warn for not translated string and 'fuzzy' string because those strings are not installed, and this is the translator responsability to examine them. Based on Frère Sébastien Marie work. Signed-off-by: Frère Sébastien Marie Signed-off-by: Chris Cormack (cherry picked from commit 2281350b6eb2b4d7043aad7baeb93f9bfa185a91) Signed-off-by: Chris Nighswonger --- misc/translator/tmpl_process3.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/misc/translator/tmpl_process3.pl b/misc/translator/tmpl_process3.pl index 46ceceb1af..d862a97ff8 100755 --- a/misc/translator/tmpl_process3.pl +++ b/misc/translator/tmpl_process3.pl @@ -274,6 +274,21 @@ if (defined $href) { # $charset_in = $candidate; # } # } + + # BUG6464: check consistency of PO messages + # - count number of '%s' in msgid and msgstr + for my $msg ( values %$href ) { + my $id_count = split(/%s/, $msg->{msgid}) - 1; + my $str_count = split(/%s/, $msg->{msgstr}) - 1; + next if $id_count == $str_count || + $msg->{msgstr} eq '""' || + grep { /fuzzy/ } @{$msg->{_flags}}; + warn_normal + "unconsistent %s count: ($id_count/$str_count):\n" . + " line: " . $msg->{loaded_line_number} . "\n" . + " msgid: " . $msg->{msgid} . "\n" . + " msgstr: " . $msg->{msgstr} . "\n", undef; + } } # set our charset in to UTF-8 -- 2.39.5