Localisation updates from http://translatewiki.net.
[mediawiki.git] / maintenance / language / StatOutputs.php
blobe9d8c86dd0c5c06cd67defea964ee97fe18fa38f
1 <?php
2 if ( !defined( 'MEDIAWIKI' ) ) {
3 die();
5 /**
6 * Statistic output classes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
23 * @file
24 * @ingroup MaintenanceLanguage
25 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
26 * @author Antoine Musso <hashar at free dot fr>
29 /** A general output object. Need to be overriden */
30 class statsOutput {
31 function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
32 return @sprintf( '%.' . $accuracy . 'f%%', 100 * $subset / $total );
35 # Override the following methods
36 function heading() {
38 function footer() {
40 function blockstart() {
42 function blockend() {
44 function element( $in, $heading = false ) {
48 /** Outputs WikiText */
49 class wikiStatsOutput extends statsOutput {
50 function heading() {
51 global $wgDummyLanguageCodes;
52 $version = SpecialVersion::getVersion( 'nodb' );
53 echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n";
54 echo "'''Note:''' These statistics can be generated by running <code>php maintenance/language/transstat.php</code>.\n\n";
55 echo "For additional information on specific languages (the message names, the actual problems, etc.), run <code>php maintenance/language/checkLanguage.php --lang=foo</code>.\n\n";
56 echo 'English (en) is excluded because it is the default localization';
57 if ( is_array( $wgDummyLanguageCodes ) ) {
58 $dummyCodes = array();
59 foreach ( $wgDummyLanguageCodes as $dummyCode => $correctCode ) {
60 $dummyCodes[] = Language::fetchLanguageName( $dummyCode ) . ' (' . $dummyCode . ')';
62 echo ', as well as the following languages that are not intended for system message translations, usually because they redirect to other language codes: ' . implode( ', ', $dummyCodes );
64 echo ".\n\n"; # dot to end sentence
65 echo '{| class="sortable wikitable" border="2" style="background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear:both; width:100%;"' . "\n";
67 function footer() {
68 echo "|}\n";
70 function blockstart() {
71 echo "|-\n";
73 function blockend() {
74 echo '';
76 function element( $in, $heading = false ) {
77 echo ( $heading ? '!' : '|' ) . "$in\n";
79 function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
80 $v = @round( 255 * $subset / $total );
81 if ( $revert ) {
82 # Weigh reverse with factor 20 so coloring takes effect more quickly as
83 # this option is used solely for reporting 'bad' percentages.
84 $v = $v * 20;
85 if ( $v > 255 ) {
86 $v = 255;
88 $v = 255 - $v;
90 if ( $v < 128 ) {
91 # Red to Yellow
92 $red = 'FF';
93 $green = sprintf( '%02X', 2 * $v );
94 } else {
95 # Yellow to Green
96 $red = sprintf( '%02X', 2 * ( 255 - $v ) );
97 $green = 'FF';
99 $blue = '00';
100 $color = $red . $green . $blue;
102 $percent = parent::formatPercent( $subset, $total, $revert, $accuracy );
103 return 'style="background-color:#' . $color . ';"|' . $percent;
107 /** Output text. To be used on a terminal for example. */
108 class textStatsOutput extends statsOutput {
109 function element( $in, $heading = false ) {
110 echo $in . "\t";
112 function blockend() {
113 echo "\n";
117 /** csv output. Some people love excel */
118 class csvStatsOutput extends statsOutput {
119 function element( $in, $heading = false ) {
120 echo $in . ";";
122 function blockend() {
123 echo "\n";