mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-24 22:25:27 +00:00
Merge "Allow msg key to be overridable"
This commit is contained in:
commit
c9bd66df37
|
@ -26,6 +26,7 @@ use MediaWiki\Minerva\Menu\Entries\SingleMenuEntry;
|
|||
use MediaWiki\Special\SpecialPageFactory;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
use MediaWiki\User\UserOptionsLookup;
|
||||
use Message;
|
||||
use MWException;
|
||||
use SpecialPage;
|
||||
use Title;
|
||||
|
@ -90,7 +91,7 @@ final class Definitions {
|
|||
/**
|
||||
* Perform message localization
|
||||
* @param string $key to localize
|
||||
* @return string
|
||||
* @return Message
|
||||
*/
|
||||
public function msg( string $key ) {
|
||||
return $this->context->msg( $key );
|
||||
|
|
|
@ -85,7 +85,7 @@ final class BuilderUtil {
|
|||
foreach ( $navigationTools as $item ) {
|
||||
$id = $item['id'] ?? null;
|
||||
if ( $id && isset( $entryDefinitions[ $id ] ) ) {
|
||||
foreach ( [ 'icon', 'class', 'href' ] as $overridableKey ) {
|
||||
foreach ( [ 'icon', 'class', 'href', 'msg' ] as $overridableKey ) {
|
||||
$override = $item[ $overridableKey ] ?? null;
|
||||
if ( $override ) {
|
||||
$entryDefinitions[$id][$overridableKey] = $override;
|
||||
|
@ -95,9 +95,19 @@ final class BuilderUtil {
|
|||
}
|
||||
// Build the menu
|
||||
foreach ( $entryDefinitions as $definition ) {
|
||||
$msgKey = $definition['msg'] ?? null;
|
||||
$text = null;
|
||||
if ( $msgKey ) {
|
||||
$msg = $definitions->msg( $msgKey );
|
||||
$text = $msg->exists() ? $msg->text() : null;
|
||||
}
|
||||
if ( !$text ) {
|
||||
$text = $definition['text'];
|
||||
}
|
||||
|
||||
$entry = SingleMenuEntry::create(
|
||||
$definition['name'],
|
||||
$definition['text'],
|
||||
$text,
|
||||
$definition['href'],
|
||||
$definition['class'],
|
||||
$definition['icon']
|
||||
|
|
Loading…
Reference in a new issue