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',
22 # 'he.po' => 'Hebrew',
23 'hu.po' => 'Hungarian',
24 'id_ID.po' => 'Indonesian',
26 'ja.po' => 'Japanese',
27 # 'lt.po' => 'Lithuanian',
28 'nb.po' => 'Norwegian Bokmål',
31 'pt_BR.po' => 'Brazilian Portuguese',
32 # 'pt_PT.po' => 'Portuguese',
33 'ro.po' => 'Romanian',
38 # 'uk.po' => 'Ukrainian',
39 # 'zh_CN.po' => 'Simplified Chinese',
40 'zh_TW.po' => 'Traditional Chinese',
44 # 'bg.po' => 'Yasen Pramatarov <yasen@lindeas.com>',
45 'ca.po' => 'David Medina <opensusecatala@gmail.com>',
46 'cs.po' => 'David Vachulka <david@konstrukce-cad.com>',
47 'da.po' => 'Erik P. Olsen <epodata@gmail.com>',
48 'de.po' => 'Simon Legner <simon.legner@gmail.com>',
49 'en_GB.po' => 'Paul Mangan <paul@claws-mail.org>',
50 # 'eo.po' => 'Sian Mountbatten <poenikatu@fastmail.co.uk>',
51 'es.po' => 'Ricardo Mones Lastra <ricardo@mones.org>',
52 'fi.po' => 'Flammie Pirinen <flammie@iki.fi>',
53 'fr.po' => 'Tristan Chabredier <wwp@claws-mail.org>',
54 # 'he.po' => 'Isratine Citizen <genghiskhan@gmx.ca>',
55 'hu.po' => 'Páder Rezső <rezso@rezso.net>',
56 'id_ID.po' => 'MSulchan Darmawan <bleketux@gmail.com>',
57 'it.po' => 'Luigi Votta <luigi.vtt@gmail.com>',
58 'ja.po' => 'UTUMI Hirosi <utuhiro78@yahoo.co.jp>',
59 # 'lt.po' => 'Mindaugas Baranauskas <embar@super.lt>',
60 'nb.po' => 'Petter Adsen <petter@synth.no>',
61 'nl.po' => 'Marcel Pol <mpol@gmx.net>',
62 'pl.po' => 'Jakub Jankiewicz <jcubic@jcubic.pl>',
63 'pt_BR.po' => 'Frederico Goncalves Guimaraes <fggdebian@yahoo.com.br>',
64 # 'pt_PT.po' => 'Tiago Faria <gouki@goukihq.org>',
65 'ro.po' => 'Cristian Secară <liste@secarica.ro>',
66 'ru.po' => 'Mikhail Kurinnoi <viewizard@viewizard.com>',
67 'sk.po' => 'Slavko <slavino@slavino.sk>',
68 'sv.po' => 'Andreas Rönnquist <gusnan@openmailbox.org>',
69 'tr.po' => 'Numan Demirdöğen <if.gnu.linux@gmail.com>',
70 # 'uk.po' => 'YUP <yupadmin@gmail.com>',
71 # 'zh_CN.po' => 'Rob <rbnwmk@gmail.com>',
72 'zh_TW.po' => 'Mark Chang <mark.cyj@gmail.com>',
77 partially
=> 'lightblue',
83 partially
=> 'lightgrey', # ligth red '#FFA0A0',
84 completed
=> 'grey', # darker red '#FF7070',
87 %barcolorcheat = ( # remarks translations with revision dates in the future
89 partially
=> 'yellow',
93 $barwidth = 500; # pixels
94 $barheight = 12; # pixels
96 $transolddays = 120; # days to consider a translation is old, so probably unmaintained.
97 $transoldmonths = $transolddays / 30;
98 $transneedthresold = 0.75; # percent/100
100 $msgfmt = '/usr/bin/msgfmt';
102 $averagestr = 'Project average';
103 $contactaddress = 'translations@thewildbeast.co.uk';
105 # $pagehead = '../../claws.i18n.head.php';
106 # $pagetail = '../../claws.i18n.tail.php';
108 # code begins here ----------------------------------------------------------
109 sub get_current_date
{
110 $date = `date --utc`;
112 $date =~ /(\S+)(\s+)(\S+)(\s+)(\S+)(\s+)(\S+)(\D+)(\d+)/;
113 $datetimenow = "$5-$3-$9 at $7"."$8";
117 my ($y, $m, $d) = @_;
118 return ($y * 365) + ($m * 31) + $d;
121 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime(time);
124 $cage = get_trans_age
($year,$mon,$mday); # get current "age"
126 # drawing a language status row
128 my ($lang, $person, $trans, $fuzzy, $untrans, $tage, $oddeven) = @_;
129 $total = $trans + $fuzzy + $untrans;
130 if ($tage == 0) { $tage = $cage; } # hack for average translation
131 print STDERR
$cage, " ", $tage, "\n";
132 if (($cage - $tage) < 0) {
133 $barcolor = \
%barcolorcheat;
135 $barcolor = (($cage - $tage) > $transolddays)? \
%barcoloraged : \
%barcolornorm ;
138 if (/(.+)\s+\<(.+)\>/) { $pname = $1; $pemail = $2; } else { $pname = $pemail = $contactaddress; }
140 if ($oddeven > 0) { print " bgcolor=#EFEFEF"; }
142 if ($lang eq $averagestr) {
143 print "<b>$lang</b>";
145 print "<a href=\"mailto:%22$pname%22%20<$pemail>\">$lang</a>";
148 print "<td>\n<table style='border: solid 1px black; width: $barwidth' border='0' cellspacing='0' cellpadding='0'><tr>\n";
149 $barlen = ($trans / $total) * $barwidth;
150 print "<td style='width:$barlen", "px; height:$barheight", "px;' bgcolor=\"$$barcolor{completed}\"></td>\n";
151 $barlen2 = ($fuzzy / $total) * $barwidth;
152 print "<td style='width:$barlen2", "px' bgcolor=\"$$barcolor{partially}\"></td>\n";
153 $barlen3 = $barwidth - $barlen2 - $barlen;
154 print "<td style='width:$barlen3", "px' bgcolor=\"$$barcolor{default}\"></td>\n";
155 print "</tr>\n</table>\n</td>\n\n<td style='text-align: right'>", int(($trans / $total) * 10000) / 100, "%</td
>\n";
156 $transtatus = (($trans / $total) < $transneedthresold)? '<font size="+1" color="red
"> * </font>': '';
157 print "<td
>$transtatus</td>\n</tr
>\n";
162 return (($i > 9)? "$i" : "0$i");
167 # get project version from changelog (project dependent code :-/ )
168 $_ = `head -1 ../ChangeLog`;
169 if (/\S+\s+\S+\s+(\S+)/) { $genversion = $1; } else { $genversion = 'Unknown'; }
171 $numlang = keys(%langname);
173 # print `cat $pagehead`;
177 # removed for being included
181 print qq ~<div
class=indent
>
182 <b
>Translation Status
(on
$datetimenow for $genversion)</b
>
184 <table cellspacing
=0 cellpadding
=2>~;
187 print qq ~<tr bgcolor
=#cccccc>
188 <th align
=left
>Language
</th
>
189 <th
>Translated
|Fuzzy
|Untranslated
</th
>
195 opendir(PODIR
, ".") || die("Error: can't open current directory\n");
196 push(@pofiles,(readdir(PODIR
)));
199 @sorted_pofiles = sort(@pofiles);
201 $alang = $atran = $afuzz = $auntr = $oddeven = 0;
202 foreach $pofile (@sorted_pofiles) {
204 if (/.+\.po$/ && defined($langname{$pofile}) ) {
205 print STDERR
"Processing $_\n"; # be a little informative
207 $transage = $tran = $fuzz = $untr = 0;
208 $_ = `$msgfmt -c --statistics -o /dev/null $pofile 2>&1`;
209 if (/([0-9]+)\s+translated/) {
212 if (/([0-9]+)\s+fuzzy/) {
215 if (/([0-9]+)\s+untranslated/) {
218 # print STDERR "Translated [$tran] Fuzzy [$fuzz] Untranslated [$untr]\n";
222 if ($pofile eq "en_GB.po") {
228 $_ = `grep 'PO-Revision-Date:' $pofile | cut -f2 -d:`;
229 if (/\s+(\d+)\-(\d+)\-(\d+)/) {
230 $transage = get_trans_age
($1,$2,$3);
233 print_lang
($langname{$pofile},$lasttranslator{$pofile},$tran,$fuzz,$untr,$transage, $oddeven);
234 if ($oddeven == 1) { $oddeven = 0 } else { $oddeven++; }
238 # average results for the project
239 print "<tr>\n<td colspan=3 height=8></td>\n<tr>";
240 print_lang
($averagestr,'',$atran,$afuzz,$auntr,0,0);
246 # print "<br>Number of languages supported: $alang <br>";
248 # Languages marked with <font size="+1" color="red"> *</font>
249 # really need your help to be completed.
251 # The ones with grey bars are <i>probably unmaintained</i> because
252 # translation is more than $transoldmonths months old, anyway, trying
253 # to contact current translator first is usually a good idea before
254 # submitting an updated one.<p><b>NOTE</b>: if you are the translator
255 # of one of them and don't want to see your language bar in grey you
256 # should manually update the <tt>PO-Revision-Date</tt> field in the .po
257 # file header (or, alternatively, use a tool which does it for you).
262 # print `cat $pagetail`;
266 # removed for being included