GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Main page
  • Get MediaWiki
  • Get extensions
  • Tech blog
  • Contribute
  • User help
  • FAQ
  • Technical manual
  • Support desk
  • Communication
  • Developer portal
  • Code statistics
  • Community portal
  • Recent changes

This view

  • Original page
  • New address

GeezerVison is showing www.mediawiki.org — Manual:Hooks/MessageCacheFetchOverrides - MediaWiki

< Manual:Hooks
MessageCacheFetchOverrides
Available from version 1.41.0 (Gerrit change 884416)
Allows changing message keys to customize them before the translation is accessed
Define function:
public static function onMessageCacheFetchOverrides( array &$keys ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"MessageCacheFetchOverrides": "MediaWiki\\Extension\\MyExtension\\Hooks::onMessageCacheFetchOverrides"
	}
}
Called from: File(s): Language/MessageCache.php
Interface: MessageCacheFetchOverridesHook.php

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

Details

Both the input and output keys must have an initial lowercase character. No spaces can be used in the keys; any spaces must be converted to underscores.

  • &$keys - Array of message keys mapped to their replacement.

Values may be either a string or a callable that returns a string. Callables are provided two arguments: the message key, an instance of MessageCache. Before MediaWiki 1.44, there were two extra arguments: a Language object, and a boolean indicating if the value should be loaded from the database.

// Since MediaWiki 1.44
function ( string $key, MessageCache $cache ): string { ... }
// Previous versions
function ( string $key, MessageCache $cache, Language $language, bool $useDB ): string { ... }

To prevent ambiguity between message keys that can also be interpreted as a callable (strtotime, for example), all string values are interpreted as a message key. To use a callable defined as a string, use Closure::fromCallable.

See also

  • MessagesPreLoad hook
  • MessageCache::get hook
Retrieved from "https://www.mediawiki.org/w/index.php?title=Manual:Hooks/MessageCacheFetchOverrides&oldid=8332781"
Categories:
  • MediaWiki hooks
  • Hooks added in MediaWiki 1.41.0
  • MediaWiki hooks included in MessageCache.php
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.