3 # claws.i18n.stats.pl - Generate statistics for Claws Mail po directory.
5 # Copyright (C) 2003-2008 by Ricardo Mones <ricardo@mones.org>,
6 # Paul Mangan <paul@claws-mail.org>
7 # This program is released under the GNU General Public License.
9 # constants -----------------------------------------------------------------
12 'bg.po' => 'Bulgarian',
13 # 'ca.po' => 'Catalan',
16 'en_GB.po' => 'British English',
20 'hu.po' => 'Hungarian',
21 'id_ID.po' => 'Indonesian',
22 # 'it.po' => 'Italian',
23 # 'ja.po' => 'Japanese',
24 'lt.po' => 'Lithuanian',
26 # 'pl.po' => 'Polish',
27 'pt_BR.po' => 'Brazilian Portuguese',
28 # 'pt_PT.po' => 'Portuguese',
32 # 'uk.po' => 'Ukrainian',
33 'zh_CN.po' => 'Simplified Chinese',
34 'zh_TW.po' => 'Traditional Chinese',
38 'bg.po' => 'Yasen Pramatarov <yasen@lindeas.com>',
39 # 'ca.po' => 'Miquel Oliete <ktalanet@yahoo.es>',
40 'cs.po' => 'David Vachulka <david@konstrukce-cad.com>',
41 'de.po' => 'Thomas Bellmann <ThomasBellmann@gmx.net>',
42 'en_GB.po' => 'Paul Mangan <paul@claws-mail.org>',
43 'es.po' => 'Ricardo Mones Lastra <ricardo@mones.org>',
44 'fi.po' => 'Flammie Pirinen <flammie@iki.fi>',
45 'fr.po' => 'Tristan Chabredier <wwp@claws-mail.org>',
46 'hu.po' => 'Páder Rezső <rezso@rezso.net>',
47 'id_ID.po' => 'MSulchan Darmawan <bleketux@gmail.com>',
48 # 'it.po' => 'Andrea Spadaccini <a.spadaccini@catania.linux.it>',
49 # 'ja.po' => 'kazken3 <kazken3@gmail.com>',
50 'lt.po' => 'Mindaugas Baranauskas <embar@super.lt>',
51 # 'nl.po' => 'Marcel Pol <mpol@gmx.net>',
52 # 'pl.po' => 'Emilian Nowak <emil5@go2.pl>',
53 'pt_BR.po' => 'Frederico Goncalves Guimaraes <fggdebian@yahoo.com.br>',
54 # 'pt_PT.po' => 'Tiago Faria <gouki@goukihq.org>',
55 'ru.po' => 'Aleksei Miheev <aleksei@miheev.info>',
56 'sk.po' => 'Slavko <slavino@slavino.sk>',
57 'sv.po' => 'Andreas Rönnquist <gusnan@gusnan.se>',
58 # 'uk.po' => 'YUP <yupadmin@gmail.com>',
59 'zh_CN.po' => 'Rob <rbnwmk@gmail.com>',
60 'zh_TW.po' => 'Rob <rbnwmk@gmail.com>',
65 partially => 'lightblue',
71 partially => 'lightgrey', # ligth red '#FFA0A0',
72 completed => 'grey', # darker red '#FF7070',
75 %barcolorcheat = ( # remarks translations with revision dates in the future
77 partially => 'yellow',
81 $barwidth = 500; # pixels
82 $barheight = 12; # pixels
84 $transolddays = 120; # days to consider a translation is old, so probably unmaintained.
85 $transoldmonths = $transolddays / 30;
86 $transneedthresold = 0.75; # percent/100
88 $msgfmt = '/usr/bin/msgfmt';
90 $averagestr = 'Project average';
91 $contactaddress = 'translations@thewildbeast.co.uk';
93 # $pagehead = '../../claws.i18n.head.php';
94 # $pagetail = '../../claws.i18n.tail.php';
96 # code begins here ----------------------------------------------------------
97 sub get_current_date {
100 $date =~ /(\S+)(\s+)(\S+)(\s+)(\S+)(\s+)(\S+)(\D+)(\d+)/;
101 $datetimenow = "$5-$3-$9 at $7"."$8";
105 my ($y, $m, $d) = @_;
106 return ($y * 365) + ($m * 31) + $d;
109 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime(time);
112 $cage = get_trans_age($year,$mon,$mday); # get current "age"
114 # drawing a language status row
116 my ($lang, $person, $trans, $fuzzy, $untrans, $tage, $oddeven) = @_;
117 $total = $trans + $fuzzy + $untrans;
118 if ($tage == 0) { $tage = $cage; } # hack for average translation
119 print STDERR $cage, " ", $tage, "\n";
120 if (($cage - $tage) < 0) {
121 $barcolor = \%barcolorcheat;
123 $barcolor = (($cage - $tage) > $transolddays)? \%barcoloraged : \%barcolornorm ;
126 if (/(.+)\s+\<(.+)\>/) { $pname = $1; $pemail = $2; } else { $pname = $pemail = $contactaddress; }
128 if ($oddeven > 0) { print " bgcolor=#EFEFEF"; }
130 if ($lang eq $averagestr) {
131 print "<b>$lang</b>";
133 print "<a href=\"mailto:%22$pname%22%20<$pemail>\">$lang</a>";
136 print "<td>\n<table style='border: solid 1px black; width: $barwidth' border='0' cellspacing='0' cellpadding='0'><tr>\n";
137 $barlen = ($trans / $total) * $barwidth;
138 print "<td style='width:$barlen", "px; height:$barheight", "px;' bgcolor=\"$$barcolor{completed}\"></td>\n";
139 $barlen2 = ($fuzzy / $total) * $barwidth;
140 print "<td style='width:$barlen2", "px' bgcolor=\"$$barcolor{partially}\"></td>\n";
141 $barlen3 = $barwidth - $barlen2 - $barlen;
142 print "<td style='width:$barlen3", "px' bgcolor=\"$$barcolor{default}\"></td>\n";
143 print "</tr>\n</table>\n</td>\n\n<td style='text-align: right'>", int(($trans / $total) * 10000) / 100, "%</td>\n";
144 $transtatus = (($trans / $total) < $transneedthresold)? '<font size="+1" color="red"> * </font>': '';
145 print "<td>$transtatus</td>\n</tr>\n";
150 return (($i > 9)? "$i" : "0$i");
155 # get project version from changelog (project dependent code :-/ )
156 $_ = `head -1 ../ChangeLog`;
157 if (/\S+\s+\S+\s+(\S+)/) { $genversion = $1; } else { $genversion = 'Unknown'; }
159 $numlang = keys(%langname);
161 # print `cat $pagehead`;
165 # removed for being included
169 print qq ~<div class=indent>
170 <b>Translation Status (on $datetimenow for $genversion)</b>
172 <table cellspacing=0 cellpadding=2>~;
175 print qq ~<tr bgcolor=#cccccc>
176 <th align=left>Language</th>
177 <th>Translated|Fuzzy|Untranslated</th>
183 opendir(PODIR, ".") || die("Error: can't open current directory\n");
184 push(@pofiles,(readdir(PODIR)));
187 @sorted_pofiles = sort(@pofiles);
189 $alang = $atran = $afuzz = $auntr = $oddeven = 0;
190 foreach $pofile (@sorted_pofiles) {
192 if (/.+\.po$/ && defined($langname{$pofile}) ) {
193 print STDERR "Processing $_\n"; # be a little informative
195 $transage = $tran = $fuzz = $untr = 0;
196 $_ = `$msgfmt -c --statistics -o /dev/null $pofile 2>&1`;
197 if (/([0-9]+)\s+translated/) {
200 if (/([0-9]+)\s+fuzzy/) {
203 if (/([0-9]+)\s+untranslated/) {
206 # print STDERR "Translated [$tran] Fuzzy [$fuzz] Untranslated [$untr]\n";
210 if ($pofile eq "en_GB.po") {
216 $_ = `grep 'PO-Revision-Date:' $pofile | cut -f2 -d:`;
217 if (/\s+(\d+)\-(\d+)\-(\d+)/) {
218 $transage = get_trans_age($1,$2,$3);
221 print_lang($langname{$pofile},$lasttranslator{$pofile},$tran,$fuzz,$untr,$transage, $oddeven);
222 if ($oddeven == 1) { $oddeven = 0 } else { $oddeven++; }
226 # average results for the project
227 print "<tr>\n<td colspan=3 height=8></td>\n<tr>";
228 print_lang($averagestr,'',$atran,$afuzz,$auntr,0,0);
234 # print "<br>Number of languages supported: $alang <br>";
236 Languages marked with <font size="+1" color="red"> *</font>
237 really need your help to be completed.
239 The ones with grey bars are <i>probably unmaintained</i> because
240 translation is more than $transoldmonths months old, anyway, trying
241 to contact current translator first is usually a good idea before
242 submitting an updated one.<p><b>NOTE</b>: if you are the translator
243 of one of them and don't want to see your language bar in grey you
244 should manually update the <tt>PO-Revision-Date</tt> field in the .po
245 file header (or, alternatively, use a tool which does it for you).
250 # print `cat $pagetail`;
254 # removed for being included