From 1856b0a6df42e684aa73bc1779d024598fb99edd Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Tue, 5 Apr 2011 22:11:06 +0000 Subject: [PATCH] Have pocheck.pl check for missing arguments, like %1$s, etc. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38263 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/pocheck.pl | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/po/pocheck.pl b/po/pocheck.pl index dbbf1935d1..0b2c0eda3c 100755 --- a/po/pocheck.pl +++ b/po/pocheck.pl @@ -45,7 +45,7 @@ foreach $pofilename ( @ARGV ) $msgid = $msgid . $more; $i++; } - + # now look for the associated msgstr. until ( ( $msgstr ) = ( $pofile[$i] =~ m/^msgstr "(.*)"/ ) ) { $i++; }; $i++; @@ -60,6 +60,25 @@ foreach $pofilename ( @ARGV ) # (surely that is always $msgstr?) next if ($msgid eq "" or $msgstr eq ""); + # Check for matching %1$s, etc. + @argstrs = ( $msgid =~ m/%(\d)\$s/g ); + if (@argstrs) { + $num = 0; + foreach $arg (@argstrs) { $num = $arg if $arg > $num; } + if ($num <= 0) { + print "Problem finding arguments in:\n $msgid!\n"; + $warn++; + } else { + foreach $i (1..$num) { + $arg = "%$i\\\$s"; + if ( $msgstr !~ m/$arg/ ) { + print "Missing argument `$arg'\n '$msgid' ==> '$msgstr'\n"; + $warn++; + } + } + } + } + # Check colon at the end of a message if ( ( $msgid =~ m/: *(\|.*)?$/ ) != ( $msgstr =~ m/: *(\|.*)?$/ ) ) { print( "Missing or unexpected colon:\n" ); @@ -94,7 +113,7 @@ foreach $pofilename ( @ARGV ) print( " '$msgid' => '$msgstr'\n" ); $warn++; } - + # we now collect these translations in a hash. # this will allow us to check below if we have translated # anything more than one way. -- 2.39.2