fix check for mail at start-up
[claws.git] / tools / claws.i18n.status.pl
blobabc81316ea020b19601d315e5db1456f42127c77
1 #!/usr/bin/perl -w
3 # claws.i18n.stats.pl - Generate statistics for Claws Mail po directory.
4 #
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 -----------------------------------------------------------------
11 %langname = (
12 # 'bg.po' => 'Bulgarian',
13 'ca.po' => 'Catalan',
14 'cs.po' => 'Czech',
15 'da.po' => 'Danish',
16 'de.po' => 'German',
17 'en_GB.po' => 'British English',
18 # 'eo.po' => 'Esperanto',
19 'es.po' => 'Spanish',
20 'fi.po' => 'Finnish',
21 'fr.po' => 'French',
22 # 'he.po' => 'Hebrew',
23 'hu.po' => 'Hungarian',
24 'id_ID.po' => 'Indonesian',
25 'it.po' => 'Italian',
26 'ja.po' => 'Japanese',
27 # 'lt.po' => 'Lithuanian',
28 'nb.po' => 'Norwegian Bokm&aring;l',
29 'nl.po' => 'Dutch',
30 'pl.po' => 'Polish',
31 'pt_BR.po' => 'Brazilian Portuguese',
32 # 'pt_PT.po' => 'Portuguese',
33 'ro.po' => 'Romanian',
34 'ru.po' => 'Russian',
35 'sk.po' => 'Slovak',
36 'sv.po' => 'Swedish',
37 'tr.po' => 'Turkish',
38 # 'uk.po' => 'Ukrainian',
39 # 'zh_CN.po' => 'Simplified Chinese',
40 'zh_TW.po' => 'Traditional Chinese',
43 %lasttranslator = (
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&aacute;der Rezs&#337; <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&#259; <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>',
75 %barcolornorm = (
76 default => 'white',
77 partially => 'lightblue',
78 completed => 'blue',
81 %barcoloraged = (
82 default => 'white',
83 partially => 'lightgrey', # ligth red '#FFA0A0',
84 completed => 'grey', # darker red '#FF7070',
87 %barcolorcheat = ( # remarks translations with revision dates in the future
88 default => 'white',
89 partially => 'yellow',
90 completed => 'red',
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`;
111 chop $date;
112 $date =~ /(\S+)(\s+)(\S+)(\s+)(\S+)(\s+)(\S+)(\D+)(\d+)/;
113 $datetimenow = "$5-$3-$9 at $7"."$8";
116 sub get_trans_age {
117 my ($y, $m, $d) = @_;
118 return ($y * 365) + ($m * 31) + $d;
121 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime(time);
122 $year += 1900;
123 $mon++;
124 $cage = get_trans_age($year,$mon,$mday); # get current "age"
126 # drawing a language status row
127 sub print_lang {
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;
134 } else {
135 $barcolor = (($cage - $tage) > $transolddays)? \%barcoloraged : \%barcolornorm ;
137 $_ = $person;
138 if (/(.+)\s+\<(.+)\>/) { $pname = $1; $pemail = $2; } else { $pname = $pemail = $contactaddress; }
139 print "<tr";
140 if ($oddeven > 0) { print " bgcolor=#EFEFEF"; }
141 print ">\n<td>\n";
142 if ($lang eq $averagestr) {
143 print "<b>$lang</b>";
144 } else {
145 print "<a href=\"mailto:%22$pname%22%20<$pemail>\">$lang</a>";
147 print "</td>\n";
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";
160 sub tens {
161 my ($i) = @_;
162 return (($i > 9)? "$i" : "0$i");
165 get_current_date();
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`;
175 # make it a here-doc
176 #print <<ENDOFHEAD;
177 # removed for being included
178 #ENDOFHEAD
180 # start
181 print qq ~<div class=indent>
182 <b>Translation Status (on $datetimenow for $genversion)</b>
183 <div class=indent>
184 <table cellspacing=0 cellpadding=2>~;
186 # table header
187 print qq ~<tr bgcolor=#cccccc>
188 <th align=left>Language</th>
189 <th>Translated|Fuzzy|Untranslated</th>
190 <th>Percent</th>
191 <th></th>
192 </tr>~;
194 # get files
195 opendir(PODIR, ".") || die("Error: can't open current directory\n");
196 push(@pofiles,(readdir(PODIR)));
197 closedir(PODIR);
199 @sorted_pofiles = sort(@pofiles);
200 # iterate them
201 $alang = $atran = $afuzz = $auntr = $oddeven = 0;
202 foreach $pofile (@sorted_pofiles) {
203 $_ = $pofile;
204 if (/.+\.po$/ && defined($langname{$pofile}) ) {
205 print STDERR "Processing $_\n"; # be a little informative
206 ++$alang;
207 $transage = $tran = $fuzz = $untr = 0;
208 $_ = `$msgfmt -c --statistics -o /dev/null $pofile 2>&1`;
209 if (/([0-9]+)\s+translated/) {
210 $tran = $1;
212 if (/([0-9]+)\s+fuzzy/) {
213 $fuzz = $1;
215 if (/([0-9]+)\s+untranslated/) {
216 $untr = $1;
218 # print STDERR "Translated [$tran] Fuzzy [$fuzz] Untranslated [$untr]\n";
219 $atran += $tran;
220 $afuzz += $fuzz;
221 $auntr += $untr;
222 if ($pofile eq "en_GB.po") {
223 $tran = $tran+$fuzz;
224 $untr = "0";
225 $fuzz = "0";
226 $transage = $cage;
227 } else {
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);
242 # table footer
243 print "</table>\n";
245 # end
246 # print "<br>Number of languages supported: $alang <br>";
247 # print qq ~<p>
248 # Languages marked with <font size="+1" color="red"> *</font>
249 # really need your help to be completed.
250 # <p>
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).
258 # <br>
259 print qq ~</div>
260 </div>~;
262 # print `cat $pagetail`;
264 # make it a here-doc
265 #print <<ENDOFTAIL;
266 # removed for being included
267 #ENDOFTAIL
269 # done