diff options
author | Dexter Morgan <dmorgan@mageia.org> | 2011-06-02 20:51:50 +0000 |
---|---|---|
committer | Dexter Morgan <dmorgan@mageia.org> | 2011-06-02 20:51:50 +0000 |
commit | f1d6b8a9d3c06f74e904959887cf043d09aff687 (patch) | |
tree | 969cb9fdc3becc19b1f2a21c3a9e3cc2e15f39e6 /wiz2fake_c.pl | |
download | drakwizard-f1d6b8a9d3c06f74e904959887cf043d09aff687.tar drakwizard-f1d6b8a9d3c06f74e904959887cf043d09aff687.tar.gz drakwizard-f1d6b8a9d3c06f74e904959887cf043d09aff687.tar.bz2 drakwizard-f1d6b8a9d3c06f74e904959887cf043d09aff687.tar.xz drakwizard-f1d6b8a9d3c06f74e904959887cf043d09aff687.zip |
Branch for updates
Diffstat (limited to 'wiz2fake_c.pl')
-rwxr-xr-x | wiz2fake_c.pl | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/wiz2fake_c.pl b/wiz2fake_c.pl new file mode 100755 index 00000000..879f9539 --- /dev/null +++ b/wiz2fake_c.pl @@ -0,0 +1,50 @@ +#!/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] => "; +my $fullname = $ARGV[0] . "_.c"; + +my $PO; +open($PO, "> $fullname"); + +foreach (keys %$wpo) { +# print "$_\n"; + $_ ne "" and print $PO qq(printf(_("$_"));\n); +} +close $PO; +print STDERR "$fullname\n"; |