title = $title; $this->doesPageHaveLanguages = $doesPageHaveLanguages; $this->messageLocalizer = $messageLocalizer; $this->icon = $doesPageHaveLanguages ? 'language-base20' : 'language-disabled'; $this->label = $label; $this->classes = $classes; } /** * @inheritDoc */ public function getName(): string { 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' => 'title', 'value' => $msg, ], ], ], ]; } }