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