Open main menu

Changes

→‎Finding system messages: the part after the # isn't a tab, it's a fragment
{{information page|H:SM}}
Wikipedia uses system message pages to create the user interface as seen by readers. The user interface includes all visual elements of Wikipedia, such as the left sidebar, the top toolbar and error messages. These system pages are in located in the [[Help:MediaWiki namespace|MediaWiki namespace]], available for each supported language, customizable and can be edited only by [[Wikipedia:Administrators|administrators]] and [[m:interface editors|interface editors]].

==Technical==
In principle for every language a set of ca. 1800 '''system messages''' in that language is provided in the '''message file''' languages/Messages''languagecode''.php. In the preferences a logged-in user can [[Help:Preferences#Interface language|select an interface language]]. For incidental use it can also be specified in the URL with the parameter [[mw:Manual:Parameters to index.php#Preference overriding|uselang=''language_code'']]. As of October 2007 there are ca. 150 interface languages to choose from. For completeness of the language files see [[mw:Localisation statistics|localization statistics]].

Each MediaWiki site has a [[mw:Manual:$wgLanguageCode|site language]]. This is the default interface language for that site. As of October 2007 there are ca. 100 languages for which there is a separate Wikipedia but not yet a language file. These Wikipedias usually have English as default interface language. However, nowadays creating the language file is a condition for opening a new language edition of Wikipedia, see [[Meta:Language proposal policy#Requisites]].

Typically the code uses the site language in link targets (function wfMsgForContent), and the user-specified language in other texts, including link labels (function wfMsg).

HTML elements which are not normally passed on to the browser, ''are'' when occurring in certain messages.

==Finding system messages==
You can find a message key by browsing Wikipedia in the special pseudo-language code <code>'''qqx'''</code>, which can be done by appending <code>?[[:mw:uselang]]=qqx</code>to the URL, or <code>&uselang=qqx</code> if the URL already contains a <code>?</code> character ([{{fullurl:{{FULLPAGENAME}}|uselang=qqx}} example]). All the messages will then be replaced by their message keys, so you can identify which message is responsible. Messages that are always in the content language will not be shown using qqx.

When the URL includes a fragment that links to a particular point on the page such as a section or a tab like e.g. [[Special:Preferences#mw-prefsection-rendering|special page "Preferences"]] you will have to add the fragment after the uselang parameter, e.g. <code>Special:Preferences?uselang=qqx#mw-prefsection-rendering</code>.

==MediaWiki namespace==
The '''MediaWiki namespace''' is one of the 16 standard [[Help:namespace|namespaces]] in the database structure of the MediaWiki software. For all languages this namespace allows [[Help:Administration|administrators]] to create site-specific deviations from the default system messages. It is enabled by default in recent mediawiki versions, <code>[[mw:Manual:$wgUseDatabaseMessages|$wgUseDatabaseMessages]] = true;</code> enables them. For each deviation from the default in the site language [[mw:Manual:$wgLanguageCode|$wgLanguageCode]] there is a page MediaWiki:''message_ID'', and for each deviation from the default in each other language a page MediaWiki:''message_ID/language_code''. See e.g. [[MediaWiki:Aboutpage]]. However, MediaWiki:Sidebar''/language_code'' does not work (for a [[mw:MediaWiki:sidebar|sidebar]] for users with that interface language); instead, the page MediaWiki:Sidebar can refer to message ID's which provides link labels dependent on the user-specified interface language. If the message is neither defined in the message file concerned, nor on the MediaWiki page, the message in the message file for English is used.

When viewing a "non-existing" page of which the name is an existing message name, the page shows the default. A "non-existing" page can be recognized by the lack of a history link. The edit page autofills with the default. Transclusion of a "non-existing" page in the MediaWiki namespace trancludes the default.

For the names of all "existing" pages see [{{fullurl:Special:Allpages|from=MediaWiki:%21}} @] [[Special:Prefixindex/MediaWiki:A|A]] [[Special:Prefixindex/MediaWiki:B|B]] [[Special:Prefixindex/MediaWiki:C|C]] [[Special:Prefixindex/MediaWiki:D|D]] [[Special:Prefixindex/MediaWiki:E|E]] [[Special:Prefixindex/MediaWiki:F|F]] [[Special:Prefixindex/MediaWiki:G|G]] [[Special:Prefixindex/MediaWiki:H|H]] [[Special:Prefixindex/MediaWiki:I|<small> </small>I<small> </small>]] [[Special:Prefixindex/MediaWiki:J|J]] [[Special:Prefixindex/MediaWiki:K|K]] [[Special:Prefixindex/MediaWiki:L|L]] [[Special:Prefixindex/MediaWiki:M|M]] [[Special:Prefixindex/MediaWiki:N|N]] [[Special:Prefixindex/MediaWiki:O|O]] [[Special:Prefixindex/MediaWiki:P|P]] [[Special:Prefixindex/MediaWiki:Q|Q]] [[Special:Prefixindex/MediaWiki:R|R]] [[Special:Prefixindex/MediaWiki:S|S]] [[Special:Prefixindex/MediaWiki:T|T]] [[Special:Prefixindex/MediaWiki:U|U]] [[Special:Prefixindex/MediaWiki:V|V]] [[Special:Prefixindex/MediaWiki:W|W]] [[Special:Prefixindex/MediaWiki:X|X]] [[Special:Prefixindex/MediaWiki:Y|Y]] [[Special:Prefixindex/MediaWiki:Z|Z]]

For the interface language set in the preferences, all default messages and current versions can be viewed at '''[[Special:Allmessages]]''', with red links to create new deviations from the defaults. When creating a page to override the default it is useful to first save the default version, to allow diffs with it.

Deviating from the default is a bit slower.

An administrator with access to the language files can choose between adapting these and creating pages in the MediaWiki namespace. The latter makes it easier to update to a new version of MediaWiki while keeping the own versions of messages. On the other hand, is easier to transfer a language file to another MediaWiki site than to export and import pages, for the benefit of users who have selected the language concerned as interface language.

An extension can set e.g. message key aaa to bbb by:

global $wgMessageCache;
$wgMessageCache->addMessages( array ('aaa' => 'bbb') );

The key has to start with a lowercase letter, even though message files define messages using an ID written with a capital, and even though the corresponding MediaWiki page has a capital after the colon, in this case MediaWiki:Aaa, even on wikis which allow a lowercase first letter in page names. (The default content of MediaWiki:aaa becomes bbb, but changing it has no effect.)

After getting the array $ma of extension messages:
$ma = $wgMessageCache->getExtensionMessagesFor( 'en' );
the value can be retrieved with $ma['aaa'], e.g. by:
$wgOut->addWikiText( $ma['aaa'] );

The result after possible overriding by the contents of the MediaWiki page can be retrieved by wfMsg('aaa').

This applies not only for a message in the strict sense; for example, an extension can allow the user community, through a sysop, to supply parameters in this way; this can even be the name of an extension tag, see e.g. [[mw:Extension:PropertyTable]], where the tag <nowiki><</nowiki>properties> is the default, but e.g. the tag <nowiki><</nowiki>pr> can be used after creating the page "MediaWiki:propertyTable tag" with the content "pr" (but note that for portability of wikitext across wikis with the same extension this flexibility has also disadvantages).

All characters of namespace prefixes are case-insensitive, so one can write "mediawiki:".

== MediaWiki before version 1.9.x ==
The concept of messages has changed in release 1.9.x. Before, there existed a page for each message, even if it was the default. On upgrade, all pages with default messages are deleted.

==Protection==
By default, the whole MediaWiki namespace is protected. This is necessary for a number of reasons:
* Many messages are in plain HTML, hence users could insert malicious scripts
* Vandalism of some messages would be extremely disruptive, for example changes to the text of the links in the sidebar would immediately be visible to all users

On the other hand, especially for pages MediaWiki:''message_ID/language_code'' the protection is somewhat impractical because administrators do not know all the languages that can be set for the user interface.

If an administrator wishes to allow general editing of a MediaWiki page, a method is to place the message on a template, and transclude the template onto the MediaWiki page.

A few messages can in theory cause the software to stop working if they are changed, for example "linktrail". Therefore and for processing efficiency the effect of page [[MediaWiki:Linktrail]] has been disabled: the software ignores its contents, taking the regular expression straight out of the message files.

==Technical details==
The namespace number of {{ns:8}} messages is '''8''', with a corresponding {{ns:9}} namespace '''9''' to discuss individual messages.
Some MediaWiki wikis offer templates like {{links-small|w|template|editprotected}} to propose modifications, others have a page like
[[m:Meta:Requests for help from a sysop or bureaucrat|Meta:Requests for help from a sysop or bureaucrat]] for this purpose.

;Links to MediaWiki messages work like links to ordinary pages, examples:
:<code><nowiki>[[MediaWiki:Edit]]</nowiki></code> [[MediaWiki:Edit]],
:<code><nowiki>[[w:de:MediaWiki:Edit]]</nowiki></code> [[w:de:MediaWiki:Edit]],
:<code><nowiki>[{{fullurl:m:MediaWiki:Edit|action=render}} demo]</nowiki></code> [{{fullurl:m:MediaWiki:Edit|action=render}} demo].

Each message in the <code>$wgAllMessagesEn</code> array in [http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/Messages.php Messages.php] corresponds to a page in the MediaWiki namespace. For example, there is a line in the php file:

'confirmprotect' =&gt; 'Confirm protection',

To this corresponds the page [[MediaWiki:Confirmprotect]], and {{evaldemo|int:Confirmprotect}}. When this page is edited the new message is automatically used for say {{fullurl:m:Main page|action=protect}}. Similarly [[w:fr:MediaWiki:Confirmprotect]] has the content ''Confirmer la protection'', note that the page name itself is not translated.

===Transclusion===
Transclusion of a system message, see e.g. {{links-small|template|Ed}}, can be done with the regular tranclusion syntax for the MediaWiki page, even if the page does not exist and the default is used:
:{{evaldemo|MediaWiki:Edit|&#61;}}, the system message with id "edit" that the site uses in the default interface interlanguage of the site.
Also, [[Help:parser function|parser function]] '''int''' can be used:
:{{evaldemo|int:Edit|&#61;}}, the system message with id "edit" that the site uses in the user-specified interface interlanguage.

If there is neither a page nor a default the result of "int" is different from "MediaWiki:" even if the user uses the default interface language of the site:
:{{evaldemo|MediaWiki:Erehwon|&#61;}}
:{{evaldemo|int:Erehwon|&#61;}}
Messages defined in extensions, even if they are in [[Special:Allmessages]], may or may not be transcluded:
:{{evaldemo|MediaWiki:Dynamicpagelist noresults}}
:{{evaldemo|MediaWiki:Expandtemplates}}

However many messages are not suited for inclusion, because they contain '''$1''' and similar parameters not evaluated by the
template parser, or raw [[w:Cascading Style Sheets|CSS]] and [[w:en:XHTML|XHTML]] markup not permitted on normal pages.

===Interlanguage links===
[[Help:Interwiki linking|Interlanguage links]] in MediaWiki messages typically do not work: noinclude tags and the link syntax may not be interpreted.

Instead, one can use in-page interlanguage links on the talk pages, {{links-small|template|ilm}} does this for some major MediaWiki wikis.

===Strings exclusive to language file===
Some text strings cannot be customised using this feature, and so can only be changed by editing the language file:
* The namespace titles "User", "Wikipedia", "Image", etc. ($namespaceNames)
* The names of the special pages ($specialPageAliases)
* $skinNames (shown in [[Special:Preferences]])
* $bookstoreList
* $separatorTransformTable
* $linkTrail
* $dateFormats

==See also==
* [[mw:Internationalisation]]
* [[m:MediaWiki localisation]]
* [[m:Writing a new special page#MessageCache $wgMessageCache|The message cache]] - possibly not up-to date
* [[m:Help:MediaWiki namespace/old|MediaWiki namespace in version 1.2.6]]
* [[w:Wikipedia:MediaWiki namespace]]
* [[mw:Localisation statistics]]
* [[Help:User style]] - site-wide CSS and JS is partly defined in "system message" "common.css", etc.
* [[mw:Extension:Multilang]] - extension to create content depending on the user-specified interface language
* [http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/languages/messages/ Message files]
{{Wikipedia technical help|state=collapsed}}
[[Category:MediaWiki Help]]
Anonymous user