Index: trunk/extensions/Translate/SpecialLanguageStats.php |
— | — | @@ -216,33 +216,17 @@ |
217 | 217 | |
218 | 218 | $fuzzy = $translated = $total = 0; |
219 | 219 | |
220 | | - $incache = $cache->get( $groupName, $code ); |
221 | | - if ( $incache !== false ) { |
222 | | - list( $fuzzy, $translated, $total ) = $incache; |
| 220 | + if ( $g instanceof AggregateMessageGroup ) { |
| 221 | + foreach ( $g->getGroups() as $subgroup ) { |
| 222 | + $result = $this->loadPercentages( $cache, $subgroup, $code ); |
| 223 | + $fuzzy += $result[0]; |
| 224 | + $translated += $result[1]; |
| 225 | + $total += $result[2]; |
| 226 | + } |
| 227 | + } else { |
| 228 | + list( $fuzzy, $translated, $total ) = $this->loadPercentages( $cache, $g, $code ); |
223 | 229 | } |
224 | 230 | |
225 | | - // Re-calculate if cache is empty or insane |
226 | | - if ( !$total ) { |
227 | | - // Initialise messages. |
228 | | - $collection = $g->initCollection( $code ); |
229 | | - $collection->setInFile( $g->load( $code ) ); |
230 | | - $collection->filter( 'ignored' ); |
231 | | - $collection->filter( 'optional' ); |
232 | | - // Store the count of real messages for later calculation. |
233 | | - $total = count( $collection ); |
234 | | - |
235 | | - // Count fuzzy first. |
236 | | - $collection->filter( 'fuzzy' ); |
237 | | - $fuzzy = $total - count( $collection ); |
238 | | - |
239 | | - // Count the completed translations. |
240 | | - $collection->filter( 'hastranslation', false ); |
241 | | - $translated = count( $collection ); |
242 | | - |
243 | | - $cache->set( $groupName, $code, array( $fuzzy, $translated, $total ) ); |
244 | | - $cache->commit(); |
245 | | - } |
246 | | - |
247 | 231 | if ( $total === 0 ) { |
248 | 232 | wfWarn( __METHOD__ . ": Group $groupName has zero message ($code)" ); |
249 | 233 | continue; |
— | — | @@ -291,6 +275,38 @@ |
292 | 276 | return $out; |
293 | 277 | } |
294 | 278 | |
| 279 | + protected function loadPercentages( $cache, $group, $code ) { |
| 280 | + $incache = $cache->get( $group->getId(), $code ); |
| 281 | + if ( $incache !== false ) { |
| 282 | + return $incache; |
| 283 | + } |
| 284 | + |
| 285 | + // Initialise messages. |
| 286 | + $collection = $group->initCollection( $code ); |
| 287 | + $collection->setInFile( $group->load( $code ) ); |
| 288 | + $collection->filter( 'ignored' ); |
| 289 | + $collection->filter( 'optional' ); |
| 290 | + // Store the count of real messages for later calculation. |
| 291 | + $total = count( $collection ); |
| 292 | + |
| 293 | + // Count fuzzy first. |
| 294 | + $collection->filter( 'fuzzy' ); |
| 295 | + $fuzzy = $total - count( $collection ); |
| 296 | + |
| 297 | + // Count the completed translations. |
| 298 | + $collection->filter( 'hastranslation', false ); |
| 299 | + $translated = count( $collection ); |
| 300 | + |
| 301 | + $result = array( $fuzzy, $translated, $total ); |
| 302 | + |
| 303 | + $cache->set( $group->getId(), $code, $result ); |
| 304 | + |
| 305 | + static $i = 0; |
| 306 | + if ( $i++ % 50 === 0 ) $cache->commit(); |
| 307 | + |
| 308 | + return $result; |
| 309 | + } |
| 310 | + |
295 | 311 | protected function formatPercentage( $num ) { |
296 | 312 | global $wgLang; |
297 | 313 | $fmt = $wgLang->formatNum( number_format( round( 100 * $num, 2 ), 2 ) ); |
Index: trunk/extensions/Translate/Groups.php |
— | — | @@ -502,7 +502,7 @@ |
503 | 503 | return $this->mangler; |
504 | 504 | } |
505 | 505 | |
506 | | - protected function getGroups() { |
| 506 | + public function getGroups() { |
507 | 507 | if ( !isset( $this->groups ) ) { |
508 | 508 | $groups = array(); |
509 | 509 | $ids = (array) $this->conf['GROUPS']; |