From 57e963507c84d67a3584f0d13f769a26bd649359 Mon Sep 17 00:00:00 2001 From: Jack Phoenix Date: Tue, 7 Jan 2020 17:34:37 +0200 Subject: [PATCH] Move capitalize-all-nouns CSS class support from core to MonoBook Bug: T97892 Change-Id: I598c4469c46d284562ea3aec79330f9a1f40d2ce --- includes/SkinMonoBook.php | 23 +++++++++++++++++++++++ resources/screen-desktop.less | 10 ++++++---- skin.json | 1 + 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/includes/SkinMonoBook.php b/includes/SkinMonoBook.php index e587377..716e3ba 100644 --- a/includes/SkinMonoBook.php +++ b/includes/SkinMonoBook.php @@ -63,6 +63,29 @@ class SkinMonoBook extends SkinTemplate { ] ); } + /** + * Add the "monobook-capitalize-all-nouns" CSS class to the element for German + * (de) and various languages which have German set as a fallback language, such + * as Colognian (ksh) and others. + * + * @see https://phabricator.wikimedia.org/T97892 + * @see https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageBodyAttributes + * @param OutputPage $out + * @param Skin $skin + * @param array &$bodyAttrs Pre-existing attributes for the element + */ + public static function onOutputPageBodyAttributes( OutputPage $out, Skin $skin, &$bodyAttrs ) { + $lang = $skin->getLanguage(); + if ( + $skin->getSkinName() === 'monobook' && ( + $lang->getCode() === 'de' || + in_array( 'de', $lang->getFallbackLanguages() ) + ) + ) { + $bodyAttrs['class'] .= ' monobook-capitalize-all-nouns'; + } + } + /** * @param User $user * @param array &$preferences diff --git a/resources/screen-desktop.less b/resources/screen-desktop.less index 7c3ec34..0b58ab2 100644 --- a/resources/screen-desktop.less +++ b/resources/screen-desktop.less @@ -64,10 +64,12 @@ li#pt-userpage { } /* Override text-transform on languages where capitalization is significant */ -.capitalize-all-nouns .portlet h3, -.capitalize-all-nouns #p-personal ul, -.capitalize-all-nouns #p-cactions ul li a { - text-transform: none; +.monobook-capitalize-all-nouns { + .portlet h3, + #p-personal ul, + #p-cactions ul li a { + text-transform: none; + } } /* Sometimes people don't want personal tools to be lowercase! */ diff --git a/skin.json b/skin.json index ad9f8ac..3a6fbb0 100644 --- a/skin.json +++ b/skin.json @@ -26,6 +26,7 @@ "monobook": "resources/mediawiki.less" }, "Hooks": { + "OutputPageBodyAttributes": "SkinMonoBook::onOutputPageBodyAttributes", "GetPreferences": "SkinMonoBook::onGetPreferences" }, "MessagesDirs": {