(bug 41477) Add Language::isSupportedLanguage
[lhc/web/wiklou.git] / languages / Language.php
index eb3a37e..7a62112 100644 (file)
@@ -177,7 +177,11 @@ class Language {
         * @return Language
         */
        static function factory( $code ) {
-               global $wgLangObjCacheSize;
+               global $wgDummyLanguageCodes, $wgLangObjCacheSize;
+
+               if ( isset( $wgDummyLanguageCodes[$code] ) ) {
+                       $code = $wgDummyLanguageCodes[$code];
+               }
 
                // get the language object to process
                $langObj = isset( self::$mLangObjCache[$code] )
@@ -241,6 +245,18 @@ class Language {
                throw new MWException( "Invalid fallback sequence for language '$code'" );
        }
 
+       /**
+        * Checks whether any localisation is available for that language tag
+        * in MediaWiki (MessagesXx.php exists).
+        *
+        * @param string $code Language tag (in lower case)
+        * @return bool Whether language is supported
+        * @since 1.21
+        */
+       public static function isSupportedLanguage( $code ) {
+               return is_readable( self::getMessagesFileName( $code ) );
+       }
+
        /**
         * Returns true if a language code string is of a valid form, whether or
         * not it exists. This includes codes which are used solely for