summaryrefslogtreecommitdiffstats
path: root/wiz2pot.pl
diff options
context:
space:
mode:
Diffstat (limited to 'wiz2pot.pl')
-rwxr-xr-xwiz2pot.pl51
1 files changed, 51 insertions, 0 deletions
diff --git a/wiz2pot.pl b/wiz2pot.pl
new file mode 100755
index 00000000..ee6357d2
--- /dev/null
+++ b/wiz2pot.pl
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+use strict;
+use XML::Parser;
+
+
+sub wrap {
+ @_[0] =~ s/\\'/\\\\'/g;
+ @_[0] =~ s/\\q/\\\\q/g;
+ @_[0] =~ s/\\a/\\\\a/g;
+ @_[0] =~ s/\\n/\\\\n/g;
+}
+
+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
+ wrap $leaf->{description};
+ wrap $leaf->{helpText};
+ wrap $leaf->{wizardTitle};
+ wrap $leaf->{nextButtonText};
+ $page->{$leaf->{wizardTitle}} = "";
+ $page->{$leaf->{helpText}} = "";
+ $page->{$leaf->{description}} = "";
+ $page->{$leaf->{nextButtonText}} = "";
+ } 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}) {
+ print "$_\n";
+ $_ ne "" and print PO "msgid \"$_\"\nmsgstr \"\"\n\n";
+}
+close PO;
+print STDERR "./po/$1.pot\n";