+ wfProfileIn( __METHOD__ );
+ $cacheKey = $inLanguage === null ? 'null' : $inLanguage;
+ $cacheKey .= ":$include";
+ if ( self::$languageNameCache === null ) {
+ self::$languageNameCache = new MapCacheLRU( 20 );
+ }
+ if ( self::$languageNameCache->has( $cacheKey ) ) {
+ $ret = self::$languageNameCache->get( $cacheKey );
+ } else {
+ $ret = self::fetchLanguageNamesUncached( $inLanguage, $include );
+ self::$languageNameCache->set( $cacheKey, $ret );
+ }
+ wfProfileOut( __METHOD__ );
+ return $ret;
+ }
+
+ /**
+ * Uncached helper for fetchLanguageNames
+ * @param null|string $inLanguage Code of language in which to return the names
+ * Use null for autonyms (native names)
+ * @param string $include One of:
+ * 'all' all available languages
+ * 'mw' only if the language is defined in MediaWiki or wgExtraLanguageNames (default)
+ * 'mwfile' only if the language is in 'mw' *and* has a message file
+ * @return array Language code => language name
+ */
+ private static function fetchLanguageNamesUncached( $inLanguage = null, $include = 'mw' ) {