diff options
author | Arnaud Desmons <adesmons@mandriva.com> | 2002-08-08 15:49:43 +0000 |
---|---|---|
committer | Arnaud Desmons <adesmons@mandriva.com> | 2002-08-08 15:49:43 +0000 |
commit | 770dfe071cdb5dee69a267858275048486f0175d (patch) | |
tree | 19eefc8890ef049eca0c7ba44a3d7a04a764e445 /wpo2po.pl | |
parent | 87be22025b6a389768602ea44567cf54fd47ca22 (diff) | |
download | drakwizard-770dfe071cdb5dee69a267858275048486f0175d.tar drakwizard-770dfe071cdb5dee69a267858275048486f0175d.tar.gz drakwizard-770dfe071cdb5dee69a267858275048486f0175d.tar.bz2 drakwizard-770dfe071cdb5dee69a267858275048486f0175d.tar.xz drakwizard-770dfe071cdb5dee69a267858275048486f0175d.zip |
old .wpo translation file to .po perl converter
Diffstat (limited to 'wpo2po.pl')
-rw-r--r-- | wpo2po.pl | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/wpo2po.pl b/wpo2po.pl new file mode 100644 index 00000000..ed84b8d3 --- /dev/null +++ b/wpo2po.pl @@ -0,0 +1,73 @@ +#!/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') { + $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>" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1" +"Content-Transfer-Encoding: 8bit"', + en => '"Language-Team: English <en@li.org>" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1" +"Content-Transfer-Encoding: 8bit"', + it => '"Language-Team: Italian <it@li.org>" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1" +"Content-Transfer-Encoding: 8bit"', + de => => '"Language-Team: Deutsh <de@li.org>" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1" +"Content-Transfer-Encoding: 8bit"', + es => => '"Language-Team: Spanish <es@li.org>" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1" +"Content-Transfer-Encoding: 8bit"'); + +print STDERR "$ARGV[0] =>"; +$ARGV[0] =~ /(.*\/).*\.(.*)\..*/; + +open(PO, "> $1$2.po"); +my $date = `date +%Y-%m-%d\\ %H:%M\\ %z`; +chomp $date; +print PO 'msgid "" +msgstr "" +'.$lang{"$2"}.' +"Project-Id-Version: drakwizard" +"POT-Creation-Date: '.$date.'" +"PO-Revision-Date: '.$date.'" +"Last-Translator: wpo2po <adesmons@mandrakesoft.com>" + +'; + +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 "$1$2.po\n"; |