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 /wpo2po.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 'wpo2po.pl')
-rw-r--r-- | wpo2po.pl | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/wpo2po.pl b/wpo2po.pl new file mode 100644 index 00000000..47f317db --- /dev/null +++ b/wpo2po.pl @@ -0,0 +1,82 @@ +#!/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->{to} =~ s/\\'/\\\\'/g; + $leaf->{to} =~ s/\\q/\\\\q/g; + $leaf->{to} =~ s/\\a/\\\\a/g; + $leaf->{from} =~ s/\\'/\\\\'/g; + $leaf->{from} =~ s/\\q/\\\\q/g; + $leaf->{from} =~ s/\\a/\\\\a/g; + $page->{$leaf->{from}} = $leaf->{to}; + } elsif (ref($leaf) =~ /\w\D/) { + $tag = $leaf; + } + } + $page; +} + +my $xmltree = XML::Parser->new(Style => 'Tree')->parsefile($ARGV[0]); +my $wpo = load_wpo($xmltree); + +my %lang = (fr => '"Language-Team: French <fr@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1\n" +"Content-Transfer-Encoding: 8bit\n"', + en => '"Language-Team: English <en@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1\n" +"Content-Transfer-Encoding: 8bit\n"', + it => '"Language-Team: Italian <it@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1\n" +"Content-Transfer-Encoding: 8bit\n"', + de => => '"Language-Team: German <de@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1\n" +"Content-Transfer-Encoding: 8bit\n"', + es => => '"Language-Team: Spanish <es@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1\n" +"Content-Transfer-Encoding: 8bit\n"'); + +print STDERR "$ARGV[0] =>"; +$ARGV[0] =~ m!.*/(.*)\.(.*)\.!; + +my $PO; +open($PO, "> ./po/$1_$2.po"); +my $date = `date +%Y-%m-%d\\ %H:%M%z`; +chomp $date; +print $PO 'msgid "" +msgstr "" +"Project-Id-Version: drakwizard 0.1\n" +"POT-Creation-Date: '.$date.'\n" +"PO-Revision-Date: '.$date.'\n" +"Last-Translator: Arnaud Desmons <adesmons@mandrakesoft.com>\n" +'.$lang{$2}.' +"X-Generator: wpo2pl 0.1\n" + +'; + +foreach (keys %$wpo) { + if ($_ ne "") { + if ($_ eq $wpo->{$_}) { + print $PO qq(msgid "$_"\nmsgstr ""\n\n); + } + else { + print $PO qq(msgid "$_"\nmsgstr "$wpo->{$_}"\n\n); + } + } + +} +close $PO; +print STDERR "./po/$1_$2.po\n"; |