MediaWiki  1.34.0
dumpMessages.php
Go to the documentation of this file.
1 <?php
26 require_once __DIR__ . '/../Maintenance.php';
27 
33 class DumpMessages extends Maintenance {
34  public function __construct() {
35  parent::__construct();
36  $this->addDescription( 'Dump an entire language, using the keys from English' );
37  }
38 
39  public function execute() {
40  global $wgVersion;
41 
42  $messages = [];
43  foreach ( array_keys( Language::getMessagesFor( 'en' ) ) as $key ) {
44  $messages[$key] = wfMessage( $key )->text();
45  }
46  $this->output( "MediaWiki $wgVersion language file\n" );
47  $this->output( serialize( $messages ) );
48  }
49 }
50 
51 $maintClass = DumpMessages::class;
52 require_once RUN_MAINTENANCE_IF_MAIN;
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:39
DumpMessages
Maintenance script that dumps an entire language, using the keys from English.
Definition: dumpMessages.php:33
DumpMessages\execute
execute()
Do the actual work.
Definition: dumpMessages.php:39
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:348
$wgVersion
$wgVersion
MediaWiki version number.
Definition: DefaultSettings.php:75
DumpMessages\__construct
__construct()
Default constructor.
Definition: dumpMessages.php:34
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1264
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: Maintenance.php:82
serialize
serialize()
Definition: ApiMessageTrait.php:138
$maintClass
$maintClass
Definition: dumpMessages.php:51
Language\getMessagesFor
static getMessagesFor( $code)
Get all messages for a given language WARNING: this may take a long time.
Definition: Language.php:4463
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:453