Manual:Messages API

The new localisation system was introduced in MediaWiki 1.17, and replaced the old  functions.

Automatically generated documentation from trunk:
 * https://svn.wikimedia.org/doc/classMessage.html#_details

Basics
returns a  object that allows to manipulate the system messages. You can supply message parameters with. To use raw parameters that will be substituted after the rest of the message is parsed and/or escaped, use. You must take care yourself that thse parameters are HTML-safe and don't introduce an XSS.

Language
By default, messages are displayed in the user language. In some cases, they need to be:
 * In the wiki content language
 * In any specific language, where $lang is a language code (string) or Language object.
 * In any specific language, where $lang is a language code (string) or Language object.

Format
It is recommended to specify the output format at the end of. It defaults to 'parse'.
 * returns the message text as-is; only parameters are substituted.
 * transforms the message text (MessageCache::transform which transforms all ' ')
 * same as 'text', but also escapes it (htmlspecialchars)
 * parses the message text from wikitext to HTML (MessageCache::parse which calls the Parser)
 * returns the parsed message text which is always surrounded by a block element, i.e. the message text will be added in a paragraph tag.

Call chaining
Most functions of this class return the current object, so you can conveniently make chained calls that do several operations with the object at once:

Special pages
In special pages, it is generally preferable to use $this->msg since it avoids making your code dependent on a global function.

Rationale
Problems with the old message system:
 * Many function with many parameters are confusing
 * The simple case is complicated to do
 * The simple way to do is wrong (wfMsg)
 * wfMsg replaces variables after {{-transform, does not parse nor escape
 * When fallbacks message is used, parsing in wrong language can lead to really broken results. Think about a language which has three plurals – English definition has only two, but it is parsed with the interface language. It used to be worse before all plural functions were made to use the last supplied value if there is too few given. This also affects other language dependent stuff like grammar.
 * replaceafter affects all parameters, where it is usually needed only for some of them
 * parsemag (or {{-transform, escape, parse, parseinline... hard to get it right

Suggested solution for all problems above expect parsing in a wrong language, since that problem is much deeper.