Language object cache, for faster wfMsg() performance with unusual languages, and hopefully less memory. Committing for test on server.

This commit is contained in:
Tim Starling 2008-11-11 23:26:07 +00:00
parent 053f795416
commit 49ef4c23a2

View file

@ -74,6 +74,7 @@ class Language {
static public $mMergeableAliasListKeys = array( 'specialPageAliases' );
static public $mLocalisationCache = array();
static public $mLangObjCache = array();
static public $mWeekdayMsgs = array(
'sunday', 'monday', 'tuesday', 'wednesday', 'thursday',
@ -130,12 +131,16 @@ class Language {
);
/**
* Create a language object for a given language code
* Get a language object for a given language code
*/
static function factory( $code ) {
global $IP;
static $recursionLevel = 0;
if ( isset( self::$mLangObjCache[$code] ) ) {
return self::$mLangObjCache[$code];
}
if ( $code == 'en' ) {
$class = 'Language';
} else {
@ -163,6 +168,7 @@ class Language {
$lang = new $class;
}
self::$mLangObjCache[$code] = $lang;
return $lang;
}