// Determine which messages should we print
if ( in_array( '*', $params['messages'] ) ) {
$message_names = Language::getMessageKeysFor( $langObj->getCode() );
+ if ( $params['includelocal'] ) {
+ global $wgLanguageCode;
+ $message_names = array_unique( array_merge(
+ $message_names,
+ // Pass in the content language code so we get local messages that have a
+ // MediaWiki:msgkey page. We might theoretically miss messages that have no
+ // MediaWiki:msgkey page but do have a MediaWiki:msgkey/lang page, but that's
+ // just a stupid case.
+ MessageCache::singleton()->getAllMessageKeys( $wgLanguageCode )
+ ) );
+ }
sort( $message_names );
$messages_target = $message_names;
} else {
),
'enableparser' => false,
'nocontent' => false,
+ 'includelocal' => false,
'args' => array(
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_ALLOW_DUPLICATES => true,
'enableparser' => array( 'Set to enable parser, will preprocess the wikitext of message',
'Will substitute magic words, handle templates etc.' ),
'nocontent' => 'If set, do not include the content of the messages in the output.',
+ 'includelocal' => array( "Also include local messages, i.e. messages that don't exist in the software but do exist as a MediaWiki: page.",
+ "This lists all MediaWiki: pages, so it will also list those that aren't 'really' messages such as Common.js",
+ ),
'title' => 'Page name to use as context when parsing message (for enableparser option)',
'args' => 'Arguments to be substituted into message',
'prefix' => 'Return messages with this prefix',
return array_keys( $list );
}
+ /**
+ * Get all message keys stored in the message cache for a given language.
+ * If $code is the content language code, this will return all message keys
+ * for which MediaWiki:msgkey exists. If $code is another language code, this
+ * will ONLY return message keys for which MediaWiki:msgkey/$code exists.
+ * @param $code string
+ * @return array of message keys (strings)
+ */
+ public function getAllMessageKeys( $code ) {
+ global $wgContLang;
+ $this->load( $code );
+ if ( !isset( $this->mCache[$code] ) ) {
+ // Apparently load() failed
+ return null;
+ }
+ $cache = $this->mCache[$code]; // Copy the cache
+ unset( $cache['VERSION'] ); // Remove the VERSION key
+ $cache = array_diff( $cache, array( '!NONEXISTENT' ) ); // Remove any !NONEXISTENT keys
+ // Keys may appear with a capital first letter. lcfirst them.
+ return array_map( array( $wgContLang, 'lcfirst' ), array_keys( $cache ) );
+ }
}