Extension talk:I18nTags/LQT Archive 1

Using a language code as the second parameter to languagename, as described on this page, do not seem to work anymore. To add that option again, replace the function  in   with this code: public static function languageName( &$parser, $code = , $code2 =  ) { global $wgLang; if ( !$code ) return ''; $native = $code2 === 'native'; $cldr  = is_callable(array( 'LanguageNames', 'getNames' )); if ( !$native && $cldr ) { $code2 = $code2 ? $code2 : $wgLang->getCode; $languages = LanguageNames::getNames( $code2,				LanguageNames::FALLBACK_NORMAL,				LanguageNames::LIST_MW_AND_CLDR			); } else { $languages = Language::getLanguageNames( false ); }

return isset($languages[$code]) ? $languages[$code] : $code; } To add the possibility to convert in the other direction (i.e. from a language name in some language to an ISO code, you need to edit three files: In, add  	$parser->setFunctionHook( 'languagecode',  array($class, 'languageCode' ) ); in the function  , between  . In  , add a new function like this:	public static function languageCode( &$parser, $name = , $lang =  ) {		global $wgLang;		if ( !$name ) return '';		$native = $lang === 'native';		$cldr   = is_callable(array( 'LanguageNames', 'getNames' ));		if ( !$native && $cldr ) {			$lang = $lang ? $lang : $wgLang->getCode;			$languages = LanguageNames::getNames( $lang, LanguageNames::FALLBACK_NORMAL, LanguageNames::LIST_MW_AND_CLDR );		} else {			$languages = Language::getLanguageNames( false );		}

$key = array_search($name, $languages); return $key ? $key : $name; } and finally, in, add the line 'languagecode' => array( 0, 'languagecode' ),

to the array with aliases of all languages used on your wiki, e.g. like this:

/** English (English) */ $magicWords['en'] = array( 	'languagename' => array( 0, 'languagename' ), 	'languagecode' => array( 0, 'languagecode' ), );

This is how we use this extension at Säsongsmat.nu. //rotsee 12:07, 29 October 2011 (UTC)