grim/guifications2

Doing this so I can fix our tarball
org.guifications.gf2 gf_2_13beta7
2007-05-01, John Bailey
d9f3834d8f71
file isExecutable
Doing this so I can fix our tarball
#!/usr/bin/perl
# xmlstats.pl - Generates translation stats in xml
# Copyright 2005 Gary Kramlich <grim@reaperworld.com>
#
# Based on stats.pl from Guifications cvs
#
# Copyright 2003 Nathan Walp <faceprint@faceprint.com>
#
# Parts Copyright 2004 Gary Kramlich <grim@reaperworld.com>
# Parts Copyright 2004 Stu Tomlinson <stu@nosnilmot.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 50 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
use Locale::Language;
$PACKAGE = "guifications";
$start = time;
$lang{en_CA} = "English (Canadian)";
$lang{en_GB} = "English (British)";
$lang{en_AU} = "English (Australian)";
$lang{pt_BR} = "Portuguese (Brazilian)";
$lang{'sr@Latn'} = "Serbian (Latin)";
$lang{sv_SE} = "Swedish (Sweden)";
$lang{zh_CN} = "Chinese (Simplified)";
$lang{zh_TW} = "Chinese (Traditional)";
opendir(DIR, ".") || die "can't open directory: $!";
@pos = grep { /\.po$/ && -f } readdir(DIR);
foreach (@pos) { s/\.po$//; };
closedir DIR;
@pos = sort @pos;
$now = `date`;
system("./update.pl --pot > /dev/null");
$_ = `msgfmt --statistics $PACKAGE.pot -o /dev/null 2>&1`;
die "unable to get total: $!" unless (/(\d+) untranslated messages/);
$total = $1;
print "<?xml version=\"1.0\"?>\n";
print "<l10n:package name='$PACKAGE' pot='$PACKAGE.pot' strings='$total'>\n";
foreach $index (0 .. $#pos) {
$trans = $fuzz = $untrans = 0;
$po = $pos[$index];
print STDERR "$po..." if($ARGV[0] eq '-v');
system("msgmerge $po.po $PACKAGE.pot -o $po.new 2>/dev/null");
$_ = `msgfmt --statistics $po.new -o /dev/null 2>&1`;
chomp;
if(/(\d+) translated message/) { $trans = $1; }
if(/(\d+) fuzzy translation/) { $fuzz = $1; }
if(/(\d+) untranslated message/) { $untrans = $1; }
$name = "";
$name = $lang{$po};
$name = code2language($po) unless $name ne "";
$name = "???" unless $name ne "";
print "\t<l10n:lang name='$name' code='$po'";
if($trans > 0) {
printf " translated='%d'", $trans;
}
if($fuzz > 0) {
printf " fuzzy='%d'", $fuzz;
}
if($untrans > 0) {
printf " untranslated='%d'", $untrans;
}
print "/>\n";
unlink("$po.new");
print STDERR "done ($untrans untranslated strings).\n" if($ARGV[0] eq '-v');
}
# Get the GMT offset.
# We multiple by negative one to represent the offset correctly.
# For example: GMT-5;
# at 5pm in GMT-5 it's 10pm in GMT
# so 10 - 5 becomes positive 5 which could be interpreted as GMT+5
($ls, $lm, $lh) = localtime();
($gs, $gm, $gh) = gmtime();
$gmtoff = ($gh - $lh) * -1;
$now = time;
$elapsed = $now - $start;
print "\t<l10n:generated at='$now' in='$elapsed' gmt='$gmtoff'/>\n";
print "</l10n:package>\n";