Index: trunk/phase3/maintenance/transstat.php |
— | — | @@ -13,6 +13,8 @@ |
14 | 14 | |
15 | 15 | /** */ |
16 | 16 | require_once('commandLine.inc'); |
| 17 | +require_once('languages.inc'); |
| 18 | + |
17 | 19 | if( isset($options['help']) ) { usage(); die(); } |
18 | 20 | // default output is WikiText |
19 | 21 | if( !isset($options['output']) ) { $options['output']='wiki'; } |
— | — | @@ -131,35 +133,21 @@ |
132 | 134 | break; |
133 | 135 | } |
134 | 136 | |
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(); |
144 | 138 | |
145 | | -// Cleanup file list |
146 | | -foreach($langs as $key => $lang) { |
147 | | - if ($lang == 'Utf8' || $lang == '' || $lang == 'Converter') |
148 | | - unset($langs[$key]); |
149 | | -} |
150 | | - |
151 | 139 | // Load message and compute stuff |
152 | 140 | $msgs = array(); |
153 | | -foreach($langs as $lang) { |
| 141 | +foreach($langTool->getList() as $langcode) { |
154 | 142 | // 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( |
159 | 147 | 'total' => count($$arr), |
160 | 148 | 'redundant' => redundant($$arr), |
161 | 149 | ); |
162 | 150 | } else { |
163 | | - $msgs[$wgContLang->lcfirst($lang)] = array( |
| 151 | + $msgs[$wgContLang->lcfirst($langcode)] = array( |
164 | 152 | 'total' => 0, |
165 | 153 | 'redundant' => 0, |
166 | 154 | ); |
— | — | @@ -181,17 +169,23 @@ |
182 | 170 | // Generate rows |
183 | 171 | foreach($msgs as $lang => $stats) { |
184 | 172 | $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 |
190 | 184 | if($stats['redundant'] =='NC') { |
191 | 185 | $out->element('NC'); |
192 | 186 | $out->element('NC'); |
193 | 187 | } 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)); |
196 | 190 | } |
197 | 191 | $out->blockend(); |
198 | 192 | } |