title = $title; $this->doesPageHaveLanguages = $doesPageHaveLanguages; $this->messageLocalizer = $messageLocalizer; $this->icon = 'wikimedia-language-base20'; $this->label = $label; $this->classes = $classes; if ( $isButton ) { $this->classes .= 'mw-ui-icon-with-label-desktop'; } } /** * @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 = '#p-lang'; } else { $switcherClasses .= ' disabled'; } $msg = $this->messageLocalizer->msg( $this->label ); return [ [ 'tag-name' => 'a', 'classes' => $this->classes . ' ' . $switcherClasses, 'label' => $msg, 'data-icon' => [ 'icon' => $this->icon, ], 'array-attributes' => [ [ 'key' => 'href', 'value' => $switcherLink, ], [ 'key' => 'data-mw', 'value' => 'interface', ], [ 'key' => 'data-event-name', 'value' => 'menu.languages', ], [ 'key' => 'role', 'value' => 'button', ], [ 'key' => 'title', 'value' => $msg, ], ], ], ]; } }