From 23bb7901c861fa3c6c53529154cf9c8b6ee1027d Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 29 Jan 2014 13:16:48 +0200 Subject: [PATCH] [SIGNED-OFF] Bug 11631 - Make translation toolchain ignore useless "translatable" strings that contain nothing but spaces and/or placeholders. Test: 1) Update PO files of some lang, xx-YY-*po cd misc/translator perl translate update xx-YY 2) Do it again, just in case 3) rm po/xx-YY*po~ 4) Extract all msgid's, sorted cat po/xx-YY*po | egrep "^msgid" | sort | uniq > xx-YY-pre 5) Apply the patch 6) Repeat 1-3 7) Repeat 4 again, other file cat po/xx-YY*po | egrep "^msgid" | sort | uniq > xx-YY-post 8) Do a diff, inspect results, only strings with %s and \s diff xx-YY-pre xx-YY-post | less Signed-off-by: Bernardo Gonzalez Kriegel --- misc/translator/xgettext.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/misc/translator/xgettext.pl b/misc/translator/xgettext.pl index 032117d..bd1706d 100755 --- a/misc/translator/xgettext.pl +++ b/misc/translator/xgettext.pl @@ -91,6 +91,11 @@ sub text_extract (*) { my $s = TmplTokenizer::next_token $h; last unless defined $s; my($kind, $t, $attr) = ($s->type, $s->string, $s->attributes); + my $tmpt = $t; + # If msgid contains only placeholders and/or spaces, ignore it + $tmpt =~ s/(%s|\s)//g; + next if ($tmpt eq ""); + if ($kind eq C4::TmplTokenType::TEXT) { if ($t =~ /\S/s && $t !~ /