From c1217970d1425e7d25ac54521ac6f0d21ad8d431 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Tue, 5 Apr 2011 22:58:08 +0000 Subject: [PATCH] Add option to get just a summary of the errors. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38269 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/pocheck.pl | 70 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/po/pocheck.pl b/po/pocheck.pl index 9e58cdcbf5..77dfe6db5f 100755 --- a/po/pocheck.pl +++ b/po/pocheck.pl @@ -15,28 +15,32 @@ use Getopt::Std; my $usage = < $n; } if ($n <= 0) { - print "Problem finding arguments in:\n $msgid!\non line $linenum.\n"; + print "Line $linenum: Problem finding arguments in:\n $msgid!\n" + unless $only_total; + ++$bad{"Missing arguments"}; $warn++; } else { foreach my $i (1..$n) { my $arg = "%$i\\\$s"; if ( $msgstr !~ m/$arg/ ) { - print "Line $linenum: Missing argument `$arg'\n '$msgid' ==> '$msgstr'\n"; + print "Line $linenum: Missing argument `$arg'\n '$msgid' ==> '$msgstr'\n" + unless $only_total; + ++$bad{"Missing arguments"}; $warn++; } } @@ -116,8 +124,9 @@ foreach my $pofilename ( @ARGV ) if ($check_colons) { # Check colon at the end of a message if ( ( $msgid =~ m/: *(\|.*)?$/ ) != ( $msgstr =~ m/: *(\|.*)?$/ ) ) { - print( "Line $linenum: Missing or unexpected colon:\n" ); - print( " '$msgid' => '$msgstr'\n" ); + print "Line $linenum: Missing or unexpected colon:\n '$msgid' => '$msgstr'\n" + unless $only_total; + ++$bad{"Bad colons"}; $warn++; } } @@ -125,8 +134,9 @@ foreach my $pofilename ( @ARGV ) if ($check_periods) { # Check period at the end of a message; uncomment code if you are paranoid if ( ( $msgid =~ m/\. *(\|.*)?$/ ) != ( $msgstr =~ m/\. *(\|.*)?$/ ) ) { - print( "Line $linenum: Missing or unexpected period:\n" ); - print( " '$msgid' => '$msgstr'\n" ); + print "Line $linenum: Missing or unexpected period:\n '$msgid' => '$msgstr'\n" + unless $only_total; + ++$bad{"Bad periods"}; $warn++; } } @@ -134,8 +144,9 @@ foreach my $pofilename ( @ARGV ) if ($check_spaces) { # Check space at the end of a message if ( ( $msgid =~ m/ *?(\|.*)?$/ ) != ( $msgstr =~ m/ *?(\|.*)?$/ ) ) { - print( "Line $linenum: Missing or unexpected space:\n" ); - print( " '$msgid' => '$msgstr'\n" ); + print "Line $linenum: Missing or unexpected space:\n '$msgid' => '$msgstr'\n" + unless $only_total; + ++$bad{"Bad spaces"}; $warn++; } } @@ -143,8 +154,9 @@ foreach my $pofilename ( @ARGV ) if ($check_qt) { # Check for "&" shortcuts if ( ( $msgid =~ m/&[^ ]/ ) != ( $msgstr =~ m/&[^ ]/ ) ) { - print( "Line $linenum: Missing or unexpected Qt shortcut:\n" ); - print( " '$msgid' => '$msgstr'\n" ); + print "Line $linenum: Missing or unexpected Qt shortcut:\n '$msgid' => '$msgstr'\n" + unless $only_total; + ++$bad{"Bad Qt shortcuts"}; $warn++; } } @@ -152,8 +164,9 @@ foreach my $pofilename ( @ARGV ) if ($check_menu) { # Check for "|..." shortcuts if ( ( $msgid =~ m/\|[^ ]/ ) != ( $msgstr =~ m/\|[^ ]/ ) ) { - print( "Line $linenum: Missing or unexpected menu shortcut:\n" ); - print( " '$msgid' => '$msgstr'\n" ); + print "Line $linenum: Missing or unexpected menu shortcut:\n '$msgid' => '$msgstr'\n" + unless $only_total; + ++$bad{"Bad menu shortcuts"}; $warn++; } } @@ -187,16 +200,21 @@ foreach my $pofilename ( @ARGV ) # do we have more than one such key? if ( $#msgstrkeys > 0 ) { - print( "Different translations for '$msgid':\n" ); - foreach $msgstr ( @msgstrkeys ) { - print( "Line $ref->{$msgstr}[2]: '" . - $ref->{$msgstr}[0] . "' => '" . - $ref->{$msgstr}[1] . "'\n" ); + if (!$only_total) { + print "Different translations for '$msgid':\n"; + foreach $msgstr ( @msgstrkeys ) { + print "Line $ref->{$msgstr}[2]: '" . + $ref->{$msgstr}[0] . "' => '" . + $ref->{$msgstr}[1] . "'\n"; + } } + ++$bad{"Inconsistent translations"}; $warn++; } } } - print( "\nTotal number of warnings: $warn\n\n" ); + print "\n"; + while (my ($k, $v) = each %bad) { print "$k: $v warnings\n"; } + print "Total number of warnings: $warn\n\n"; } -- 2.39.2