Commits

Etienne Perot committed 9de51b5

Add {{#languagetitle}} parser function to return a capitalized version of a language name, as the old {{#language}} function did

Comments (0)

Files changed (1)

 }
 
 function wfLangUtils_ParserFirstCallInit( $parser ) {
+	$parser->setFunctionHook( 'languagetitle', 'ExtLangUtils::languagetitle', SFH_OBJECT_ARGS );
 	$parser->setFunctionHook( 'langswitch', 'ExtLangUtils::langswitch', SFH_OBJECT_ARGS );
 	$parser->setFunctionHook( 'ifpagelang', 'ExtLangUtils::ifpagelang', SFH_OBJECT_ARGS );
 
 }
 
 function wfLangUtils_LanguageGetMagic( &$magicWords, $langCode ) {
+	$magicWords['languagetitle'] = array( 0, 'languagetitle' );
 	$magicWords['langswitch'] = array( 0, 'langswitch' );
 	$magicWords['ifpagelang'] = array( 0, 'ifpagelang' );
 	$magicWords['pagelang'] = array( 0, 'pagelang' );
 
 	}
 
+	public static function languagetitle( $parser, $frame, $args ) {
+		global $coreLanguageNames_titlecase;
+		if ( count( $args ) == 0 || !isset($coreLanguageNames_titlecase[$args[0]]) ) {
+			return '';
+		}
+		return $coreLanguageNames_titlecase[$args[0]];
+	}
+
 	public static function langswitch( $parser, $frame, $args ) {
 		ExtLangUtils::setLang( $parser );