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
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 text
Definition design.txt:18
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
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
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a message
Definition hooks.txt:2163
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
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
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