MediaWiki  master
dumpMessages.php
Go to the documentation of this file.
1 <?php
27 
28 require_once __DIR__ . '/../Maintenance.php';
29 
35 class DumpMessages extends Maintenance {
36 
39 
40  public function __construct() {
41  parent::__construct();
42  $this->addDescription( 'Dump an entire language, using the keys from English' );
43  $this->localisationCache = MediaWikiServices::getInstance()->getLocalisationCache();
44  }
45 
46  public function execute() {
47  $messages = [];
48  $localisationMessagesEn = $this->localisationCache->getItem( 'en', 'messages' );
49  foreach ( array_keys( $localisationMessagesEn ) as $key ) {
50  $messages[$key] = wfMessage( $key )->text();
51  }
52  $this->output( "MediaWiki " . MW_VERSION . " language file\n" );
53  $this->output( serialize( $messages ) );
54  }
55 }
56 
57 $maintClass = DumpMessages::class;
58 require_once RUN_MAINTENANCE_IF_MAIN;
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:38
DumpMessages
Maintenance script that dumps an entire language, using the keys from English.
Definition: dumpMessages.php:35
DumpMessages\execute
execute()
Do the actual work.
Definition: dumpMessages.php:46
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:163
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:327
DumpMessages\__construct
__construct()
Default constructor.
Definition: dumpMessages.php:40
MW_VERSION
const MW_VERSION
The running version of MediaWiki.
Definition: Defines.php:39
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1220
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: Maintenance.php:55
serialize
serialize()
Definition: ApiMessageTrait.php:138
$maintClass
$maintClass
Definition: dumpMessages.php:57
DumpMessages\$localisationCache
LocalisationCache $localisationCache
Definition: dumpMessages.php:38
LocalisationCache
Class for caching the contents of localisation files, Messages*.php and *.i18n.php.
Definition: LocalisationCache.php:43
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:434