Skip to content

Commit

Permalink
TOOLS: PRINCE: More files parsed from POT
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Apr 29, 2018
1 parent fdb5367 commit a3dce7d
Showing 1 changed file with 65 additions and 6 deletions.
71 changes: 65 additions & 6 deletions engines/prince/po-parse.pl
Expand Up @@ -16,21 +16,22 @@
die "Usage: $0 <language-code> <file>";
}

my %data;

my $lang = $ARGV[0];

my $fname = "";
my $idx1 = "";
my $idx2 = "";
my $seenheader = 0;

my %data;
my $inmsgid = 0;
our %data;

open IN, $ARGV[1];

while (<$ARGV[1]>) {
while (<IN>) {
chomp;

if (/^#: ([^:]]+):(\d+)$/) {
if (/^#: ([^:]+):(\d+)$/) {
$fname = $1;
$idx1 = $2;

Expand All @@ -39,13 +40,29 @@
next;
}

if (/^msgid ""$/) {
$inmsgid = 1;
next;
}

if (/^msgid (.*)$/) {
my $s = $1;

$s =~ s/(^")|("$)//g;
$s =~ s/\\"/"/g;

$data{$fname}{$idx1} = $s;

$inmsgid = 0;
}

if (/^"(.*)"$/) {
if ($inmsgid) {
$data{$fname}{$idx1} .= $1;
}
}

if (/^msgstr/) {
$inmsgid = 0;
}
}

Expand All @@ -63,6 +80,12 @@ ($)

open(*OUT, ">$file") or die "Cannot open file $file: $!";

print OUT "invtxt.dat\n";

for $n (sort {$a<=>$b} keys $data{'invtxt.txt'}) {
print OUT "$n. $data{'invtxt.txt'}{$n}\n";
}

close OUT;
}

Expand All @@ -71,6 +94,12 @@ ($)

open(*OUT, ">$file") or die "Cannot open file $file: $!";

print OUT "variatxt.dat\n";

for $n (sort {$a<=>$b} keys $data{'variatxt.txt'}) {
print OUT "$n. $data{'variatxt.txt'}{$n}\n";
}

close OUT;
}

Expand All @@ -79,6 +108,28 @@ ($)

open(*OUT, ">$file") or die "Cannot open file $file: $!";

print OUT "mob.lst\n";

my $pn = 0;

for $n (sort {$a<=>$b} keys $data{'mob.lst'}) {
my $p1 = int($n / 1000);

if ($p1 != $pn) {
if ($p1 > 1) {
for my $i (($pn+1)..$p1) {
print OUT "$i.\n";
}
}
$pn = $p1;
}
print OUT "$data{'mob.lst'}{$n}\n";
}

for my $i (($pn+1)..61) {
print OUT "$i.\n";
}

close OUT;
}

Expand All @@ -87,6 +138,14 @@ ($)

open(*OUT, ">$file") or die "Cannot open file $file: $!";

print OUT "credits.dat\n";

for $n (sort {$a<=>$b} keys $data{'credits.txt'}) {
$data{'credits.txt'}{$n} =~ s/\\n/\n/g;

print OUT "$data{'credits.txt'}{$n}";
}

close OUT;
}

Expand Down

0 comments on commit a3dce7d

Please sign in to comment.