Change ULS label for sticky header when 0 Languages available.
Modifies the `getULSLabel()` function to centralize the logic related to the ULS language button messages. Renames this function `getULSLabels()` since it retrieves both the text and aria label for this input. This logic conditionally returns the values based on whether or not there are multiple languages available for an title. It method is used in both sticky header and language button near the page title. Bug: T315556 Change-Id: I47e313414ae9c86d057e9b65ec67e522e9e7c464
This commit is contained in:
parent
0e7c32827d
commit
87d0630aa2
|
@ -659,16 +659,25 @@ abstract class SkinVector extends SkinMustache {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns ULS button label within the context of the translated message taking a placeholder.
|
* Get the ULS button label, accounting for the number of available
|
||||||
|
* languages.
|
||||||
*
|
*
|
||||||
* @param string $message
|
* @return array
|
||||||
* @param int $count
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
private function getULSLabel( string $message, int $count ): string {
|
private function getULSLabels(): array {
|
||||||
return $this->msg( $message )
|
$numLanguages = count( $this->getLanguagesCached() );
|
||||||
->numParams( $count )
|
|
||||||
->escaped();
|
if ( $numLanguages === 0 ) {
|
||||||
|
return [
|
||||||
|
'label' => $this->msg( 'vector-no-language-button-label' )->text(),
|
||||||
|
'aria-label' => $this->msg( 'vector-no-language-button-aria-label' )->text()
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
return [
|
||||||
|
'label' => $this->msg( 'vector-language-button-label' )->numParams( $numLanguages )->escaped(),
|
||||||
|
'aria-label' => $this->msg( 'vector-language-button-aria-label' )->numParams( $numLanguages )->escaped()
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -702,7 +711,7 @@ abstract class SkinVector extends SkinMustache {
|
||||||
'class' => 'mw-interlanguage-selector',
|
'class' => 'mw-interlanguage-selector',
|
||||||
'is-quiet' => true,
|
'is-quiet' => true,
|
||||||
'tabindex' => '-1',
|
'tabindex' => '-1',
|
||||||
'label' => $this->getULSLabel( 'vector-language-button-label', $numLanguages ),
|
'label' => $this->getULSLabels()[ 'label' ],
|
||||||
'html-vector-button-icon' => Hooks::makeIcon( 'wikimedia-language' ),
|
'html-vector-button-icon' => Hooks::makeIcon( 'wikimedia-language' ),
|
||||||
'event' => 'ui.dropdown-p-lang-btn-sticky-header'
|
'event' => 'ui.dropdown-p-lang-btn-sticky-header'
|
||||||
];
|
];
|
||||||
|
@ -718,14 +727,8 @@ abstract class SkinVector extends SkinMustache {
|
||||||
|
|
||||||
$languageButtonData = [
|
$languageButtonData = [
|
||||||
'id' => 'p-lang-btn',
|
'id' => 'p-lang-btn',
|
||||||
// No languages present for the article.
|
'label' => $this->getULSLabels()['label'],
|
||||||
// But the page can show languages if there were languages.
|
'aria-label' => $this->getULSLabels()['aria-label'],
|
||||||
'label' => $numLanguages === 0 ?
|
|
||||||
$this->msg( 'vector-no-language-button-label' )->text() :
|
|
||||||
$this->getULSLabel( 'vector-language-button-label', $numLanguages ),
|
|
||||||
'aria-label' => $numLanguages === 0 ?
|
|
||||||
$this->msg( 'vector-no-language-button-aria-label' )->text() :
|
|
||||||
$this->getULSLabel( 'vector-language-button-aria-label', $numLanguages ),
|
|
||||||
// ext.uls.interface attaches click handler to this selector.
|
// ext.uls.interface attaches click handler to this selector.
|
||||||
'checkbox-class' => ' mw-interlanguage-selector ',
|
'checkbox-class' => ' mw-interlanguage-selector ',
|
||||||
'html-vector-heading-icon' => Hooks::makeIcon( 'wikimedia-language-progressive' ),
|
'html-vector-heading-icon' => Hooks::makeIcon( 'wikimedia-language-progressive' ),
|
||||||
|
|
Loading…
Reference in New Issue