function mlSetLangParse(&$parser, &$text, &$strip_state) { global $wgLang; global $wgUser; global $wgLanguageCode; global $wgContLanguageCode; $page = $parser->getTitle(); if (get_class($page) == "Title") { $i = $page->getArticleID(); $controller = new MultiLanguageManager_controller(); MultiLanguageManager_controller::setUILanguage($controller->getPageLanguage($i)); } return true; }
/** * TARGET : getPageLanguage * Scenario 1: (it will be used to test 2 cases) * Page A in the default language * Page B not in the default language * * We check the A language * We check the B language */ public function testGetPageLanguage_scenario1_ndl() { global $wgContLanguageCode; $controller = new MultiLanguageManager_controller(); MultiLanguageManager_controller::setUILanguage($this->notDefaultLanguage); $this->dbw->safeQuery("INSERT INTO ! (page_id, lang) VALUES (?, ?)", $this->db_page_language, $this->pageswithoutlanguage[1], $this->notDefaultLanguage); $this->assertEquals($this->dbw->affectedRows(), 1); //scenario1 : ready $this->assertEquals($controller->getPageLanguage($this->pageswithoutlanguage[0]), $wgContLanguageCode); $this->assertEquals($controller->getPageLanguage($this->pageswithoutlanguage[1]), $this->notDefaultLanguage); }