Manual:Hooks/MessagesPreLoad

From MediaWiki.org
Jump to navigation Jump to search
MessagesPreLoad
Available from version 1.5.7 (r12999)
When loading a message from the database
Define function:
public static function onMessagesPreLoad( $title, &$message, $code ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"MessagesPreLoad": "MyExtensionHooks::onMessagesPreLoad"
	}
}
Called from:File(s): cache/MessageCache.php
Interface:MessagesPreLoadHook.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:MessagesPreLoad extensions.

Details[edit]

  • $title: title of the message (string)
  • $message: value (string), change it to the message you want to define
  • $code: language code being requested (string)

This hook is sometimes used to programatically provide the text of a message. Note though that that will not work when the message's useDatabase flag has been disabled.

See also[edit]