summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xwiz2pot.pl47
1 files changed, 47 insertions, 0 deletions
diff --git a/wiz2pot.pl b/wiz2pot.pl
new file mode 100755
index 00000000..14a51b51
--- /dev/null
+++ b/wiz2pot.pl
@@ -0,0 +1,47 @@
+#!/usr/bin/perl
+use strict;
+use XML::Parser;
+
+
+sub load_wpo {
+ my ($tree, $tag ,$page) = @_;
+
+ foreach my $leaf (@$tree) {
+ if (ref($leaf) eq 'ARRAY') {
+ $page = load_wpo($leaf, $tag, $page);
+ } elsif (ref($leaf) eq 'HASH') {
+ # XML compatibility
+ $leaf->{helpText} =~ s/\\'/\\\\'/g;
+ $leaf->{helpText} =~ s/\\q/\\\\q/g;
+ $leaf->{helpText} =~ s/\\a/\\\\a/g;
+ $page->{$leaf->{helpText}} = "";
+ }elsif(ref($leaf)=~ /\w\D/){
+ $tag = $leaf;
+ }
+ }
+ $page;
+}
+
+my $xmltree = XML::Parser->new(Style => 'Tree')->parsefile($ARGV[0]);
+my $wpo = load_wpo($xmltree);
+
+print STDERR "$ARGV[0] =>";
+$ARGV[0] =~ /.*\/(.*)\.wiz.*/;
+
+open(PO, "> ./po/$1.pot");
+my $date = `date +%Y-%m-%d\\ %H:%M\\ %z`;
+chomp $date;
+
+foreach (keys %{$wpo}) {
+ if ($_ ne "") {
+ if ($_ eq $wpo->{$_}) {
+ print PO "msgid \"$_\"\nmsgstr \"\"\n\n";
+ }
+ else {
+ print PO "msgid \"$_\"\nmsgstr \"$wpo->{$_}\"\n\n";
+ }
+ }
+
+}
+close PO;
+print STDERR "./po/$1.pot\n";