From a3062960c7b75c0fc4229b3f5bb0647c2dffde02 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 29 Apr 2018 22:12:25 +0200 Subject: [PATCH] TOOLS: PRINCE: Initial code for POT parser --- engines/prince/po-parse.pl | 99 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 engines/prince/po-parse.pl diff --git a/engines/prince/po-parse.pl b/engines/prince/po-parse.pl new file mode 100644 index 00000000..27d90e8c --- /dev/null +++ b/engines/prince/po-parse.pl @@ -0,0 +1,99 @@ +#!perl + +# Generate .po file for The Prince and the Coward game + +use utf8; + +sub process_inv($); +sub process_varia($); +sub process_mob($); +sub process_credits($); +sub process_talk($); + +use open qw/:std :utf8/; + +if ($#ARGV != 1) { + die "Usage: $0 "; +} + +my %data; + +my $lang = $ARGV[0]; + +my $fname = ""; +my $idx1 = ""; +my $idx2 = ""; +my $seenheader = 0; + +my %data; + +while (<$ARGV[1]>) { + chomp; + + if (/^#: ([^:]]+):(\d+)$/) { + $fname = $1; + $idx1 = $2; + + $seenheader = 1; + + next; + } + + if (/^msgid (.*)$/) { + my $s = $1; + + $s =~ s/(^")|("$)//g; + $s =~ s/\\"/"/g; + + $data{$fname}{$idx1} = $s; + } +} + + +process_inv "invtxt.txt.out1"; +process_varia "variatxt.txt.out1"; +process_mob "mob.txt.out1"; +process_credits "credits.txt.out1"; +process_talk "talktxt.txt.out1"; + +exit; + +sub process_inv($) { + my $file = shift; + + open(*OUT, ">$file") or die "Cannot open file $file: $!"; + + close OUT; +} + +sub process_varia($) { + my $file = shift; + + open(*OUT, ">$file") or die "Cannot open file $file: $!"; + + close OUT; +} + +sub process_mob($) { + my $file = shift; + + open(*OUT, ">$file") or die "Cannot open file $file: $!"; + + close OUT; +} + +sub process_credits($) { + my $file = shift; + + open(*OUT, ">$file") or die "Cannot open file $file: $!"; + + close OUT; +} + +sub process_talk($) { + my $file = shift; + + open(*OUT, ">$file") or die "Cannot open file $file: $!"; + + close OUT; +}