7202
+ 鐃緒申��申鐃緒申 1 #!/usr/bin/perl
+ 鐃緒申��申鐃緒申 2
9412
+ 鐃緒申��申鐃緒申 3 # Copyright 2003-2004 Nathan Walp <faceprint@faceprint.com>
7202
+ 鐃緒申��申鐃緒申 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
9413
+ 鐃緒申��申鐃緒申 21 my $PACKAGE="gaim";
9412
+ 鐃緒申��申鐃緒申 22
+ 鐃緒申��申鐃緒申 23
7202
+ 鐃緒申��申鐃緒申 24 use Locale::Language;
+ 鐃緒申��申鐃緒申 25
10058
+ 鐃緒申��申鐃緒申 26 $lang{en_AU} = "English (Australian)";
8860
+ 鐃緒申��申鐃緒申 27 $lang{en_CA} = "English (Canadian)";
8033
+ 鐃緒申��申鐃緒申 28 $lang{en_GB} = "English (British)";
7548
+ 鐃緒申��申鐃緒申 29 $lang{pt_BR} = "Portuguese (Brazilian)";
7202
+ 鐃緒申��申鐃緒申 30 $lang{'sr@Latn'} = "Serbian (Latin)";
+ 鐃緒申��申鐃緒申 31 $lang{zh_CN} = "Chinese (Simplified)";
+ 鐃緒申��申鐃緒申 32 $lang{zh_TW} = "Chinese (Traditional)";
+ 鐃緒申��申鐃緒申 33
+ 鐃緒申��申鐃緒申 34 opendir(DIR, ".") || die "can't open directory: $!";
+ 鐃緒申��申鐃緒申 35 @pos = grep { /\.po$/ && -f } readdir(DIR);
+ 鐃緒申��申鐃緒申 36 foreach (@pos) { s/\.po$//; };
+ 鐃緒申��申鐃緒申 37 closedir DIR;
+ 鐃緒申��申鐃緒申 38
+ 鐃緒申��申鐃緒申 39 @pos = sort @pos;
+ 鐃緒申��申鐃緒申 40
+ 鐃緒申��申鐃緒申 41 $now = `date`;
+ 鐃緒申��申鐃緒申 42
+ 鐃緒申��申鐃緒申 43 system("./update.pl --pot > /dev/null");
+ 鐃緒申��申鐃緒申 44
9412
+ 鐃緒申��申鐃緒申 45 $_ = `msgfmt --statistics $PACKAGE.pot -o /dev/null 2>&1`;
7202
+ 鐃緒申��申鐃緒申 46
+ 鐃緒申��申鐃緒申 47 die "unable to get total: $!" unless (/(\d+) untranslated messages/);
+ 鐃緒申��申鐃緒申 48
+ 鐃緒申��申鐃緒申 49 $total = $1;
+ 鐃緒申��申鐃緒申 50
+ 鐃緒申��申鐃緒申 51 print "<html>\n";
9765
+ 鐃緒申��申鐃緒申 52 print "<head><title>$PACKAGE i18n statistics</title></head>\n";
7202
+ 鐃緒申��申鐃緒申 53 print "<body>\n";
+ 鐃緒申��申鐃緒申 54 print "<table cellspacing='0' cellpadding='0' border='0' bgcolor='#888888' width='100%'><tr><td><table cellspacing='1' cellpadding='2' border='0' width='100%'>\n";
+ 鐃緒申��申鐃緒申 55
8168
+ 鐃緒申��申鐃緒申 56 print"<tr bgcolor='#e0e0e0'><th>language</th><th style='background: #339933;'>trans</th><th style='background: #339933;'>%</th><th style='background: #333399;'>fuzzy</th><th style='background: #333399;'>%</th><th style='background: #dd3333;'>untrans</th><th style='background: #dd3333;'>%</th><th> </th></tr>\n";
7202
+ 鐃緒申��申鐃緒申 57
+ 鐃緒申��申鐃緒申 58 foreach $index (0 .. $#pos) {
+ 鐃緒申��申鐃緒申 59 $trans = $fuzz = $untrans = 0;
+ 鐃緒申��申鐃緒申 60 $po = $pos[$index];
7739
+ 鐃緒申��申鐃緒申 61 print STDERR "$po..." if($ARGV[0] eq '-v');
9412
+ 鐃緒申��申鐃緒申 62 system("msgmerge $po.po $PACKAGE.pot -o $po.new 2>/dev/null");
7739
+ 鐃緒申��申鐃緒申 63 $_ = `msgfmt --statistics $po.new -o /dev/null 2>&1`;
7202
+ 鐃緒申��申鐃緒申 64 chomp;
9765
+ 鐃緒申��申鐃緒申 65 if(/(\d+) translated message/) { $trans = $1; }
+ 鐃緒申��申鐃緒申 66 if(/(\d+) fuzzy translation/) { $fuzz = $1; }
+ 鐃緒申��申鐃緒申 67 if(/(\d+) untranslated message/) { $untrans = $1; }
7202
+ 鐃緒申��申鐃緒申 68 $transp = 100 * $trans / $total;
+ 鐃緒申��申鐃緒申 69 $fuzzp = 100 * $fuzz / $total;
+ 鐃緒申��申鐃緒申 70 $untransp = 100 * $untrans / $total;
+ 鐃緒申��申鐃緒申 71 if($index % 2) {
+ 鐃緒申��申鐃緒申 72 $color = " bgcolor='#e0e0e0'";
+ 鐃緒申��申鐃緒申 73 } else {
+ 鐃緒申��申鐃緒申 74 $color = " bgcolor='#d0e0ff'";
+ 鐃緒申��申鐃緒申 75 }
+ 鐃緒申��申鐃緒申 76 $name = "";
+ 鐃緒申��申鐃緒申 77 $name = $lang{$po};
+ 鐃緒申��申鐃緒申 78 $name = code2language($po) unless $name ne "";
+ 鐃緒申��申鐃緒申 79 $name = "???" unless $name ne "";
8168
+ 鐃緒申��申鐃緒申 80 printf "<tr$color><td>%s(%s.po)</td><td>%d</td><td>%0.2f</td><td>%d</td><td>%0.2f</td><td>%d</td><td>%0.2f</td><td>",
+ 鐃緒申��申鐃緒申 81 $name, $po, $trans, $transp, $fuzz, $fuzzp, $untrans, $untransp;
7243
+ 鐃緒申��申鐃緒申 82 printf "<img src='bar_g.gif' height='15' width='%0.0f' />", $transp*2
+ 鐃緒申��申鐃緒申 83 unless $transp*2 < 0.5;
+ 鐃緒申��申鐃緒申 84 printf "<img src='bar_b.gif' height='15' width='%0.0f' />", $fuzzp*2
+ 鐃緒申��申鐃緒申 85 unless $fuzzp*2 < 0.5;
+ 鐃緒申��申鐃緒申 86 printf "<img src='bar_r.gif' height='15' width='%0.0f' />", $untransp*2
+ 鐃緒申��申鐃緒申 87 unless $untransp*2 < 0.5;
+ 鐃緒申��申鐃緒申 88 print "</tr>\n";
7739
+ 鐃緒申��申鐃緒申 89 unlink("$po.new");
8060
+ 鐃緒申��申鐃緒申 90 print STDERR "done ($untrans untranslated strings).\n" if($ARGV[0] eq '-v');
7202
+ 鐃緒申��申鐃緒申 91 }
+ 鐃緒申��申鐃緒申 92 print "</table></td></tr></table>\n";
9412
+ 鐃緒申��申鐃緒申 93 print "Latest $PACKAGE.pot generated $now: <a href='$PACKAGE.pot'>$PACKAGE.pot</a><br />\n";
7202
+ 鐃緒申��申鐃緒申 94 print "</body>\n";
+ 鐃緒申��申鐃緒申 95 print "</html>\n";
+ 鐃緒申��申鐃緒申 96