3 # claws.i18n.stats.pl - Generate statistics for Claws Mail po directory.
5 # Copyright (C) 2003-2015 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',
17 # 'eo.po' => 'Esperanto',
22 'hu.po' => 'Hungarian',
23 # 'id_ID.po' => 'Indonesian',
25 # 'ja.po' => 'Japanese',
26 'lt.po' => 'Lithuanian',
27 'nb.po' => 'Norwegian Bokmål',
29 # 'pl.po' => 'Polish',
30 'pt_BR.po' => 'Brazilian Portuguese',
31 # 'pt_PT.po' => 'Portuguese',
35 # 'uk.po' => 'Ukrainian',
36 # 'zh_CN.po' => 'Simplified Chinese',
37 'zh_TW.po' => 'Traditional Chinese',
41 # 'bg.po' => 'Yasen Pramatarov <yasen@lindeas.com>',
42 'ca.po' => 'Carles Tubio Terrón <c@rles-tub.io>',
43 'cs.po' => 'David Vachulka <david@konstrukce-cad.com>',
44 'de.po' => 'Thomas Bellmann <ThomasBellmann@gmx.net>',
45 'en_GB.po' => 'Paul Mangan <paul@claws-mail.org>',
46 # 'eo.po' => 'Sian Mountbatten <poenikatu@fastmail.co.uk>',
47 'es.po' => 'Ricardo Mones Lastra <ricardo@mones.org>',
48 'fi.po' => 'Flammie Pirinen <flammie@iki.fi>',
49 'fr.po' => 'Tristan Chabredier <wwp@claws-mail.org>',
50 'he.po' => 'Isratine Citizen <genghiskhan@gmx.ca>',
51 'hu.po' => 'Páder Rezső <rezso@rezso.net>',
52 # 'id_ID.po' => 'MSulchan Darmawan <bleketux@gmail.com>',
53 'it.po' => 'Luigi Votta <luigi.vtt@gmail.com>',
54 # 'ja.po' => 'kazken3 <kazken3@gmail.com>',
55 'lt.po' => 'Mindaugas Baranauskas <embar@super.lt>',
56 'nb.po' => 'Petter Adsen <petter@synth.no>',
57 'nl.po' => 'Marcel Pol <mpol@gmx.net>',
58 # 'pl.po' => 'Emilian Nowak <emil5@go2.pl>',
59 'pt_BR.po' => 'Frederico Goncalves Guimaraes <fggdebian@yahoo.com.br>',
60 # 'pt_PT.po' => 'Tiago Faria <gouki@goukihq.org>',
61 'ru.po' => 'Mikhail Kurinnoi <viewizard@viewizard.com>',
62 'sk.po' => 'Slavko <slavino@slavino.sk>',
63 'sv.po' => 'Andreas Rönnquist <gusnan@openmailbox.org>',
64 # 'uk.po' => 'YUP <yupadmin@gmail.com>',
65 # 'zh_CN.po' => 'Rob <rbnwmk@gmail.com>',
66 'zh_TW.po' => 'Mark Chang <mark.cyj@gmail.com>',
71 partially => 'lightblue',
77 partially => 'lightgrey', # ligth red '#FFA0A0',
78 completed => 'grey', # darker red '#FF7070',
81 %barcolorcheat = ( # remarks translations with revision dates in the future
83 partially => 'yellow',
87 $barwidth = 500; # pixels
88 $barheight = 12; # pixels
90 $transolddays = 120; # days to consider a translation is old, so probably unmaintained.
91 $transoldmonths = $transolddays / 30;
92 $transneedthresold = 0.75; # percent/100
94 $msgfmt = '/usr/bin/msgfmt';
96 $averagestr = 'Project average';
97 $contactaddress = 'translations@thewildbeast.co.uk';
99 # $pagehead = '../../claws.i18n.head.php';
100 # $pagetail = '../../claws.i18n.tail.php';
102 # code begins here ----------------------------------------------------------
103 sub get_current_date {
104 $date = `date --utc`;
106 $date =~ /(\S+)(\s+)(\S+)(\s+)(\S+)(\s+)(\S+)(\D+)(\d+)/;
107 $datetimenow = "$5-$3-$9 at $7"."$8";
111 my ($y, $m, $d) = @_;
112 return ($y * 365) + ($m * 31) + $d;
115 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime(time);
118 $cage = get_trans_age($year,$mon,$mday); # get current "age"
120 # drawing a language status row
122 my ($lang, $person, $trans, $fuzzy, $untrans, $tage, $oddeven) = @_;
123 $total = $trans + $fuzzy + $untrans;
124 if ($tage == 0) { $tage = $cage; } # hack for average translation
125 print STDERR $cage, " ", $tage, "\n";
126 if (($cage - $tage) < 0) {
127 $barcolor = \%barcolorcheat;
129 $barcolor = (($cage - $tage) > $transolddays)? \%barcoloraged : \%barcolornorm ;
132 if (/(.+)\s+\<(.+)\>/) { $pname = $1; $pemail = $2; } else { $pname = $pemail = $contactaddress; }
134 if ($oddeven > 0) { print " bgcolor=#EFEFEF"; }
136 if ($lang eq $averagestr) {
137 print "<b>$lang</b>";
139 print "<a href=\"mailto:%22$pname%22%20<$pemail>\">$lang</a>";
142 print "<td>\n<table style='border: solid 1px black; width: $barwidth' border='0' cellspacing='0' cellpadding='0'><tr>\n";
143 $barlen = ($trans / $total) * $barwidth;
144 print "<td style='width:$barlen", "px; height:$barheight", "px;' bgcolor=\"$$barcolor{completed}\"></td>\n";
145 $barlen2 = ($fuzzy / $total) * $barwidth;
146 print "<td style='width:$barlen2", "px' bgcolor=\"$$barcolor{partially}\"></td>\n";
147 $barlen3 = $barwidth - $barlen2 - $barlen;
148 print "<td style='width:$barlen3", "px' bgcolor=\"$$barcolor{default}\"></td>\n";
149 print "</tr>\n</table>\n</td>\n\n<td style='text-align: right'>", int(($trans / $total) * 10000) / 100, "%</td>\n";
150 $transtatus = (($trans / $total) < $transneedthresold)? '<font size="+1" color="red"> * </font>': '';
151 print "<td>$transtatus</td>\n</tr>\n";
156 return (($i > 9)? "$i" : "0$i");
161 # get project version from changelog (project dependent code :-/ )
162 $_ = `head -1 ../ChangeLog`;
163 if (/\S+\s+\S+\s+(\S+)/) { $genversion = $1; } else { $genversion = 'Unknown'; }
165 $numlang = keys(%langname);
167 # print `cat $pagehead`;
171 # removed for being included
175 print qq ~<div class=indent>
176 <b>Translation Status (on $datetimenow for $genversion)</b>
178 <table cellspacing=0 cellpadding=2>~;
181 print qq ~<tr bgcolor=#cccccc>
182 <th align=left>Language</th>
183 <th>Translated|Fuzzy|Untranslated</th>
189 opendir(PODIR, ".") || die("Error: can't open current directory\n");
190 push(@pofiles,(readdir(PODIR)));
193 @sorted_pofiles = sort(@pofiles);
195 $alang = $atran = $afuzz = $auntr = $oddeven = 0;
196 foreach $pofile (@sorted_pofiles) {
198 if (/.+\.po$/ && defined($langname{$pofile}) ) {
199 print STDERR "Processing $_\n"; # be a little informative
201 $transage = $tran = $fuzz = $untr = 0;
202 $_ = `$msgfmt -c --statistics -o /dev/null $pofile 2>&1`;
203 if (/([0-9]+)\s+translated/) {
206 if (/([0-9]+)\s+fuzzy/) {
209 if (/([0-9]+)\s+untranslated/) {
212 # print STDERR "Translated [$tran] Fuzzy [$fuzz] Untranslated [$untr]\n";
216 if ($pofile eq "en_GB.po") {
222 $_ = `grep 'PO-Revision-Date:' $pofile | cut -f2 -d:`;
223 if (/\s+(\d+)\-(\d+)\-(\d+)/) {
224 $transage = get_trans_age($1,$2,$3);
227 print_lang($langname{$pofile},$lasttranslator{$pofile},$tran,$fuzz,$untr,$transage, $oddeven);
228 if ($oddeven == 1) { $oddeven = 0 } else { $oddeven++; }
232 # average results for the project
233 print "<tr>\n<td colspan=3 height=8></td>\n<tr>";
234 print_lang($averagestr,'',$atran,$afuzz,$auntr,0,0);
240 # print "<br>Number of languages supported: $alang <br>";
242 # Languages marked with <font size="+1" color="red"> *</font>
243 # really need your help to be completed.
245 # The ones with grey bars are <i>probably unmaintained</i> because
246 # translation is more than $transoldmonths months old, anyway, trying
247 # to contact current translator first is usually a good idea before
248 # submitting an updated one.<p><b>NOTE</b>: if you are the translator
249 # of one of them and don't want to see your language bar in grey you
250 # should manually update the <tt>PO-Revision-Date</tt> field in the .po
251 # file header (or, alternatively, use a tool which does it for you).
256 # print `cat $pagetail`;
260 # removed for being included