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
$this->assertEquals( "a{$c}b{$and}{$s}c", $lang->listToText( array( 'a', 'b', 'c' ) ) );
$this->assertEquals( "a{$c}b{$c}c{$and}{$s}d", $lang->listToText( array( 'a', 'b', 'c', 'd' ) ) );
}
+
+ /**
+ * @dataProvider provideIsSupportedLanguage
+ */
+ function testIsSupportedLanguage( $code, $expected, $comment ) {
+ $this->assertEquals( $expected, Language::isSupportedLanguage( $code ), $comment );
+ }
+
+ static function provideIsSupportedLanguage() {
+ return array(
+ array( 'en', true, 'is supported language' ),
+ array( 'fi', true, 'is supported language' ),
+ array( 'bunny', false, 'is not supported language' ),
+ array( 'FI', false, 'is not supported language, input should be in lower case' ),
+ );
+ }
}