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',
26 'pt_BR.po' => 'Brazilian Portuguese',
29 'zh_CN.po' => 'Simpilified Chinese',
33 'bg.po' => 'Yasen Pramatarov <yasen@lindeas.com>',
34 'ca.po' => 'Miquel Oliete <ktalanet@yahoo.es>',
35 'cs.po' => 'David Vachulka <david@konstrukce-cad.com>',
36 'de.po' => 'Stephan Sachse <white@dev-zero.com>',
37 'en_GB.po' => 'Paul Mangan <paul@claws-mail.org>',
38 'es.po' => 'Ricardo Mones Lastra <ricardo@mones.org>',
39 'fi.po' => 'Flammie Pirinen <flammie@iki.fi>',
40 'fr.po' => 'Tristan Chabredier <wwp@claws-mail.org>',
41 'hu.po' => 'Páder Rezső <rezso@rezso.net>',
42 'id.po' => 'MSulchan Darmawan <bleketux@gmail.com>',
43 'it.po' => 'Andrea Spadaccini <a.spadaccini@catania.linux.it>',
44 'ja.po' => 'kazken3 <kazken3@gmail.com>',
45 'nl.po' => 'Marcel Pol <mpol@gmx.net>',
46 'pl.po' => 'Emilian Nowak <emil5@go2.pl>',
47 'pt_BR.po' => 'Frederico Goncalves Guimaraes <fggdebian@yahoo.com.br>',
48 'ru.po' => 'Aleksei Miheev <aleksei@miheev.info>',
49 'sv.po' => 'Lars Persson Fink <lars.p.fink@gmail.com>',
50 'zh_CN.po' => 'Ralgh Young <bamanzi@gmail.com>',
55 partially => 'lightblue',
61 partially => 'lightgrey', # ligth red '#FFA0A0',
62 completed => 'grey', # darker red '#FF7070',
65 %barcolorcheat = ( # remarks translations with revision dates in the future
67 partially => 'yellow',
71 $barwidth = 500; # pixels
72 $barheight = 12; # pixels
74 $transolddays = 90; # days to consider a translation is old, so probably unmaintained.
75 $transoldmonths = $transolddays / 30;
76 $transneedthresold = 0.75; # percent/100
78 $msgfmt = '/usr/bin/msgfmt';
80 $averagestr = 'Project average';
81 $contactaddress = 'translations@thewildbeast.co.uk';
83 # $pagehead = '../../claws.i18n.head.php';
84 # $pagetail = '../../claws.i18n.tail.php';
86 # code begins here ----------------------------------------------------------
87 sub get_current_date {
90 $date =~ /(\S+)(\s+)(\S+)(\s+)(\S+)(\s+)(\S+)(\D+)(\d+)/;
91 $datetimenow = "$5-$3-$9 at $7"."$8";
96 return ($y * 365) + ($m * 31) + $d;
99 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime(time);
102 $cage = get_trans_age($year,$mon,$mday); # get current "age"
104 # drawing a language status row
106 my ($lang, $person, $trans, $fuzzy, $untrans, $tage, $oddeven) = @_;
107 $total = $trans + $fuzzy + $untrans;
108 if ($tage == 0) { $tage = $cage; } # hack for average translation
109 print STDERR $cage, " ", $tage, "\n";
110 if (($cage - $tage) < 0) {
111 $barcolor = \%barcolorcheat;
113 $barcolor = (($cage - $tage) > $transolddays)? \%barcoloraged : \%barcolornorm ;
116 if (/(.+)\s+\<(.+)\>/) { $pname = $1; $pemail = $2; } else { $pname = $pemail = $contactaddress; }
118 if ($oddeven > 0) { print " bgcolor=#EFEFEF"; }
120 if ($lang eq $averagestr) {
121 print "<b>$lang</b>";
123 print "<a href=\"mailto:%22$pname%22%20<$pemail>\">$lang</a>";
126 print "<td>\n<table style='border: solid 1px black; width: $barwidth' border='0' cellspacing='0' cellpadding='0'><tr>\n";
127 $barlen = ($trans / $total) * $barwidth;
128 print "<td style='width:$barlen", "px; height:$barheight", "px;' bgcolor=\"$$barcolor{completed}\"></td>\n";
129 $barlen2 = ($fuzzy / $total) * $barwidth;
130 print "<td style='width:$barlen2", "px' bgcolor=\"$$barcolor{partially}\"></td>\n";
131 $barlen3 = $barwidth - $barlen2 - $barlen;
132 print "<td style='width:$barlen3", "px' bgcolor=\"$$barcolor{default}\"></td>\n";
133 print "</tr>\n</table>\n</td>\n\n<td style='text-align: right'>", int(($trans / $total) * 10000) / 100, "%</td>\n";
134 if (($lang eq $langname{'en_GB.po'}) or ($lang eq $averagestr)) { $trans = $total; } # hack for en_GB and average results
135 $transtatus = (($trans / $total) < $transneedthresold)? '<font size="+1" color="red"> * </font>': '';
136 print "<td>$transtatus</td>\n</tr>\n";
141 return (($i > 9)? "$i" : "0$i");
146 # get project version from changelog (project dependent code :-/ )
147 $_ = `head -1 ../ChangeLog`;
148 if (/\S+\s+\S+\s+(\S+)/) { $genversion = $1; } else { $genversion = 'Unknown'; }
150 $numlang = keys(%langname);
152 # print `cat $pagehead`;
156 # removed for being included
160 print qq ~<div class=indent>
161 <b>Translation Status (on $datetimenow for $genversion)</b>
163 <table cellspacing=0 cellpadding=2>~;
166 print qq ~<tr bgcolor=#cccccc>
167 <th align=left>Language</th>
168 <th>Translated|Fuzzy|Untranslated</th>
174 opendir(PODIR, ".") || die("Error: can't open current directory\n");
175 push(@pofiles,(readdir(PODIR)));
178 @sorted_pofiles = sort(@pofiles);
180 $alang = $atran = $afuzz = $auntr = $oddeven = 0;
181 foreach $pofile (@sorted_pofiles) {
183 if (/.+\.po$/ && defined($langname{$pofile}) ) {
184 print STDERR "Processing $_\n"; # be a little informative
186 $transage = $tran = $fuzz = $untr = 0;
187 $_ = `$msgfmt -c --statistics -o /dev/null $pofile 2>&1`;
188 if (/([0-9]+)\s+translated/) {
191 if (/([0-9]+)\s+fuzzy/) {
194 if (/([0-9]+)\s+untranslated/) {
197 # print STDERR "Translated [$tran] Fuzzy [$fuzz] Untranslated [$untr]\n";
201 $_ = `grep 'PO-Revision-Date:' $pofile | cut -f2 -d:`;
202 if (/\s+(\d+)\-(\d+)\-(\d+)/) {
203 $transage = get_trans_age($1,$2,$3);
205 print_lang($langname{$pofile},$lasttranslator{$pofile},$tran,$fuzz,$untr,$transage, $oddeven);
206 if ($oddeven == 1) { $oddeven = 0 } else { $oddeven++; }
210 # average results for the project
211 print "<tr>\n<td colspan=3 height=8></td>\n<tr>";
212 print_lang($averagestr,'',$atran,$afuzz,$auntr,0,0);
218 # print "<br>Number of languages supported: $alang <br>";
220 Languages marked with <font size="+1" color="red"> *</font>
221 really need your help to be completed.
223 The ones with grey bars are <i>probably unmaintained</i> because
224 translation is more than $transoldmonths months old, anyway, trying
225 to contact current translator first is usually a good idea before
226 submitting an updated one.<p><b>NOTE</b>: if you are the translator
227 of one of them and don't want to see your language bar in grey you
228 should manually update the <tt>PO-Revision-Date</tt> field in the .po
229 file header (or, alternatively, use a tool which does it for you).
234 # print `cat $pagetail`;
238 # removed for being included