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": {