diff options
author | Pablo Saratxaga <pablo@mandriva.com> | 2002-08-23 00:50:14 +0000 |
---|---|---|
committer | Pablo Saratxaga <pablo@mandriva.com> | 2002-08-23 00:50:14 +0000 |
commit | 584d2eca1f6fe74be87c371d99a713176965f9f9 (patch) | |
tree | 225c49c0656057e01c92a9dd7340c64120e62e4f /wiz2fake_c.pl | |
parent | 8cb296dff1704b8b7247ebe8635a54e8336edb58 (diff) | |
download | drakwizard-584d2eca1f6fe74be87c371d99a713176965f9f9.tar drakwizard-584d2eca1f6fe74be87c371d99a713176965f9f9.tar.gz drakwizard-584d2eca1f6fe74be87c371d99a713176965f9f9.tar.bz2 drakwizard-584d2eca1f6fe74be87c371d99a713176965f9f9.tar.xz drakwizard-584d2eca1f6fe74be87c371d99a713176965f9f9.zip |
copied fake_c.pl from other modules, and converted wiz2pot into
wiz2fake_c; so now the pot file can be easily rebuild to match the
source files.
Diffstat (limited to 'wiz2fake_c.pl')
-rwxr-xr-x | wiz2fake_c.pl | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/wiz2fake_c.pl b/wiz2fake_c.pl new file mode 100755 index 00000000..635eb6d9 --- /dev/null +++ b/wiz2fake_c.pl @@ -0,0 +1,49 @@ +#!/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"; + +open(PO, "> $fullname"); + +foreach (keys %{$wpo}) { +# print "$_\n"; + $_ ne "" and print PO "printf(_(\"$_\"));\n"; +} +close PO; +print STDERR "$fullname\n"; |