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