X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=po%2Fpocheck.pl;h=68dd83f23c4978d80f43d402d8d96b7c43f6fff0;hb=09bc43918842936eb9af9b10f7950ac34009a56a;hp=fe45b059cee36c0533bd5d6d71b3fa0972c3ad04;hpb=89bb06a23e7337c0587a575f7b4a39f8acb97817;p=lyx.git diff --git a/po/pocheck.pl b/po/pocheck.pl index fe45b059ce..68dd83f23c 100755 --- a/po/pocheck.pl +++ b/po/pocheck.pl @@ -15,41 +15,55 @@ use Getopt::Std; my $usage = < $n; } if ($n <= 0) { - print "Problem finding arguments in:\n $msgid!\n"; + print "$pofilename, 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 "Missing argument `$arg'\n '$msgid' ==> '$msgstr'\n"; + print "$pofilename, line $linenum: Missing argument `$arg'\n '$msgid' ==> '$msgstr'\n" + unless $only_total; + ++$bad{"Missing arguments"}; $warn++; } } @@ -115,8 +141,9 @@ foreach my $pofilename ( @ARGV ) if ($check_colons) { # Check colon at the end of a message if ( ( $msgid =~ m/: *(\|.*)?$/ ) != ( $msgstr =~ m/: *(\|.*)?$/ ) ) { - print( "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++; } } @@ -124,8 +151,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( "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++; } } @@ -133,8 +161,9 @@ foreach my $pofilename ( @ARGV ) if ($check_spaces) { # Check space at the end of a message if ( ( $msgid =~ m/ *?(\|.*)?$/ ) != ( $msgstr =~ m/ *?(\|.*)?$/ ) ) { - print( "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++; } } @@ -142,8 +171,9 @@ foreach my $pofilename ( @ARGV ) if ($check_qt) { # Check for "&" shortcuts if ( ( $msgid =~ m/&[^ ]/ ) != ( $msgstr =~ m/&[^ ]/ ) ) { - print( "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++; } } @@ -151,8 +181,9 @@ foreach my $pofilename ( @ARGV ) if ($check_menu) { # Check for "|..." shortcuts if ( ( $msgid =~ m/\|[^ ]/ ) != ( $msgstr =~ m/\|[^ ]/ ) ) { - print( "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++; } } @@ -174,7 +205,7 @@ foreach my $pofilename ( @ARGV ) # cleaned versions of ORIGINAL strings. the keys of the inner hash # are the cleaned versions of their TRANSLATIONS. The value for the # inner hash is an array of the orignal string and translation. - $trans{$msgid_clean}{$msgstr_clean} = [ $msgid, $msgstr ]; + $trans{$msgid_clean}{$msgstr_clean} = [ $msgid, $msgstr, $linenum ]; } if ($check_trans) { @@ -186,14 +217,32 @@ 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( " '" . $trans{$msgid}{$msgstr}[0] . "' => '" . $trans{$msgid}{$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" ); + if (!$silent_mode) { + if ($warn) { + while (my ($k, $v) = each %bad) { print "$k: $v\n"; } + if (scalar(keys %bad) > 1) { + print "Total warnings: $warn\n"; + } + } else { + print "No warnings!\n"; + } + print "\n"; + } + $total_warn += $warn; } + +exit ($total_warn > 0); +