r10524 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r10523‎ | r10524 | r10525 >
Date:12:50, 15 August 2005
Author:hashar
Status:old
Tags:
Comment:
* Use languages class.
* $lang -> $langcode
* comments moved on top of line instead of being at the end (shorter lines)
Modified paths:
  • /trunk/phase3/maintenance/transstat.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/transstat.php
@@ -13,6 +13,8 @@
1414
1515 /** */
1616 require_once('commandLine.inc');
 17+require_once('languages.inc');
 18+
1719 if( isset($options['help']) ) { usage(); die(); }
1820 // default output is WikiText
1921 if( !isset($options['output']) ) { $options['output']='wiki'; }
@@ -131,35 +133,21 @@
132134 break;
133135 }
134136
135 -// available language files
136 -$langs = array();
137 -$dir = opendir("$IP/languages");
138 -while ($file = readdir($dir)) {
139 - if (preg_match("/Language(.*?)\.php$/", $file, $m)) {
140 - $langs[] = $m[1];
141 - }
142 -}
143 -sort($langs);
 137+$langTool = new languages();
144138
145 -// Cleanup file list
146 -foreach($langs as $key => $lang) {
147 - if ($lang == 'Utf8' || $lang == '' || $lang == 'Converter')
148 - unset($langs[$key]);
149 -}
150 -
151139 // Load message and compute stuff
152140 $msgs = array();
153 -foreach($langs as $lang) {
 141+foreach($langTool->getList() as $langcode) {
154142 // Since they aren't loaded by default..
155 - require_once( 'languages/Language' . $lang . '.php' );
156 - $arr = 'wgAllMessages' . $lang;
157 - if (@is_array($$arr)) { // Some of them don't have a message array
158 - $msgs[$wgContLang->lcfirst($lang)] = array(
 143+ require_once( 'languages/Language' . $langcode . '.php' );
 144+ $arr = 'wgAllMessages'.$langcode;
 145+ if(@is_array($$arr)) {
 146+ $msgs[$wgContLang->lcfirst($langcode)] = array(
159147 'total' => count($$arr),
160148 'redundant' => redundant($$arr),
161149 );
162150 } else {
163 - $msgs[$wgContLang->lcfirst($lang)] = array(
 151+ $msgs[$wgContLang->lcfirst($langcode)] = array(
164152 'total' => 0,
165153 'redundant' => 0,
166154 );
@@ -181,17 +169,23 @@
182170 // Generate rows
183171 foreach($msgs as $lang => $stats) {
184172 $out->blockstart();
185 - $out->element($wgContLang->getLanguageName(strtr($lang, '_', '-')) . " ($lang)"); // Language
186 - $out->element($stats['total'] . '/' . $msgs['en']['total']); // Translated
187 - $out->element($out->formatPercent($stats['total'], $msgs['en']['total'])); // % Translated
188 - $out->element($msgs['en']['total'] - $stats['total']); // Untranslated
189 - $out->element($out->formatPercent($msgs['en']['total'] - $stats['total'], $msgs['en']['total'], true)); // % Untranslated
 173+ // Language
 174+ $out->element($wgContLang->getLanguageName(strtr($lang, '_', '-')) . " ($lang)");
 175+ // Translated
 176+ $out->element($stats['total'] . '/' . $msgs['en']['total']);
 177+ // % Translated
 178+ $out->element($out->formatPercent($stats['total'], $msgs['en']['total']));
 179+ // Untranslated
 180+ $out->element($msgs['en']['total'] - $stats['total']);
 181+ // % Untranslated
 182+ $out->element($out->formatPercent($msgs['en']['total'] - $stats['total'], $msgs['en']['total'], true));
 183+ // Redundant & % Redundant
190184 if($stats['redundant'] =='NC') {
191185 $out->element('NC');
192186 $out->element('NC');
193187 } else {
194 - $out->element($stats['redundant'] . '/' . $stats['total']); // Redundant
195 - $out->element($out->formatPercent($stats['redundant'], $stats['total'],true)); // % Redundant
 188+ $out->element($stats['redundant'] . '/' . $stats['total']);
 189+ $out->element($out->formatPercent($stats['redundant'], $stats['total'],true));
196190 }
197191 $out->blockend();
198192 }

Status & tagging log