title = $title; $this->doesPageHaveLanguages = $doesPageHaveLanguages; $this->messageLocalizer = $messageLocalizer; $this->iconClass = $iconClass; $this->label = $label; } /** * @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, 'class' => $this->iconClass . $switcherClasses, 'text' => $msg, 'title' => $msg, 'data-event-name' => 'menu.languages' ] ]; } }