# Invocation:
# pocheck.pl po_file po_file ...
# Invocation:
# pocheck.pl po_file po_file ...
-foreach $pofilename ( @ARGV )
+use strict;
+use warnings;
+
+my %trans;
+
+foreach my $pofilename ( @ARGV )
{
print "Processing po file '$pofilename'...\n";
open( INPUT, "<$pofilename" )
|| die "Cannot read po file '$pofilename'";
{
print "Processing po file '$pofilename'...\n";
open( INPUT, "<$pofilename" )
|| die "Cannot read po file '$pofilename'";
close( INPUT );
undef( %trans );
keys( %trans ) = 10000;
close( INPUT );
undef( %trans );
keys( %trans ) = 10000;
+ my $noOfLines = $#pofile;
+
+ my $warn = 0;
+ my $i = 0;
+ my ($msgid, $msgstr, $more);
while ($i <= $noOfLines) {
( $msgid ) = ( $pofile[$i] =~ m/^msgid "(.*)"/ );
$i++;
while ($i <= $noOfLines) {
( $msgid ) = ( $pofile[$i] =~ m/^msgid "(.*)"/ );
$i++;
next if ($msgid eq "" or $msgstr eq "");
# Check for matching %1$s, etc.
next if ($msgid eq "" or $msgstr eq "");
# Check for matching %1$s, etc.
- @argstrs = ( $msgid =~ m/%(\d)\$s/g );
+ my @argstrs = ( $msgid =~ m/%(\d)\$s/g );
- $num = 0;
- foreach $arg (@argstrs) { $num = $arg if $arg > $num; }
- if ($num <= 0) {
+ my $n = 0;
+ foreach my $arg (@argstrs) { $n = $arg if $arg > $n; }
+ if ($n <= 0) {
print "Problem finding arguments in:\n $msgid!\n";
$warn++;
} else {
print "Problem finding arguments in:\n $msgid!\n";
$warn++;
} else {
- foreach $i (1..$num) {
- $arg = "%$i\\\$s";
+ foreach my $i (1..$n) {
+ my $arg = "%$i\\\$s";
if ( $msgstr !~ m/$arg/ ) {
print "Missing argument `$arg'\n '$msgid' ==> '$msgstr'\n";
$warn++;
if ( $msgstr !~ m/$arg/ ) {
print "Missing argument `$arg'\n '$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.
# we now collect these translations in a hash.
# this will allow us to check below if we have translated
# anything more than one way.
- $msgid_clean = lc($msgid);
- $msgstr_clean = lc($msgstr);
+ my $msgid_clean = lc($msgid);
+ my $msgstr_clean = lc($msgstr);
$msgid_clean =~ s/(.*)\|.*?$/$1/; # strip menu shortcuts
$msgstr_clean =~ s/(.*)\|.*?$/$1/;
$msgid_clean =~ s/(.*)\|.*?$/$1/; # strip menu shortcuts
$msgstr_clean =~ s/(.*)\|.*?$/$1/;
foreach $msgid ( keys %trans ) {
# so $ref is a reference to the inner hash.
foreach $msgid ( keys %trans ) {
# so $ref is a reference to the inner hash.
+ my $ref = $trans{$msgid};
# @msgstrkeys is an array of the keys of that inner hash.
# @msgstrkeys is an array of the keys of that inner hash.
- @msgstrkeys = keys %$ref;
+ my @msgstrkeys = keys %$ref;
# do we have more than one such key?
if ( $#msgstrkeys > 0 ) {
# do we have more than one such key?
if ( $#msgstrkeys > 0 ) {