$revision: New Revision of the article
'PageContentLanguage': Allows changing the language in which the content of a
-page is written. Defaults to the wiki content language ($wgContLang).
+page is written. Defaults to the wiki content language.
$title: Title object
-&$pageLang: the page content language (either an object or a language code)
-$wgLang: the user language
+&$pageLang: the page content language. Input can be anything (under control of
+ hook subscribers), but hooks should return Language objects. Language code
+ strings are deprecated.
+$userLang: the user language (Language or StubUserLang object)
'PageContentSave': Before an article is saved.
$wikiPage: the WikiPage (object) being saved
* This default implementation just returns the content language (except for pages
* in the MediaWiki namespace)
*
- * Note that the pages language is not cacheable, since it may in some
+ * Note that the page's language is not cacheable, since it may in some
* cases depend on user settings.
*
* Also note that the page language may or may not depend on the actual content of the page,
global $wgLang;
$pageLang = MediaWikiServices::getInstance()->getContentLanguage();
- if ( $title->getNamespace() == NS_MEDIAWIKI ) {
+ if ( $title->inNamespace( NS_MEDIAWIKI ) ) {
// Parse mediawiki messages with correct target language
list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $title->getText() );
$pageLang = Language::factory( $lang );
$handler = ContentHandler::getForTitle( $title );
$lang = $handler->getPageLanguage( $title );
+ $this->assertInstanceOf( Language::class, $lang );
$this->assertEquals( $expected->getCode(), $lang->getCode() );
}