blob: a06e98b6d0e2ecc09385998c9b06ca6006eaf1a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#!/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] =~ /.*\/(.*)\.(.*)\..*/;
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 "msgid \"$_\"\nmsgstr \"\"\n\n";
}
else {
print PO "msgid \"$_\"\nmsgstr \"$wpo->{$_}\"\n\n";
}
}
}
close PO;
print STDERR "./po/$1_$2.po\n";
|