diff --git a/includes/Menu/Definitions.php b/includes/Menu/Definitions.php index 1f2f70202..e21d6ef49 100644 --- a/includes/Menu/Definitions.php +++ b/includes/Menu/Definitions.php @@ -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 ); diff --git a/includes/Menu/Main/BuilderUtil.php b/includes/Menu/Main/BuilderUtil.php index e17460428..ce295168a 100644 --- a/includes/Menu/Main/BuilderUtil.php +++ b/includes/Menu/Main/BuilderUtil.php @@ -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']