Index: trunk/phase3/languages/Language.php |
— | — | @@ -131,16 +131,21 @@ |
132 | 132 | ); |
133 | 133 | |
134 | 134 | /** |
135 | | - * Get a language object for a given language code |
| 135 | + * Get a cached language object for a given language code |
136 | 136 | */ |
137 | 137 | static function factory( $code ) { |
| 138 | + if ( !isset( self::$mLangObjCache[$code] ) ) { |
| 139 | + self::$mLangObjCache[$code] = self::newFromCode( $code ); |
| 140 | + } |
| 141 | + return self::$mLangObjCache[$code]; |
| 142 | + } |
| 143 | + |
| 144 | + /** |
| 145 | + * Create a language object for a given language code |
| 146 | + */ |
| 147 | + protected static function newFromCode( $code ) { |
138 | 148 | global $IP; |
139 | 149 | static $recursionLevel = 0; |
140 | | - |
141 | | - if ( isset( self::$mLangObjCache[$code] ) ) { |
142 | | - return self::$mLangObjCache[$code]; |
143 | | - } |
144 | | - |
145 | 150 | if ( $code == 'en' ) { |
146 | 151 | $class = 'Language'; |
147 | 152 | } else { |
— | — | @@ -161,14 +166,12 @@ |
162 | 167 | if( ! class_exists( $class ) ) { |
163 | 168 | $fallback = Language::getFallbackFor( $code ); |
164 | 169 | ++$recursionLevel; |
165 | | - $lang = Language::factory( $fallback ); |
| 170 | + $lang = Language::newFromCode( $fallback ); |
166 | 171 | --$recursionLevel; |
167 | 172 | $lang->setCode( $code ); |
168 | 173 | } else { |
169 | 174 | $lang = new $class; |
170 | 175 | } |
171 | | - |
172 | | - self::$mLangObjCache[$code] = $lang; |
173 | 176 | return $lang; |
174 | 177 | } |
175 | 178 | |