Move capitalize-all-nouns CSS class support from core to MonoBook

Bug: T97892
Change-Id: I598c4469c46d284562ea3aec79330f9a1f40d2ce
This commit is contained in:
Jack Phoenix 2020-01-07 17:34:37 +02:00 committed by Jdlrobson
parent bc80783b1e
commit 57e963507c
3 changed files with 30 additions and 4 deletions

View file

@ -63,6 +63,29 @@ class SkinMonoBook extends SkinTemplate {
] ); ] );
} }
/**
* Add the "monobook-capitalize-all-nouns" CSS class to the <body> 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 <body> 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 User $user
* @param array &$preferences * @param array &$preferences

View file

@ -64,10 +64,12 @@ li#pt-userpage {
} }
/* Override text-transform on languages where capitalization is significant */ /* Override text-transform on languages where capitalization is significant */
.capitalize-all-nouns .portlet h3, .monobook-capitalize-all-nouns {
.capitalize-all-nouns #p-personal ul, .portlet h3,
.capitalize-all-nouns #p-cactions ul li a { #p-personal ul,
text-transform: none; #p-cactions ul li a {
text-transform: none;
}
} }
/* Sometimes people don't want personal tools to be lowercase! */ /* Sometimes people don't want personal tools to be lowercase! */

View file

@ -26,6 +26,7 @@
"monobook": "resources/mediawiki.less" "monobook": "resources/mediawiki.less"
}, },
"Hooks": { "Hooks": {
"OutputPageBodyAttributes": "SkinMonoBook::onOutputPageBodyAttributes",
"GetPreferences": "SkinMonoBook::onGetPreferences" "GetPreferences": "SkinMonoBook::onGetPreferences"
}, },
"MessagesDirs": { "MessagesDirs": {