MediaWiki REL1_31
transstat.php
Go to the documentation of this file.
1<?php
29$optionsWithArgs = [ 'output' ];
31
32require_once __DIR__ . '/../commandLine.inc';
33require_once 'languages.inc';
34require_once __DIR__ . '/StatOutputs.php';
35
36if ( isset( $options['help'] ) ) {
37 showUsage();
38}
39
40# Default output is WikiText
41if ( !isset( $options['output'] ) ) {
42 $options['output'] = 'wiki';
43}
44
46function showUsage() {
47 print <<<TEXT
48Usage: php transstat.php [--help] [--output=csv|text|wiki]
49 --help : this helpful message
50 --output : select an output engine one of:
51 * 'csv' : Comma Separated Values.
52 * 'wiki' : MediaWiki syntax (default).
53 * 'text' : Text with tabs.
54Example: php maintenance/transstat.php --output=text
55
56TEXT;
57 exit( 1 );
58}
59
60# Select an output engine
61switch ( $options['output'] ) {
62 case 'wiki':
64 break;
65 case 'text':
67 break;
68 case 'csv':
69 $output = new CsvStatsOutput();
70 break;
71 default:
72 showUsage();
73}
74
75# Languages
77
78# Header
79$output->heading();
80$output->blockstart();
81$output->element( 'Language', true );
82$output->element( 'Code', true );
83$output->element( 'Fallback', true );
84$output->element( 'Translated', true );
85$output->element( '%', true );
86$output->element( 'Obsolete', true );
87$output->element( '%', true );
88$output->element( 'Problematic', true );
89$output->element( '%', true );
90$output->blockend();
91
92$wgGeneralMessages = $languages->getGeneralMessages();
94
95foreach ( $languages->getLanguages() as $code ) {
96 # Don't check English, RTL English or dummy language codes
97 if ( $code == 'en' || $code == 'enRTL' || ( is_array( $wgDummyLanguageCodes ) &&
99 ) {
100 continue;
101 }
102
103 # Calculate the numbers
104 $language = Language::fetchLanguageName( $code );
105 $fallback = $languages->getFallback( $code );
106 $messages = $languages->getMessages( $code );
107 $messagesNumber = count( $messages['translated'] );
108 $requiredMessagesNumber = count( $messages['required'] );
109 $requiredMessagesPercent = $output->formatPercent(
110 $requiredMessagesNumber,
112 );
113 $obsoleteMessagesNumber = count( $messages['obsolete'] );
114 $obsoleteMessagesPercent = $output->formatPercent(
115 $obsoleteMessagesNumber,
116 $messagesNumber,
117 true
118 );
119 $messagesWithMismatchVariables = $languages->getMessagesWithMismatchVariables( $code );
120 $emptyMessages = $languages->getEmptyMessages( $code );
121 $messagesWithWhitespace = $languages->getMessagesWithWhitespace( $code );
122 $nonXHTMLMessages = $languages->getNonXHTMLMessages( $code );
123 $messagesWithWrongChars = $languages->getMessagesWithWrongChars( $code );
124 $problematicMessagesNumber = count( array_unique( array_merge(
125 $messagesWithMismatchVariables,
126 $emptyMessages,
127 $messagesWithWhitespace,
128 $nonXHTMLMessages,
129 $messagesWithWrongChars
130 ) ) );
131 $problematicMessagesPercent = $output->formatPercent(
132 $problematicMessagesNumber,
133 $messagesNumber,
134 true
135 );
136
137 # Output them
138 $output->blockstart();
139 $output->element( "$language" );
140 $output->element( "$code" );
141 $output->element( "$fallback" );
142 $output->element( "$requiredMessagesNumber/$wgRequiredMessagesNumber" );
143 $output->element( $requiredMessagesPercent );
144 $output->element( "$obsoleteMessagesNumber/$messagesNumber" );
145 $output->element( $obsoleteMessagesPercent );
146 $output->element( "$problematicMessagesNumber/$messagesNumber" );
147 $output->element( $problematicMessagesPercent );
148 $output->blockend();
149}
150
151# Footer
152$output->footer();
$wgDummyLanguageCodes
Functionally the same as $wgExtraLanguageCodes, but deprecated.
$messages
$fallback
csv output.
static fetchLanguageName( $code, $inLanguage=null, $include='all')
Definition Language.php:896
Output text.
Outputs WikiText.
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like select() and insert() are usually more convenient. They take care of things like table prefixes and escaping for you. If you really need to make your own SQL
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
Definition hooks.txt:2255
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:2001
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
Definition hooks.txt:865
while(( $__line=Maintenance::readconsole()) !==false) print
Definition eval.php:64
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
database rows
Definition globals.txt:10
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning maintenance scripts have been cleaned up to use a unified class Directory structure How to run a script How to write your own DIRECTORY STRUCTURE The maintenance directory of a MediaWiki installation contains several all of which have unique purposes HOW TO RUN A SCRIPT Ridiculously just call php someScript php that s in the top level maintenance directory if not default wiki
A helper class for throttling authentication attempts.
$wgGeneralMessages
Definition transstat.php:92
$optionsWithoutArgs
Definition transstat.php:30
$optionsWithArgs
Definition transstat.php:29
switch( $options['output']) $languages
Definition transstat.php:76
if(isset( $options['help'])) if(!isset($options[ 'output'])) showUsage()
Print a usage message.
Definition transstat.php:46
$wgRequiredMessagesNumber
Definition transstat.php:93