From a3dce7d57c0a1d87a66e95199b2a2d026f52d0df Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 29 Apr 2018 23:08:07 +0200 Subject: [PATCH] TOOLS: PRINCE: More files parsed from POT --- engines/prince/po-parse.pl | 71 ++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 6 deletions(-) diff --git a/engines/prince/po-parse.pl b/engines/prince/po-parse.pl index 27d90e8c..e359c5f3 100644 --- a/engines/prince/po-parse.pl +++ b/engines/prince/po-parse.pl @@ -16,8 +16,6 @@ die "Usage: $0 "; } -my %data; - my $lang = $ARGV[0]; my $fname = ""; @@ -25,12 +23,15 @@ my $idx2 = ""; my $seenheader = 0; -my %data; +my $inmsgid = 0; +our %data; + +open IN, $ARGV[1]; -while (<$ARGV[1]>) { +while () { chomp; - if (/^#: ([^:]]+):(\d+)$/) { + if (/^#: ([^:]+):(\d+)$/) { $fname = $1; $idx1 = $2; @@ -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; } } @@ -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; } @@ -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; } @@ -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; } @@ -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; }