Manual:Hooks/NormalizeMessageKey

From Linux Web Expert

NormalizeMessageKey
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate>
<translate> Removed in <tvar name=1><translate> version <tvar </tvar></translate>
Allows extensions to change what system message will be displayed on a page
<translate> Define function:</translate>
public static function onNormalizeMessageKey( &$key, &$useDB, &$langCode, &$transform ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"NormalizeMessageKey": "MediaWiki\\Extension\\MyExtension\\Hooks::onNormalizeMessageKey"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> GlobalFunctions.php
<translate> Interface:</translate> NormalizeMessageKeyHook.php

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:NormalizeMessageKey extensions</tvar>.</translate>

Details

  • &$key: (string) The message going to be displayed. Change this to display a different message in its place
  • &$useDB: (bool) Whether to query the database to get the message
  • &$langCode: (string or bool) If a string, the language code that should be used to get the message, if bool true, uses the content language, if bool false, uses the site's default language
  • &$transform: (bool) Whether to expand templates and variables in the message

See also