3 # Copyright 2003-2004 Nathan Walp <faceprint@faceprint.com>
4 # Adapted for Koha by Ambrose Li <acli@ada.dhs.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 50 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 $lang{en_AU
} = "English (Australian)";
28 $lang{en_CA
} = "English (Canadian)";
29 $lang{en_GB
} = "English (British)";
30 $lang{es_AR
} = "Spanish (Argentinian)";
31 $lang{fr_FR
} = "French"; # FIXME: should be just "fr"
32 $lang{it_IT
} = "Italian"; # FIXME: should be just "it"
33 $lang{my_MM
} = "Burmese (Myanmar)";
34 $lang{pl_PL
} = "Polish"; # FIXME: should be just "pl"
35 $lang{pt_BR
} = "Portuguese (Brazilian)";
36 $lang{'sr@Latn'} = "Serbian (Latin)";
37 $lang{zh_CN
} = "Chinese (Simplified)";
38 $lang{zh_TW
} = "Chinese (Traditional)";
40 $ENV{LANG
} = $ENV{LC_ALL
} = 'C';
42 opendir(DIR
, ".") || die "can't open directory: $!";
43 @pos = grep { /\.po$/ && -f
} readdir(DIR
);
44 foreach (@pos) { s/\.po$//; };
51 system("./update.pl --pot > /dev/null");
54 print "<head><title>$PACKAGE i18n statistics</title></head>\n";
57 opendir(DIR
, ".") || die "can't open directory: $!";
58 @templates = grep { /\.pot$/ && -f
} readdir(DIR
);
59 foreach (@templates) { s/\.pot$//; };
61 for my $PACKAGE (sort {
62 my($theme1, $module1) = ($1, $2) if $a =~ /^(.*)_([^_]+)$/;
63 my($theme2, $module2) = ($1, $2) if $b =~ /^(.*)_([^_]+)$/;
64 return $module1 cmp $module2 || $theme1 cmp $theme2
67 my @pos = grep { /^${PACKAGE}_/ } @pos_orig;
68 my($theme, $module) = ($1, $2) if $PACKAGE =~ /^(.*)_([^_]+)$/;
70 $_ = `msgfmt --statistics $PACKAGE.pot -o /dev/null 2>&1`;
72 die "unable to get total: $!" unless (/(\d+) untranslated messages/);
76 print "<h1>Module $module, theme $theme</h1>\n";
77 print "<table cellspacing='0' cellpadding='0' border='0' bgcolor='#888888' width='100%'><tr><td><table cellspacing='1' cellpadding='2' border='0' width='100%'>\n";
79 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";
81 foreach $index (0 .. $#pos) {
82 $trans = $fuzz = $untrans = 0;
84 next if $po =~ /_en_EN/; # Koha-specific
85 print STDERR
"$po..." if($ARGV[0] eq '-v');
86 system("msgmerge $po.po $PACKAGE.pot -o $po.new 2>/dev/null");
87 $_ = `msgfmt --statistics $po.new -o /dev/null 2>&1`;
89 if(/(\d+) translated message/) { $trans = $1; }
90 if(/(\d+) fuzzy translation/) { $fuzz = $1; }
91 if(/(\d+) untranslated message/) { $untrans = $1; }
92 $transp = 100 * $trans / $total;
93 $fuzzp = 100 * $fuzz / $total;
94 $untransp = 100 * $untrans / $total;
96 $color = " bgcolor='#e0e0e0'";
98 $color = " bgcolor='#d0e0ff'";
100 my $lang = $1 if $po =~ /^${PACKAGE}_(.*)$/; # Koha-specific
102 $name = $lang{$lang}; # NOTE
103 $name = code2language
($lang) unless $name ne ""; # NOTE
104 $name = "???" unless $name ne "";
105 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>",
106 $name, $po, $trans, $transp, $fuzz, $fuzzp, $untrans, $untransp;
107 printf "<img src='bar_g.gif' height='15' width='%0.0f' />", $transp*2
108 unless $transp*2 < 0.5;
109 printf "<img src='bar_b.gif' height='15' width='%0.0f' />", $fuzzp*2
110 unless $fuzzp*2 < 0.5;
111 printf "<img src='bar_r.gif' height='15' width='%0.0f' />", $untransp*2
112 unless $untransp*2 < 0.5;
115 print STDERR
"done ($untrans untranslated strings).\n" if($ARGV[0] eq '-v');
117 print "</table></td></tr></table>\n";
118 print "Latest $PACKAGE.pot generated $now: <a href='$PACKAGE.pot'>$PACKAGE.pot</a><br />\n";