MediaWiki  1.33.0
Go to the documentation of this file.
1 <?php
29 $optionsWithArgs = [ 'output' ];
30 $optionsWithoutArgs = [ 'help' ];
32 require_once __DIR__ . '/../';
33 require_once '';
34 require_once __DIR__ . '/StatOutputs.php';
36 if ( isset( $options['help'] ) ) {
37  showUsage();
38 }
40 # Default output is WikiText
41 if ( !isset( $options['output'] ) ) {
42  $options['output'] = 'wiki';
43 }
46 function showUsage() {
47  print <<<TEXT
48 Usage: 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.
54 Example: php maintenance/transstat.php --output=text
56 TEXT;
57  exit( 1 );
58 }
60 # Select an output engine
61 switch ( $options['output'] ) {
62  case 'wiki':
63  $output = new WikiStatsOutput();
64  break;
65  case 'text':
66  $output = new TextStatsOutput();
67  break;
68  case 'csv':
69  $output = new CsvStatsOutput();
70  break;
71  default:
72  showUsage();
73 }
75 # Languages
76 $languages = new Languages();
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();
92 $wgGeneralMessages = $languages->getGeneralMessages();
95 foreach ( $languages->getLanguages() as $code ) {
96  # Don't check English, RTL English or dummy language codes
97  if ( $code == 'en' || $code == 'enRTL' || ( is_array( $wgDummyLanguageCodes ) &&
98  isset( $wgDummyLanguageCodes[$code] ) )
99  ) {
100  continue;
101  }
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  );
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 }
151 # Footer
152 $output->footer();
static fetchLanguageName( $code, $inLanguage=self::AS_AUTONYMS, $include=self::ALL)
Definition: Language.php:933
csv output.
Definition: StatOutputs.php:138
switch( $options['output']) $languages
Definition: transstat.php:76
Definition: MessagesAb.php:11
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
Definition: maintenance.txt:1
Definition: LogTests.i18n.php:8
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:35
Definition: transstat.php:30
Output text.
Definition: StatOutputs.php:127
A helper class for throttling authentication attempts.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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:780
Definition: SyntaxHighlight.php:334
Definition: transstat.php:93
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 use $formDescriptor instead 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:2154
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
Definition: All_system_messages.txt:1267
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:1985
if(isset( $options['help'])) if(!isset( $options['output'])) showUsage()
Print a usage message.
Definition: transstat.php:46
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
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
Definition: globals.txt:10
Definition: transstat.php:29
Outputs WikiText.
Definition: StatOutputs.php:54
Definition: transstat.php:92
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
Functionally the same as $wgExtraLanguageCodes, but deprecated.
Definition: DefaultSettings.php:2989