Manual:Hooks/LanguageGetMagic

LanguageGetMagic is an event for which a hook is available. Correspondingly it is an index of the array $wgHooks. The array value is an array of function names. To add a function name, a parser function extension can use a statement like:

$wgHooks['LanguageGetMagic'][]      = "function_defining_magic_words";

These functions provide for each parser function, optionally depending on $Langcode, a list of names that can be used in the wikitext for the parser function, and whether these names are case-sensitive (0=no, 1=yes):

$magicWords[' magic_word_ID ']   = array( case_sensitivity_code, comma-separated_list_of_magic_words );

Thus in the simplest case it defines a single name for a single function, independent of language:

function function_defining_magic_words( &$magicWords, $langCode ) { $magicWords[' magic_word_id '] = array( 0, ' function_name_in_wikitext ' ); return true; // unless we return true, other parser function extensions won't get loaded. }

Function setFunctionHook in Parser.php fills array mFunctionSynonyms with magic word IDs for all synonyms in the applicable language of all functions:

$this->mFunctionSynonyms[$sensitive][$syn] = $id;

and uses this in function braceSubstitution to convert a function synonym to a function ID.