Skip to content

Commit

Permalink
Merge pull request #4 from Zverik/master
Browse files Browse the repository at this point in the history
Update to work with MediaWiki 1.26.2
  • Loading branch information
tszming committed Dec 25, 2015
2 parents 7f36379 + 74689c5 commit ceef680
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
6 changes: 3 additions & 3 deletions example.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
* YOU SHOULD PLACE THEM OUTSIDE THE DOCUMENT ROOT OF YOUR WEB SERVER!!!
*/

define("MEDIAWIKI_PATH", "/var/lib/mediawiki-1.6.10/");
define("MEDIAWIKI_PATH", "/var/lib/mediawiki-1.26.2/");

/* Include our helper class */
require_once "mediawiki-zhconverter.inc.php";

/* Convert it, valid variants such as zh, zh-cn, zh-tw, zh-sg & zh-hk */
/* Convert it, valid variants such as zh, zh-hans, zh-hant, zh-cn, zh-tw, zh-sg & zh-hk */
echo MediaWikiZhConverter::convert("雪糕", "zh-tw") , ",";
echo MediaWikiZhConverter::convert("記憶體", "zh-cn"), ",";
echo MediaWikiZhConverter::convert("大卫·贝克汉姆", "zh-hk");

?>
?>
16 changes: 15 additions & 1 deletion mediawiki-zhconverter.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ static function &getConverter() {
global $wgRequest, $wgMemc;
global $wgLocalisationCacheConf, $wgDisabledVariants, $wgExtraLanguageNames;
global $wgLangConvMemc, $wgMessageCacheType, $wgObjectCaches;
global $wgLanguageConverterCacheType, $wgMWLoggerDefaultSpi, $wgMainWANCache, $wgWANObjectCaches;
$wgRequest = new WebRequest();
$wgMemc = new FakeMemCachedClient;

Expand All @@ -143,20 +144,33 @@ static function &getConverter() {
$wgDisabledVariants = array();
$wgExtraLanguageNames = array();
$wgLangConvMemc = new FakeMemCachedClient;
define('CACHE_NONE', 'FAKE');
$wgObjectCaches = array(
'FAKE' => array( 'class' => 'FakeMemCachedClient' ),
);
$wgMessageCacheType = 'FAKE';
$wgLanguageConverterCacheType = 'FAKE';
$wgMainWANCache = 'FAKE';
$wgWANObjectCaches = array(
'FAKE' => array(
'class' => 'WANObjectCache',
'cacheId' => 'FAKE',
'pool' => 'mediawiki-main-none',
'relayerConfig' => array( 'class' => 'EventRelayerNull' )
)
);
$wgMWLoggerDefaultSpi = array( 'class' => '\\MediaWiki\\Logger\\NullSpi' );

require_once "includes/GlobalFunctions.php";
require_once "includes/AutoLoader.php";
require_once "vendor/autoload.php";

/* Switch for PHP4 and PHP5 version of MediaWiki */
if (file_exists( MEDIAWIKI_PATH . "languages/LanguageZh.php")) {
require_once "languages/LanguageZh.php";
} else {
require_once "languages/classes/LanguageZh.php";
require_once "includes/utils/StringUtils.php";
require_once "includes/libs/StringUtils.php";
}

$instance = new MediaWikiZhConverter();
Expand Down

0 comments on commit ceef680

Please sign in to comment.