VisualEditorDataModule: Generate definition summary without parsing wikitext

Adapted from code in DiscussionTools.

Bug: T189229
Change-Id: I206bb05d28d492d6ba2dd9d29cdbe94323d6bad9
This commit is contained in:
Bartosz Dziewoński 2022-01-08 03:09:27 +01:00
parent 8080bd2f5d
commit ec59e2ed42

View file

@ -37,6 +37,30 @@ class VisualEditorDataModule extends ResourceLoaderModule {
) . ');';
}
/**
* Get the definition summary for this module.
*
* @param ResourceLoaderContext $context
* @return array
*/
public function getDefinitionSummary( ResourceLoaderContext $context ) {
$summary = parent::getDefinitionSummary( $context );
$msgVersion = [];
$msgInfo = $this->getMessageInfo( $context );
$msgInfo = array_merge( $msgInfo['parse'], $msgInfo['plain'] );
foreach ( $msgInfo as $msgKey => $msgObj ) {
$msgVersion[ $msgKey ] = [
// Include the text of the message, in case the canonical translation changes
$msgObj->plain(),
// Include the page touched time, in case the on-wiki override is invalidated
Title::makeTitle( NS_MEDIAWIKI, ucfirst( $msgObj->getKey() ) )->getTouched(),
];
}
$summary[] = [ 've-messages' => $msgVersion ];
return $summary;
}
/**
* @param ResourceLoaderContext $context Object containing information about the state of this
* specific loader request.