Constructor
new mw.Message(map, key, [parameters])
#
Object constructor for messages. The constructor is not publicly accessible;
use mw.message
instead.
Parameters:
- Source:
Methods
escaped() → {string}
#
Format message and return as escaped text in HTML.
This is equivalent to the #text format, which is then HTML-escaped.
- Source:
Returns:
String form of html escaped message
- Type
- string
exists() → {boolean}
#
isParseable() → {boolean}
#
Check whether the message contains only syntax supported by jqueryMsg.
This method is only available when jqueryMsg is loaded.
Example
const msg = mw.message( 'key' );
mw.loader.using(`mediawiki.jqueryMsg`).then(() => {
if ( msg.isParseable() ) {
...
}
})
- Since:
- 1.41
- Source:
Returns:
- Type
- boolean
params(parameters) → {mw.Message}chainable
#
Add (does not replace) parameters for $N
placeholder values.
Parameters:
Name | Type | Description |
---|---|---|
parameters |
Array |
- Source:
Returns:
- Type
- mw.Message
$N
placeholder values.
parse() → {string}
#
Parse message as wikitext and return HTML.
If jqueryMsg is loaded, this transforms text and parses a subset of supported wikitext
into HTML. Without jqueryMsg, it is equivalent to mw.Message#escaped
.
- Source:
Returns:
String form of parsed message
- Type
- string
parseDom() → {jQuery}
#
Parse the message to DOM nodes, rather than HTML string like mw.Message#parse
.
This method is only available when jqueryMsg is loaded.
Example
const msg = mw.message( 'key' );
mw.loader.using(`mediawiki.jqueryMsg`).then(() => {
if ( msg.isParseable() ) {
const $node = msg.parseDom();
$node.appendTo('body');
}
})
- Since:
- 1.27
- Source:
Returns:
- Type
- jQuery
mw.Message#parse
.
plain() → {string}
#
Return message plainly.
This substitutes parameters, but otherwise does not transform the message content.
- Source:
Returns:
String form of plain message
- Type
- string
text() → {string}
#
Format message with text transformations applied.
If jqueryMsg is loaded, {{
-transformation is done for supported
magic words such as {{plural:}}
, {{gender:}}
, and {{int:}}
.
Without jqueryMsg, it is equivalent to mw.Message#plain
.
- Source:
Returns:
String form of text message
- Type
- string