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