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
This commit is contained in:
Richard Heck 2011-04-05 22:11:06 +00:00
parent 772262ca3d
commit 1856b0a6df

View File

@ -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.