Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
expand-groupspec.php
Go to the documentation of this file.
1<?php
9// Standard boilerplate to define $IP
10if ( getenv( 'MW_INSTALL_PATH' ) !== false ) {
11 $IP = getenv( 'MW_INSTALL_PATH' );
12} else {
13 $dir = __DIR__;
14 $IP = "$dir/../../..";
15}
16require_once "$IP/maintenance/Maintenance.php";
17
18class TranslateExpandGroupSpec extends Maintenance {
19 public function __construct() {
20 parent::__construct();
21 $this->addDescription( 'Expands a message group specification.' );
22 $this->addOption(
23 'exportable',
24 'List only groups that can be exported',
25 false, /*required*/
26 false /*has arg*/
27 );
28
29 $this->addArg(
30 'specification',
31 'For example page-*,main',
32 true /*required*/
33 );
34 $this->requireExtension( 'Translate' );
35 }
36
37 public function execute() {
38 $spec = $this->getArg( 0 );
39 $patterns = explode( ',', trim( $spec ) );
40 $ids = MessageGroups::expandWildcards( $patterns );
41
42 if ( $this->getOption( 'exportable' ) ) {
43 foreach ( $ids as $index => $id ) {
44 if ( !MessageGroups::getGroup( $id ) instanceof FileBasedMessageGroup ) {
45 unset( $ids[ $index ] );
46 }
47 }
48 }
49
50 if ( $ids !== [] ) {
51 // This should not be affected by --quiet
52 echo implode( "\n", $ids ) . "\n";
53 }
54 }
55}
56
57$maintClass = TranslateExpandGroupSpec::class;
58require_once RUN_MAINTENANCE_IF_MAIN;
This class implements default behavior for file based message groups.