[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: msgfmt --statistics annoyance



Quoting Eddy Petrişor (eddy.petrisor@gmail.com):
> On 6/18/06, Christian Perrier <bubulle@debian.org> wrote:
> >
> >This is what is really used by programs when compiled.
> >
> >Attached is my "po_test" script which tests a given PO file, with regards
> >to the POT fil in the current directory. Among other things, it also
> >outputs stats about the file.
> 
> Could you publish check_vars.pl, too?


Yep.


#! /usr/bin/perl

sub getVars
{
        my $text = shift;
        my $var = '';
        while ($text =~ m/\G.*?(\$\{[^{}]+\})/g) {
                $var .= $1;
        }
        return $var;
}

$/ = "\n\n";
open (PO, "< $ARGV[0]") or die "Unable to open $ARGV[0]: $!\n";
while (<PO>)
{
        s/"\n"//g;
        (my $msgid) = m/^msgid "(.*)"$/m;
        (my $msgstr) = m/^msgstr "(.*)"$/m;
        next if $msgstr eq '' || m/^#, .*fuzzy/m;
        my $var1 = getVars($msgid);
        my $var2 = getVars($msgstr);
        print if $var1 ne $var2;
}
close (PO);

Attachment: signature.asc
Description: Digital signature


Reply to: