1#!/usr/local/bin/perl
2
3# Copyright 2003-2005 Nathan Walp <faceprint@faceprint.com>
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 50 Temple Place, Suite 330, Boston, MA 02111-1307  USA
18#
19
20# Taken from the Gaim project, modified by Angel Vidal (Kry) for the aMule project.
21
22use POSIX qw(strftime);
23
24
25my $PACKAGE="aMule";
26my $DOMAIN="amule";
27
28
29use Locale::Language;
30
31$lang{gl} = "Galician (Galiza)";
32$lang{en_AU} = "English (Australian)";
33$lang{en_CA} = "English (Canadian)";
34$lang{en_GB} = "English (British)";
35$lang{en_US} = "English (USA)";
36$lang{es_MX} = "Spanish (Mexico)";
37$lang{et_EE} = "Estonian (Estonia)";
38$lang{it_CH} = "Italian (Switzerland)";
39$lang{ko_KR} = "Korean (Korea)";
40$lang{my_MM} = "Burmese (Myanmar)";
41$lang{pt_BR} = "Portuguese (Brazilian)";
42$lang{pt_PT} = "Portuguese (Portugal)";
43$lang{'sr@Latn'} = "Serbian (Latin)";
44$lang{zh_CN} = "Chinese (Simplified)";
45$lang{zh_TW} = "Chinese (Traditional)";
46
47opendir(DIR, ".") || die "can't open directory: $!";
48@pos = grep { /\.po$/ && -f } readdir(DIR);
49foreach (@pos) { s/\.po$//; };
50closedir DIR;
51
52@pos = sort @pos;
53
54$now = `date`;
55
56system("intltool-update --pot > /dev/null");
57
58$_ = `msgfmt --statistics $DOMAIN.pot -o /dev/null 2>&1`;
59
60die "unable to get total: $!" unless (/(\d+) untranslated messages/);
61
62$total = $1;
63$generated = strftime "%Y-%m-%d %H:%M:%S", gmtime;
64$stats_generated = `date`;
65chomp($stats_generated);
66
67print "<?xml version='1.0'?>\n";
68print "<?xml-stylesheet type='text/xsl' href='l10n.xsl'?>\n";
69print "<project version='1.0' xmlns:l10n='http://faceprint.com/code/l10n' name='$PACKAGE' pofile='$DOMAIN.pot' strings='$total' generated='$generated' stats_generated='$stats_generated'>\n";
70
71foreach $index (0 .. $#pos) {
72	$trans = $fuzz = $untrans = 0;
73	$po = $pos[$index];
74	print STDERR "$po..." if($ARGV[0] eq '-v');
75	system("msgmerge $po.po $DOMAIN.pot -o $po.new 2>$po.po.warnings");
76	$_ = `msgfmt --statistics $po.new -o /dev/null 2>&1`;
77	chomp;
78	if(/(\d+) translated message/) { $trans = $1; }
79	if(/(\d+) fuzzy translation/) { $fuzz = $1; }
80	if(/(\d+) untranslated message/) { $untrans = $1; }
81	unlink("$po.new");
82
83	$warnings = `cat $po.po.warnings | grep -v done | wc -l | cut -d" " -f 1`;
84	chop($warnings);
85	unlink("$po.po.warnings") if $warnings eq "0";
86
87	$name = "";
88	$name = $lang{$po};
89	$name = code2language($po) unless $name ne "";
90	$name = "???" unless $name ne "";
91
92	print "<lang code='$po' name='$name' translated='$trans' fuzzy='$fuzz' warnings='$warnings' />\n" unless $po eq "en_GB";
93	print STDERR "done ($untrans untranslated strings).\n" if($ARGV[0] eq '-v');
94}
95
96print "</project>\n";
97
98