Fix issues with language alert in sidebar:

- Don't show language alert if:
  - language button is not in header
  - on main page
  - on special page
- Update message with sitename.

Bug: T299581
Bug: T295555
Change-Id: I6290ea440e6b4673f29939376ac47ab53a882001
This commit is contained in:
Clare Ming 2022-01-26 00:57:04 -07:00
parent 0e08ae8c17
commit 588d273360
2 changed files with 8 additions and 3 deletions

View file

@ -16,7 +16,7 @@
"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-label": "{{PLURAL:$1|$1 language|$1 languages}}",
"vector-language-redirect-to-top": "On this Wikipedia 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-action-addsection": "Add topic",
"vector-action-delete": "Delete",

View file

@ -557,7 +557,12 @@ class SkinVector extends SkinMustache {
*/
private function shouldLanguageAlertBeInSidebar(): bool {
$featureManager = VectorServices::getFeatureManager();
return $featureManager->isFeatureEnabled( Constants::FEATURE_LANGUAGE_ALERT_IN_SIDEBAR );
$isMainPage = $this->getTitle() ? $this->getTitle()->isMainPage() : false;
$shouldShowOnMainPage = $isMainPage &&
$featureManager->isFeatureEnabled( Constants::FEATURE_LANGUAGE_IN_MAIN_PAGE_HEADER );
return ( $this->isLanguagesInContentAt( 'top' ) && !$isMainPage &&
$featureManager->isFeatureEnabled( Constants::FEATURE_LANGUAGE_ALERT_IN_SIDEBAR ) ) ||
$shouldShowOnMainPage;
}
/**
@ -671,7 +676,7 @@ class SkinVector extends SkinMustache {
);
// T295555 Add language switch alert message temporarily (to be removed).
if ( $this->shouldLanguageAlertBeInSidebar() && !$parentData['is-mainpage'] ) {
if ( $this->shouldLanguageAlertBeInSidebar() ) {
$languageSwitchAlert = [
'html-content' => Html::rawElement( 'div',
[ 'class' => 'messagebox' ],