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