claws.i18n.status.pl 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. #!/usr/bin/perl -w
  2. #
  3. # claws.i18n.stats.pl - Generate statistics for Sylpheed Claws po directory.
  4. #
  5. # (c) 2003 by Ricardo Mones Lastra <mones@aic.uniovi.es>
  6. # This program is released under the GNU General Public License.
  7. #
  8. # constants -----------------------------------------------------------------
  9. %langname = (
  10. 'bg.po' => 'Bulgarian',
  11. 'ca.po' => 'Catalan',
  12. 'cs.po' => 'Czech',
  13. 'de.po' => 'German',
  14. 'el.po' => 'Greek',
  15. 'en_GB.po' => 'British English',
  16. 'es.po' => 'Spanish',
  17. 'fi.po' => 'Finnish',
  18. 'fr.po' => 'French',
  19. 'hr.po' => 'Croatian',
  20. 'hu.po' => 'Hungarian',
  21. 'it.po' => 'Italian',
  22. 'ja.po' => 'Japanese',
  23. 'ko.po' => 'Korean',
  24. 'nl.po' => 'Dutch',
  25. 'pl.po' => 'Polish',
  26. 'pt_BR.po' => 'Brazilian Portuguese',
  27. 'ru.po' => 'Russian',
  28. 'sk.po' => 'Slovak',
  29. 'sr.po' => 'Serbian',
  30. 'sv.po' => 'Swedish',
  31. 'zh_CN.po' => 'Simpilified Chinese',
  32. 'zh_TW.Big5.po' => 'Taiwanese',
  33. );
  34. %lasttranslator = (
  35. 'bg.po' => 'George Danchev <danchev@spnet.net>',
  36. 'ca.po' => 'Miquel Oliete <miqueloliete@softhome.net>',
  37. 'cs.po' => 'Radek Vybíral <Radek.Vybiral@vsb.cz>',
  38. 'de.po' => 'Thomas Gilgin <thg1@karate-muellheim.de>',
  39. 'el.po' => 'Michalis Kabrianis <Michalis@bigfoot.com>',
  40. 'en_GB.po' => 'Paul Mangan <claws@thewildbeast.co.uk>',
  41. 'es.po' => 'Ricardo Mones Lastra <mones@aic.uniovi.es>',
  42. 'fi.po' => 'Flammie Pirinen <flammie@iki.fi>',
  43. 'fr.po' => 'Fabien Vantard <fzzzzz@gmail.com>',
  44. 'hr.po' => 'Dragan Leskovar <drleskov@inet.hr>',
  45. 'hu.po' => 'Gál Zoltán <galzoli@hu.inter.net>',
  46. 'it.po' => 'Andrea Spadaccini <a.spadaccini@catania.linux.it>',
  47. 'ja.po' => 'Rui Hirokawa <rui_hirokawa@ybb.ne.jp>',
  48. 'ko.po' => 'ChiDeok, Hwang <hwang@mizi.co.kr>',
  49. 'nl.po' => 'Wilbert Berendsen <wbsoft@xs4all.nl>',
  50. 'pl.po' => 'Emilian Nowak <eminowbl@posejdon.wpk.p.lodz.pl>',
  51. 'pt_BR.po' => 'Frederico Goncalves Guimaraes <fggdebian@yahoo.com.br>',
  52. 'ru.po' => 'Pavlo Bohmat <bohm@ukr.net>',
  53. 'sk.po' => 'Andrej Kacian <andrej@kacian.sk>',
  54. 'sr.po' => 'urke <urke@users.sourceforge.net>',
  55. 'sv.po' => 'Joakim Andreasson <joakim.andreasson@gmx.net>',
  56. 'zh_CN.po' => 'Hansom Young <glyoung@users.sourceforge.net>',
  57. 'zh_TW.Big5.po' => 'Tsu-Fan Cheng <tscheng@ic.sunysb.edu>',
  58. );
  59. %barcolornorm = (
  60. default => 'white',
  61. partially => 'lightblue',
  62. completed => 'blue',
  63. );
  64. %barcoloraged = (
  65. default => 'white',
  66. partially => 'lightgrey', # ligth red '#FFA0A0',
  67. completed => 'grey', # darker red '#FF7070',
  68. );
  69. %barcolorcheat = ( # remarks translations with revision dates in the future
  70. default => 'white',
  71. partially => 'yellow',
  72. completed => 'red',
  73. );
  74. $barwidth = 300; # pixels
  75. $barheight = 12; # pixels
  76. $transolddays = 90; # days to consider a translation is old, so probably unmaintained.
  77. $transneedthresold = 0.75; # percent/100
  78. $msgfmt = '/usr/bin/msgfmt';
  79. $averagestr = 'Project average';
  80. $contactaddress = 'translations@thewildbeast.co.uk';
  81. # $pagehead = '../../claws.i18n.head.php';
  82. # $pagetail = '../../claws.i18n.tail.php';
  83. # code begins here ----------------------------------------------------------
  84. sub get_current_date {
  85. $date = `date --utc`;
  86. chop $date;
  87. $date =~ /(\S+)(\s+)(\S+)(\s+)(\S+)(\s+)(\S+)(\D+)(\d+)/;
  88. $datetimenow = "$5-$3-$9 at $7"."$8";
  89. }
  90. sub get_trans_age {
  91. my ($y, $m, $d) = @_;
  92. return ($y * 365) + ($m * 31) + $d;
  93. }
  94. ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime(time);
  95. $year += 1900;
  96. $mon++;
  97. $cage = get_trans_age($year,$mon,$mday); # get current "age"
  98. # drawing a language status row
  99. sub print_lang {
  100. my ($lang, $person, $trans, $fuzzy, $untrans, $tage) = @_;
  101. $total = $trans + $fuzzy + $untrans;
  102. if ($tage == 0) { $tage = $cage; } # hack for average translation
  103. print STDERR $cage, " ", $tage, "\n";
  104. if (($cage - $tage) < 0) {
  105. $barcolor = \%barcolorcheat;
  106. } else {
  107. $barcolor = (($cage - $tage) > $transolddays)? \%barcoloraged : \%barcolornorm ;
  108. }
  109. $_ = $person;
  110. if (/(.+)\s+\<(.+)\>/) { $pname = $1; $pemail = $2; } else { $pname = $pemail = $contactaddress; }
  111. print "<tr>\n<td>\n";
  112. if ($lang eq $averagestr) {
  113. print "<b>$lang</b>";
  114. } else {
  115. print "<a href=\"mailto:%22$pname%22%20<$pemail>\">$lang</a>";
  116. }
  117. print "</td>\n";
  118. print "<td>\n<table style='border: solid 1px black; width: $barwidth' border='0' cellspacing='0' cellpadding='0'><tr>\n";
  119. $barlen = ($trans / $total) * $barwidth;
  120. print "<td style='width:$barlen", "px; height:$barheight", "px;' bgcolor=\"$$barcolor{completed}\"></td>\n";
  121. $barlen2 = ($fuzzy / $total) * $barwidth;
  122. print "<td style='width:$barlen2", "px' bgcolor=\"$$barcolor{partially}\"></td>\n";
  123. $barlen3 = $barwidth - $barlen2 - $barlen;
  124. print "<td style='width:$barlen3", "px' bgcolor=\"$$barcolor{default}\"></td>\n";
  125. print "</tr>\n</table>\n</td>\n\n<td style='text-align: right'>", int(($trans / $total) * 10000) / 100, "%</td>\n";
  126. if (($lang eq $langname{'en_GB.po'}) or ($lang eq $averagestr)) { $trans = $total; } # hack for en_GB and average results
  127. $transtatus = (($trans / $total) < $transneedthresold)? '<font size="+1" color="red"> * </font>': '';
  128. print "<td>$transtatus</td>\n</tr>\n";
  129. }
  130. sub tens {
  131. my ($i) = @_;
  132. return (($i > 9)? "$i" : "0$i");
  133. }
  134. get_current_date();
  135. # get project version from changelog (project dependent code :-/ )
  136. $_ = `head -1 ../ChangeLog-gtk2.claws`;
  137. if (/\S+\s+\S+\s+(\S+)/) { $genversion = $1; } else { $genversion = 'Unknown'; }
  138. $numlang = keys(%langname);
  139. # print `cat $pagehead`;
  140. #
  141. # make it a here-doc
  142. #print <<ENDOFHEAD;
  143. # removed for being included
  144. #ENDOFHEAD
  145. # start
  146. print "<div class=indent>\n<b>Translation Status (on $datetimenow for $genversion)</b>\n<div class=indent>\n<table cellspacing=0 cellpadding=2>\n";
  147. # table header
  148. print "<tr bgcolor=#cccccc>\n<th align=left>Language</th>\n<th>Translated|Fuzzy|Untranslated</th>\n<th>Percent</th>\n<th>\n</th>\n</tr>\n";
  149. # get files
  150. opendir(PODIR, ".") || die("Error: can't open current directory\n");
  151. push(@pofiles,(readdir(PODIR)));
  152. closedir(PODIR);
  153. @sorted_pofiles = sort(@pofiles);
  154. # iterate them
  155. $alang = $atran = $afuzz = $auntr = 0;
  156. foreach $pofile (@sorted_pofiles) {
  157. $_ = $pofile;
  158. if (/.+\.po$/) {
  159. print STDERR "Processing $_\n"; # be a little informative
  160. ++$alang;
  161. $transage = $tran = $fuzz = $untr = 0;
  162. $_ = `$msgfmt -c --statistics -o /dev/null $pofile 2>&1`;
  163. if (/([0-9]+)\s+translated/) {
  164. $tran = $1;
  165. }
  166. if (/([0-9]+)\s+fuzzy/) {
  167. $fuzz = $1;
  168. }
  169. if (/([0-9]+)\s+untranslated/) {
  170. $untr = $1;
  171. }
  172. # print STDERR "Translated [$tran] Fuzzy [$fuzz] Untranslated [$untr]\n";
  173. $atran += $tran;
  174. $afuzz += $fuzz;
  175. $auntr += $untr;
  176. $_ = `grep 'PO-Revision-Date:' $pofile | cut -f2 -d:`;
  177. if (/\s+(\d+)\-(\d+)\-(\d+)/) {
  178. $transage = get_trans_age($1,$2,$3);
  179. }
  180. print_lang($langname{$pofile},$lasttranslator{$pofile},$tran,$fuzz,$untr,$transage);
  181. }
  182. }
  183. # average results for the project
  184. print "<tr>\n<td colspan=3 height=8></td>\n<tr>";
  185. print_lang($averagestr,'',$atran,$afuzz,$auntr,0);
  186. # table footer
  187. print "</table>\n";
  188. # end
  189. # print "<br>Number of languages supported: $alang <br>";
  190. print "<p>\nLanguages marked with <font size=\"+1\" color=\"red\"> *</font> really need your help to be completed.<br>";
  191. print "<p>The ones with grey bars are <i>probably unmaintained</i> because translation is more than ", $transolddays / 30, " months old, anyway, trying to contact current translator first is usually a good idea before submitting an updated one.<p><b>NOTE</b>: if you are the translator of one of them and don't want to see your language bar in grey you should manually update the <tt>PO-Revision-Date</tt> field in the .po file header (or, alternatively, use a tool which does it for you).<br>";
  192. # print "If you want to help those or contribute any new language please contact <a href=\"mailto:$contactaddress\">us</a>.";
  193. print "</div></div>";
  194. # print `cat $pagetail`;
  195. #
  196. # make it a here-doc
  197. #print <<ENDOFTAIL;
  198. # removed for being included
  199. #ENDOFTAIL
  200. # done