Consider the scenario, that I want to have a german wiki (wgContLang is de), and want to add an english text, that can be translated with the Translate extension. To make this work, I need to change the content model of the page I want to translate into english (instead of having the default german). For that I enable $wgPageLanguageUseDB and set it to true to be able to change the page language of a specific page to a different one.
Now, if I call Title::getPageLanguage() I would expect, that a language object is returned, which represents the DB language (en), instead of wgContLang (de). Unfortunately, the Translate extension still shows, that the page will be translated from de, not from en (db language).
I created a hook in another extension to recheck this:
public static function onPageContentLanguage( Title $title, Language &$pageLang, $userLang ) {
var_dump($title->getPageLanguage()->getCode());
var_dump($pageLang->getCode());
}
The output is "en" and "de". That, btw., doesn't make much sense, because Title::getPageLanguage() is usually the function, which calls the hook (through ContentHandler::getPageLanguage()). I'm currently not sure, if this is a thing of my setup or not, will verify first.
Btw.: If I change the language in the hook:
public static function onPageContentLanguage( Title $title, Language &$pageLang, $userLang ) {
$pageLang = wfGetLangObj( 'en' );
}
anything works fine.