Index: trunk/extensions/Translate/groups/PageTranslationAgg.yaml |
— | — | @@ -0,0 +1,15 @@ |
| 2 | +# Enable this group if you want to have aggregate group for all page |
| 3 | +# page translation groups. You can also add this configuration: |
| 4 | +# $wgTranslateGroupStructure['/^page/'] = array( 'page' ); |
| 5 | + |
| 6 | +BASIC: |
| 7 | + id: page-0-all |
| 8 | + label: All translatable pages |
| 9 | + display: page |
| 10 | + meta: yes |
| 11 | + class: AggregateMessageGroup |
| 12 | + description: 'All translatable pages' |
| 13 | + namespace: NS_TRANSLATIONS |
| 14 | + |
| 15 | +GROUPS: |
| 16 | + - page|* |
Index: trunk/extensions/Translate/Groups.php |
— | — | @@ -455,9 +455,7 @@ |
456 | 456 | class AggregateMessageGroup extends MessageGroupBase { |
457 | 457 | |
458 | 458 | public function exists() { |
459 | | - /** |
460 | | - * Group exists if there are any subgroups. |
461 | | - */ |
| 459 | + // Group exists if there are any subgroups. |
462 | 460 | $exists = (bool) $this->conf['GROUPS']; |
463 | 461 | |
464 | 462 | if ( !$exists ) { |
— | — | @@ -488,6 +486,7 @@ |
489 | 487 | if ( !isset( $this->groups ) ) { |
490 | 488 | $groups = array(); |
491 | 489 | $ids = (array) $this->conf['GROUPS']; |
| 490 | + $ids = $this->expandWildcards( $ids ); |
492 | 491 | |
493 | 492 | foreach ( $ids as $id ) { |
494 | 493 | // Do not try to include self and go to infinite loop. |
— | — | @@ -507,6 +506,34 @@ |
508 | 507 | return $this->groups; |
509 | 508 | } |
510 | 509 | |
| 510 | + /** |
| 511 | + * If the list of group ids contains wildcards, this function will match |
| 512 | + * them against the list of all supported groups and return matched group |
| 513 | + * names. |
| 514 | + * @param $ids \list{String} |
| 515 | + * @return \list{String} |
| 516 | + */ |
| 517 | + protected function expandWildcards( $ids ) { |
| 518 | + $hasWild = false; |
| 519 | + foreach ( $ids as $id ) { |
| 520 | + if ( strpos( $id, '*' ) !== false ) { |
| 521 | + $hasWild = true; |
| 522 | + break; |
| 523 | + } |
| 524 | + } |
| 525 | + |
| 526 | + if ( !$hasWild ) return $ids; |
| 527 | + |
| 528 | + $matcher = new StringMatcher( '', $ids ); |
| 529 | + $all = array(); |
| 530 | + foreach ( MessageGroups::singleton()->getGroups() as $id => $_ ) { |
| 531 | + if ( $matcher->match( $id ) ) { |
| 532 | + $all[] = $id; |
| 533 | + } |
| 534 | + } |
| 535 | + return $all; |
| 536 | + } |
| 537 | + |
511 | 538 | public function initCollection( $code ) { |
512 | 539 | $messages = array(); |
513 | 540 | foreach ( $this->getGroups() as $group ) { |