title = $title; $this->doesPageHaveLanguages = $doesPageHaveLanguages; $this->messageLocalizer = $messageLocalizer; $this->icon = 'wikimedia-language-base20'; $this->label = $label; $this->classes = $classes; if ( $isButton ) { $this->classes .= MinervaUI::iconClass( 'language-base20', 'element', 'mw-ui-button mw-ui-quiet mw-ui-icon-with-label-desktop', 'wikimedia' ); } } /** * @inheritDoc */ public function getName() { return 'language-selector'; } /** * @inheritDoc */ public function getCSSClasses(): array { return []; } /** * @inheritDoc */ public function getComponents(): array { $switcherLink = false; $switcherClasses = ' language-selector'; if ( $this->doesPageHaveLanguages ) { $switcherLink = SpecialPage::getTitleFor( 'MobileLanguages', $this->title )->getLocalURL(); } else { $switcherClasses .= ' disabled'; } $msg = $this->messageLocalizer->msg( $this->label ); return [ [ 'href' => $switcherLink, 'icon' => $this->icon, 'class' => $this->classes . ' ' . $switcherClasses, 'text' => $msg, 'title' => $msg, 'data-event-name' => 'menu.languages' ] ]; } }