* @since 1.21
*/
public static function isSupportedLanguage( $code ) {
- return is_readable( self::getMessagesFileName( $code ) );
+ return $code === strtolower( $code ) && is_readable( self::getMessagesFileName( $code ) );
}
/**
return (bool)preg_match( '/^[a-z0-9-]+$/i', $code );
}
+ /**
+ * Returns true if a language code is an IETF tag known to MediaWiki.
+ *
+ * @param $code string
+ *
+ * @since 1.21
+ * @return bool
+ */
+ public static function isKnownLanguageTag( $tag ) {
+ static $coreLanguageNames;
+
+ if ( $coreLanguageNames === null ) {
+ include( MWInit::compiledPath( 'languages/Names.php' ) );
+ }
+
+ if ( isset( $coreLanguageNames[$tag] )
+ || self::fetchLanguageName( $tag, $tag ) !== ''
+ ) {
+ return true;
+ }
+
+ return false;
+ }
+
/**
* @param $code
* @return String Name of the language class
if ( $start < 0 ) {
$start = 0;
}
- $groupedNumber = substr( $number , $start, $end -$start ) . $groupedNumber ;
+ $groupedNumber = substr( $number, $start, $end -$start ) . $groupedNumber ;
$end = $start;
if ( $numMatches > 1 ) {
// use the last pattern for the rest of the number
* @return bool
*/
public function hasVariants() {
- return sizeof( $this->getVariants() ) > 1;
+ return count( $this->getVariants() ) > 1;
}
/**