mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-28 01:20:07 +00:00
Merge "Show ULS button when article exist only in single language"
This commit is contained in:
commit
e4b4f5bf9f
|
@ -16,6 +16,8 @@
|
||||||
"vector-languages": "Languages",
|
"vector-languages": "Languages",
|
||||||
"vector-language-button-aria-label": "Go to an article in another language. Available in {{PLURAL:$1|$1 language|$1 languages}}",
|
"vector-language-button-aria-label": "Go to an article in another language. Available in {{PLURAL:$1|$1 language|$1 languages}}",
|
||||||
"vector-language-button-label": "{{PLURAL:$1|$1 language|$1 languages}}",
|
"vector-language-button-label": "{{PLURAL:$1|$1 language|$1 languages}}",
|
||||||
|
"vector-no-language-button-label": "Add languages",
|
||||||
|
"vector-no-language-button-aria-label": "This article exist only in this language. Add the article for other languages",
|
||||||
"vector-language-redirect-to-top": "On this {{SITENAME}} the language links are at the top of the page across from the article title. [[#p-lang-btn|Go to top]].",
|
"vector-language-redirect-to-top": "On this {{SITENAME}} the language links are at the top of the page across from the article title. [[#p-lang-btn|Go to top]].",
|
||||||
"vector-language-variant-switcher-label": "Change language variant",
|
"vector-language-variant-switcher-label": "Change language variant",
|
||||||
"vector-action-addsection": "Add topic",
|
"vector-action-addsection": "Add topic",
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
"vector-languages": "Label for language alert in sidebar when language switching is in header\n\n{{Identical|Language}}",
|
"vector-languages": "Label for language alert in sidebar when language switching is in header\n\n{{Identical|Language}}",
|
||||||
"vector-language-button-aria-label": "Accessibility label for language button dropdown menu in modern Vector.\n* $1 - the count of languages available, supports plural",
|
"vector-language-button-aria-label": "Accessibility label for language button dropdown menu in modern Vector.\n* $1 - the count of languages available, supports plural",
|
||||||
"vector-language-button-label": "Label for language button in modern Vector.\n\nArguments:\n* $1 number of languages, supports plural",
|
"vector-language-button-label": "Label for language button in modern Vector.\n\nArguments:\n* $1 number of languages, supports plural",
|
||||||
|
"vector-no-language-button-label": "Label for language button when article does not exist in any other language.",
|
||||||
|
"vector-no-language-button-aria-label": "Accessibility label for language button dropdown menu in modern Vector.\n",
|
||||||
"vector-language-redirect-to-top": "Explains language links location at top of page and provides link to top. See also [[:phab:T295555]].",
|
"vector-language-redirect-to-top": "Explains language links location at top of page and provides link to top. See also [[:phab:T295555]].",
|
||||||
"vector-language-variant-switcher-label": "Label for the language variant switcher.",
|
"vector-language-variant-switcher-label": "Label for the language variant switcher.",
|
||||||
"vector-action-addsection": "Used in the Vector skin. See for example {{canonicalurl:Talk:Main_Page|useskin=vector}}\n{{Identical|Add topic}}",
|
"vector-action-addsection": "Used in the Vector skin. See for example {{canonicalurl:Talk:Main_Page|useskin=vector}}\n{{Identical|Add topic}}",
|
||||||
|
|
|
@ -223,12 +223,13 @@ abstract class SkinVector extends SkinMustache {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the ULS button if it's modern Vector, languages in header is enabled,
|
* Show the ULS button if it's modern Vector, languages in header is enabled,
|
||||||
* and the language array isn't empty. Hide it otherwise.
|
* and the ULS extension is enabled. Hide it otherwise.
|
||||||
|
* There is no point in showing the language button if ULS extension is unavailable
|
||||||
|
* as there is no ways to add languages without it.
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function shouldHideLanguages() {
|
protected function shouldHideLanguages() {
|
||||||
// NOTE: T276950 - This should be revisited when an empty state for the language button is chosen.
|
return $this->isLegacy() || !$this->isLanguagesInContent() || !$this->isULSExtensionEnabled();
|
||||||
return $this->isLegacy() || !$this->isLanguagesInContent() || empty( $this->getLanguagesCached() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -378,6 +379,15 @@ abstract class SkinVector extends SkinMustache {
|
||||||
Hooks::onSkinTemplateNavigation( $skin, $content_navigation );
|
Hooks::onSkinTemplateNavigation( $skin, $content_navigation );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether ULS is enabled
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function isULSExtensionEnabled(): bool {
|
||||||
|
return ExtensionRegistry::getInstance()->isLoaded( 'UniversalLanguageSelector' );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate data needed to generate the sticky header.
|
* Generate data needed to generate the sticky header.
|
||||||
* @param array $searchBoxData
|
* @param array $searchBoxData
|
||||||
|
@ -399,8 +409,7 @@ abstract class SkinVector extends SkinMustache {
|
||||||
$btns[] = $this->getAddSectionButtonData();
|
$btns[] = $this->getAddSectionButtonData();
|
||||||
|
|
||||||
// Show sticky ULS if the ULS extension is enabled and the ULS in header is not hidden
|
// Show sticky ULS if the ULS extension is enabled and the ULS in header is not hidden
|
||||||
$showStickyULS = ExtensionRegistry::getInstance()->isLoaded( 'UniversalLanguageSelector' )
|
$showStickyULS = $this->isULSExtensionEnabled() && !$this->shouldHideLanguages();
|
||||||
&& !$this->shouldHideLanguages();
|
|
||||||
return [
|
return [
|
||||||
'data-primary-action' => $showStickyULS ?
|
'data-primary-action' => $showStickyULS ?
|
||||||
$this->getULSButtonData() : null,
|
$this->getULSButtonData() : null,
|
||||||
|
@ -457,6 +466,7 @@ abstract class SkinVector extends SkinMustache {
|
||||||
*/
|
*/
|
||||||
public function getTemplateData(): array {
|
public function getTemplateData(): array {
|
||||||
$skin = $this;
|
$skin = $this;
|
||||||
|
|
||||||
$parentData = $this->decoratePortletsData( parent::getTemplateData() );
|
$parentData = $this->decoratePortletsData( parent::getTemplateData() );
|
||||||
$featureManager = VectorServices::getFeatureManager();
|
$featureManager = VectorServices::getFeatureManager();
|
||||||
|
|
||||||
|
@ -677,11 +687,12 @@ abstract class SkinVector extends SkinMustache {
|
||||||
* Returns ULS button label within the context of the translated message taking a placeholder.
|
* Returns ULS button label within the context of the translated message taking a placeholder.
|
||||||
*
|
*
|
||||||
* @param string $message
|
* @param string $message
|
||||||
|
* @param int $count
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getULSLabel( string $message ) {
|
private function getULSLabel( string $message, int $count ): string {
|
||||||
return $this->msg( $message )
|
return $this->msg( $message )
|
||||||
->numParams( count( $this->getLanguagesCached() ) )
|
->numParams( $count )
|
||||||
->escaped();
|
->escaped();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -709,12 +720,14 @@ abstract class SkinVector extends SkinMustache {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getULSButtonData() {
|
private function getULSButtonData() {
|
||||||
|
$numLanguages = count( $this->getLanguagesCached() );
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => 'p-lang-btn-sticky-header',
|
'id' => 'p-lang-btn-sticky-header',
|
||||||
'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' ),
|
'label' => $this->getULSLabel( 'vector-language-button-label', $numLanguages ),
|
||||||
'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'
|
||||||
];
|
];
|
||||||
|
@ -726,14 +739,23 @@ abstract class SkinVector extends SkinMustache {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getULSPortletData() {
|
private function getULSPortletData() {
|
||||||
|
$numLanguages = count( $this->getLanguagesCached() );
|
||||||
|
|
||||||
$languageButtonData = [
|
$languageButtonData = [
|
||||||
'id' => 'p-lang-btn',
|
'id' => 'p-lang-btn',
|
||||||
'label' => $this->getULSLabel( 'vector-language-button-label' ),
|
// No languages present for the article.
|
||||||
'aria-label' => $this->getULSLabel( 'vector-language-button-aria-label' ),
|
// But the page can show languages if there were languages.
|
||||||
|
'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' ),
|
||||||
'heading-class' => self::CLASS_QUIET_BUTTON . ' ' . self::CLASS_PROGRESSIVE
|
'heading-class' => self::CLASS_QUIET_BUTTON . ' ' . self::CLASS_PROGRESSIVE .
|
||||||
|
' mw-portlet-lang-heading-' . strval( $numLanguages ),
|
||||||
];
|
];
|
||||||
|
|
||||||
// Adds class to hide language button
|
// Adds class to hide language button
|
||||||
|
|
|
@ -17,6 +17,14 @@
|
||||||
opacity: 0.87;
|
opacity: 0.87;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there are no languages and JavaScript is not enabled there is no fallback so we hide
|
||||||
|
// the button altogether.
|
||||||
|
.mw-portlet-lang-heading-0 {
|
||||||
|
.client-nojs & {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.vector-menu-heading {
|
.vector-menu-heading {
|
||||||
// Prevent select of span text "X languages"
|
// Prevent select of span text "X languages"
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
|
Loading…
Reference in a new issue