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',
16 'en_GB.po' => 'British English',
20 'hu.po' => 'Hungarian',
21 'id.po' => 'Indonesian',
23 'ja.po' => 'Japanese',
24 'lt.po' => 'Lithuanian',
27 'pt_BR.po' => 'Brazilian Portuguese',
28 'pt_PT.po' => 'Portuguese',
32 'uk.po' => 'Ukrainian',
33 'zh_CN.po' => 'Simplified Chinese',
37 'bg.po' => 'Yasen Pramatarov <yasen@lindeas.com>',
38 'ca.po' => 'Miquel Oliete <ktalanet@yahoo.es>',
39 'cs.po' => 'David Vachulka <david@konstrukce-cad.com>',
40 'de.po' => 'Stephan Sachse <white@dev-zero.com>',
41 'en_GB.po' => 'Paul Mangan <paul@claws-mail.org>',
42 'es.po' => 'Ricardo Mones Lastra <ricardo@mones.org>',
43 'fi.po' => 'Flammie Pirinen <flammie@iki.fi>',
44 'fr.po' => 'Tristan Chabredier <wwp@claws-mail.org>',
45 'hu.po' => 'Páder Rezső <rezso@rezso.net>',
46 'id.po' => 'MSulchan Darmawan <bleketux@gmail.com>',
47 'it.po' => 'Andrea Spadaccini <a.spadaccini@catania.linux.it>',
48 'ja.po' => 'kazken3 <kazken3@gmail.com>',
49 'lt.po' => 'Mindaugas Baranauskas <embar@super.lt>',
50 'nl.po' => 'Marcel Pol <mpol@gmx.net>',
51 'pl.po' => 'Emilian Nowak <emil5@go2.pl>',
52 'pt_PT.po' => 'Tiago Faria <gouki@goukihq.org>',
53 'pt_BR.po' => 'Frederico Goncalves Guimaraes <fggdebian@yahoo.com.br>',
54 'ru.po' => 'Aleksei Miheev <aleksei@miheev.info>',
55 'sk.po' => 'Slavko <slavino@slavino.sk>',
56 'sv.po' => 'Lars Persson Fink <lars.p.fink@gmail.com>',
57 'uk.po' => 'YUP <yupadmin@gmail.com>',
58 'zh_CN.po' => 'Ralgh Young <bamanzi@gmail.com>',
63 partially => 'lightblue',
69 partially => 'lightgrey', # ligth red '#FFA0A0',
70 completed => 'grey', # darker red '#FF7070',
73 %barcolorcheat = ( # remarks translations with revision dates in the future
75 partially => 'yellow',
79 $barwidth = 500; # pixels
80 $barheight = 12; # pixels
82 $transolddays = 120; # days to consider a translation is old, so probably unmaintained.
83 $transoldmonths = $transolddays / 30;
84 $transneedthresold = 0.75; # percent/100
86 $msgfmt = '/usr/bin/msgfmt';
88 $averagestr = 'Project average';
89 $contactaddress = 'translations@thewildbeast.co.uk';
91 # $pagehead = '../../claws.i18n.head.php';
92 # $pagetail = '../../claws.i18n.tail.php';
94 # code begins here ----------------------------------------------------------
95 sub get_current_date {
98 $date =~ /(\S+)(\s+)(\S+)(\s+)(\S+)(\s+)(\S+)(\D+)(\d+)/;
99 $datetimenow = "$5-$3-$9 at $7"."$8";
103 my ($y, $m, $d) = @_;
104 return ($y * 365) + ($m * 31) + $d;
107 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime(time);
110 $cage = get_trans_age($year,$mon,$mday); # get current "age"
112 # drawing a language status row
114 my ($lang, $person, $trans, $fuzzy, $untrans, $tage, $oddeven) = @_;
115 $total = $trans + $fuzzy + $untrans;
116 if ($tage == 0) { $tage = $cage; } # hack for average translation
117 print STDERR $cage, " ", $tage, "\n";
118 if (($cage - $tage) < 0) {
119 $barcolor = \%barcolorcheat;
121 $barcolor = (($cage - $tage) > $transolddays)? \%barcoloraged : \%barcolornorm ;
124 if (/(.+)\s+\<(.+)\>/) { $pname = $1; $pemail = $2; } else { $pname = $pemail = $contactaddress; }
126 if ($oddeven > 0) { print " bgcolor=#EFEFEF"; }
128 if ($lang eq $averagestr) {
129 print "<b>$lang</b>";
131 print "<a href=\"mailto:%22$pname%22%20<$pemail>\">$lang</a>";
134 print "<td>\n<table style='border: solid 1px black; width: $barwidth' border='0' cellspacing='0' cellpadding='0'><tr>\n";
135 $barlen = ($trans / $total) * $barwidth;
136 print "<td style='width:$barlen", "px; height:$barheight", "px;' bgcolor=\"$$barcolor{completed}\"></td>\n";
137 $barlen2 = ($fuzzy / $total) * $barwidth;
138 print "<td style='width:$barlen2", "px' bgcolor=\"$$barcolor{partially}\"></td>\n";
139 $barlen3 = $barwidth - $barlen2 - $barlen;
140 print "<td style='width:$barlen3", "px' bgcolor=\"$$barcolor{default}\"></td>\n";
141 print "</tr>\n</table>\n</td>\n\n<td style='text-align: right'>", int(($trans / $total) * 10000) / 100, "%</td>\n";
142 $transtatus = (($trans / $total) < $transneedthresold)? '<font size="+1" color="red"> * </font>': '';
143 print "<td>$transtatus</td>\n</tr>\n";
148 return (($i > 9)? "$i" : "0$i");
153 # get project version from changelog (project dependent code :-/ )
154 $_ = `head -1 ../ChangeLog`;
155 if (/\S+\s+\S+\s+(\S+)/) { $genversion = $1; } else { $genversion = 'Unknown'; }
157 $numlang = keys(%langname);
159 # print `cat $pagehead`;
163 # removed for being included
167 print qq ~<div class=indent>
168 <b>Translation Status (on $datetimenow for $genversion)</b>
170 <table cellspacing=0 cellpadding=2>~;
173 print qq ~<tr bgcolor=#cccccc>
174 <th align=left>Language</th>
175 <th>Translated|Fuzzy|Untranslated</th>
181 opendir(PODIR, ".") || die("Error: can't open current directory\n");
182 push(@pofiles,(readdir(PODIR)));
185 @sorted_pofiles = sort(@pofiles);
187 $alang = $atran = $afuzz = $auntr = $oddeven = 0;
188 foreach $pofile (@sorted_pofiles) {
190 if (/.+\.po$/ && defined($langname{$pofile}) ) {
191 print STDERR "Processing $_\n"; # be a little informative
193 $transage = $tran = $fuzz = $untr = 0;
194 $_ = `$msgfmt -c --statistics -o /dev/null $pofile 2>&1`;
195 if (/([0-9]+)\s+translated/) {
198 if (/([0-9]+)\s+fuzzy/) {
201 if (/([0-9]+)\s+untranslated/) {
204 # print STDERR "Translated [$tran] Fuzzy [$fuzz] Untranslated [$untr]\n";
208 if ($pofile eq "en_GB.po") {
214 $_ = `grep 'PO-Revision-Date:' $pofile | cut -f2 -d:`;
215 if (/\s+(\d+)\-(\d+)\-(\d+)/) {
216 $transage = get_trans_age($1,$2,$3);
219 print_lang($langname{$pofile},$lasttranslator{$pofile},$tran,$fuzz,$untr,$transage, $oddeven);
220 if ($oddeven == 1) { $oddeven = 0 } else { $oddeven++; }
224 # average results for the project
225 print "<tr>\n<td colspan=3 height=8></td>\n<tr>";
226 print_lang($averagestr,'',$atran,$afuzz,$auntr,0,0);
232 # print "<br>Number of languages supported: $alang <br>";
234 Languages marked with <font size="+1" color="red"> *</font>
235 really need your help to be completed.
237 The ones with grey bars are <i>probably unmaintained</i> because
238 translation is more than $transoldmonths months old, anyway, trying
239 to contact current translator first is usually a good idea before
240 submitting an updated one.<p><b>NOTE</b>: if you are the translator
241 of one of them and don't want to see your language bar in grey you
242 should manually update the <tt>PO-Revision-Date</tt> field in the .po
243 file header (or, alternatively, use a tool which does it for you).
248 # print `cat $pagetail`;
252 # removed for being included