3 * Statistics about the localisation.
6 * @ingroup MaintenanceLanguage
8 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
9 * @author Ashar Voultoiz <hashar at free dot fr>
11 * Output is posted from time to time on:
12 * http://www.mediawiki.org/wiki/Localisation_statistics
14 $optionsWithArgs = array( 'output' );
16 require_once( dirname( __FILE__
) . '/../commandLine.inc' );
17 require_once( 'languages.inc' );
18 require_once( dirname( __FILE__
) . '/StatOutputs.php' );
21 if ( isset( $options['help'] ) ) {
25 # Default output is WikiText
26 if ( !isset( $options['output'] ) ) {
27 $options['output'] = 'wiki';
30 /** Print a usage message*/
31 function showUsage() {
33 Usage: php transstat.php [--help] [--output=csv|text|wiki]
34 --help : this helpful message
35 --output : select an output engine one of:
36 * 'csv' : Comma Separated Values.
37 * 'wiki' : MediaWiki syntax (default).
38 * 'text' : Text with tabs.
39 Example: php maintenance/transstat.php --output=text
47 # Select an output engine
48 switch ( $options['output'] ) {
50 $output = new wikiStatsOutput();
53 $output = new textStatsOutput();
56 $output = new csvStatsOutput();
63 $wgLanguages = new languages();
67 $output->blockstart();
68 $output->element( 'Language', true );
69 $output->element( 'Code', true );
70 $output->element( 'Fallback', true );
71 $output->element( 'Translated', true );
72 $output->element( '%', true );
73 $output->element( 'Obsolete', true );
74 $output->element( '%', true );
75 $output->element( 'Problematic', true );
76 $output->element( '%', true );
79 $wgGeneralMessages = $wgLanguages->getGeneralMessages();
80 $wgRequiredMessagesNumber = count( $wgGeneralMessages['required'] );
82 foreach ( $wgLanguages->getLanguages() as $code ) {
83 # Don't check English or RTL English
84 if ( $code == 'en' ||
$code == 'enRTL' ) {
88 # Calculate the numbers
89 $language = $wgContLang->getLanguageName( $code );
90 $fallback = $wgLanguages->getFallback( $code );
91 $messages = $wgLanguages->getMessages( $code );
92 $messagesNumber = count( $messages['translated'] );
93 $requiredMessagesNumber = count( $messages['required'] );
94 $requiredMessagesPercent = $output->formatPercent( $requiredMessagesNumber, $wgRequiredMessagesNumber );
95 $obsoleteMessagesNumber = count( $messages['obsolete'] );
96 $obsoleteMessagesPercent = $output->formatPercent( $obsoleteMessagesNumber, $messagesNumber, true );
97 $messagesWithMismatchVariables = $wgLanguages->getMessagesWithMismatchVariables( $code );
98 $emptyMessages = $wgLanguages->getEmptyMessages( $code );
99 $messagesWithWhitespace = $wgLanguages->getMessagesWithWhitespace( $code );
100 $nonXHTMLMessages = $wgLanguages->getNonXHTMLMessages( $code );
101 $messagesWithWrongChars = $wgLanguages->getMessagesWithWrongChars( $code );
102 $problematicMessagesNumber = count( array_unique( array_merge( $messagesWithMismatchVariables, $emptyMessages, $messagesWithWhitespace, $nonXHTMLMessages, $messagesWithWrongChars ) ) );
103 $problematicMessagesPercent = $output->formatPercent( $problematicMessagesNumber, $messagesNumber, true );
106 $output->blockstart();
107 $output->element( "$language" );
108 $output->element( "$code" );
109 $output->element( "$fallback" );
110 $output->element( "$requiredMessagesNumber/$wgRequiredMessagesNumber" );
111 $output->element( $requiredMessagesPercent );
112 $output->element( "$obsoleteMessagesNumber/$messagesNumber" );
113 $output->element( $obsoleteMessagesPercent );
114 $output->element( "$problematicMessagesNumber/$messagesNumber" );
115 $output->element( $problematicMessagesPercent );