In MediaWiki, there are various kinds of languages:
ContentLanguage service inMediaWiki\MediaWikiServices::getContentLanguage, based on$wgLanguageCode), which should generally stay the same as long as the wiki exists.$wgLang), which can be changed in your preferences or with&uselang=xyz in the URL, but also generally remains the same while using the wiki.&variant (or$wgVariantArticlePath) in the URL (e.g. by selecting one of the tabs)if it is a variant of the content language of the page being viewed. It's defined in getPageViewLanguage() inTitle, representing what language the rendered HTML content is written in.All three of them arelanguage objects.
A language code is a valid standard abbreviation for a language supported by MediaWiki,[1] which uses such codes as standard identifiers for languages (mostly in accordance withISO 639-3, except two-letter codes from ISO 639-1 for "established" locales) and exposes or requires them in many points of the interface and code.[2]
In the example below,MediaWiki:Message/ar,ar is the language code for Arabic.
Uniformity with Unicode standard is needed to provide a good language support, in particular in cooperation withCLDR; having an ISO 639-3 code is onerequirement for a language to be added to MediaWiki locales.
There are some special language codes for internal or development use:
qqq – for message documentation, does not work withuselang etc.qqx – shows message names for debuggingen-x-rtl – English, but pretends it is a right-to-left languageen-x-piglatin – when$wgUsePigLatinVariant is enabled, forLanguageConverter testingx-xss – when$wgUseXssLanguage is enabled, tests XSS vulnerabilities in messagesNames.php is the master registry of languages supported by MediaWiki.This is not the same as languages of which MediaWiki will show l10n (JSON files) nor languages of which MediaWiki knows the names (viaCLDR), mind you!

Some languages in MediaWiki have what is known as a "fallback sequence".This is where MediaWiki will fall back on a different language if it cannot find what it needs.An example of this is the language codefrc (Cajun French), which falls back on the language codefr (French).The reason for this is that sometimes languages don't have all messages defined in them.
The fallback for a language can be found in its associatedlanguages/messages/MessagesXX.php file.For instanceMessagesFrc.php. You cansearch the code for all uses.There is also a JSON file with fallbacks list from July 2025 inthis page.And you can also see visualisation graph (fromSeptember 2020) byRtnf:https://altilunium.github.io/MediaWiki-Language-Fallback/.
For found language fallback chain for current UI language you can usegetFallbackLanguageChain() method.
Viewing/getting the site content language
mw.config.get('wgContentLanguage');
| MediaWiki version: | ≥ 1.18 |
&uselang=zxx in the URL (seeuselang)&variant=xy (or$wgVariantArticlePath) in the URLif it is a variant of your user language| MediaWiki version: | ≥ 1.18 |
ContentLanguage.ContentLanguage by default.| MediaWiki version: | ≥ 1.24 |
ContentLanguage). Language of pages in the MediaWiki namespace can't be changed.$wgPageLanguageUseDB =true and thepagelang permission must be granted to a wiki user rights group (who can then perform page language changes).<divlang="xyz"dir="ltr/rtl"class="mw-content-ltr/rtl"></div> around the page text. The dir attribute sets the correctwriting direction. The lang attribute will always be the root code, e.g. "de" even when "de-formal" is given.<divlang="xyz"dir="ltr/rtl"class="mw-content-ltr/rtl"> tags can be used to mark text as being written in a different language. If the CSS class is used, the ul/ol lists and editsection will display nicely when the dir tag is opposite to the value of that of the page content language. Things defined in the parser, like TOC and magic words, however, will not change.mw.config.get( 'wgPageContentLanguage' ) - note that, when e.g. viewing the page history, it will return the page language of the page it is the history of, whereas the history page doesn't have an mw-content-ltr/rtl class. I.e. both "/wiki/Page" and "/w/index.php?title=Page&action=history" will return the language of "Page".1.19+action=info, linked in the toolbox)1.21+First, you have a Language object inLanguage.php.This object contains all the localisablemessage strings, as well as other important language-specific settings and custom behavior (uppercasing, lowercasing, printing dates, formatting numbers,direction,custom grammar rulesetc.).
The object is constructed from two sources: sub-classed versions of itself (classes) and Message files (messages).
There's also the MessageCache class, which handles input of text via the MediaWiki namespace.Most internationalisation is nowadays done viaManual:Messages API objects and by using thewfMessage() shortcut function, which is defined inincludes/GlobalFunctions.php.Legacy code might still be using the oldwfMsg*() functions, which are now considered deprecated in favor of the above-mentioned Message objects.
See alsoManual:Messages API.
There are two ways to get a language object.You can use the globals$wgLang andContentLanguage service (MediaWiki\MediaWikiServices::getContentLanguage) for user interface and content language respectively.For an arbitrary language you can construct an object by using$languageFactory->getLanguage('en') by replacingen with the code of the language.You can get$languageFactory, an object of theMediaWiki\Languages\LanguageFactory class, usingDependency Injection.You can also usewfGetLangObj($code); if$code could already be a language object.The list of codes is inincludes/languages/data/Names.php.
Language objects are needed for doing language-specific functions, most often to do number, time and date formatting, but also to construct lists and other things.There are multiple layers of caching and merging with#Fallback languages, but the details are irrelevant in normal use.
With MediaWiki 1.3.0, a new system was set up for localising MediaWiki.Instead of editing the language file and asking developers to apply the change, users could edit the interface strings directly from their wikis.This is the system in use as of August 2005.People can find the message they want to translate inSpecial:AllMessages and then edit the relevant string in theMediaWiki: namespace.Once edited, these changes are live.There was no more need to request an update, and wait for developers to check and update the file.
The system is great for Wikipedia projects; however a side effect is that the MediaWiki language files shipped with the software are no longer quite up-to-date, and it is harder for developers to keep the files on meta in sync with the real language files.
As the default language files do not provide enough translated material, we face two problems:
This is not such a big issue anymore, because translatewiki.net is advertised prominently and used by almost all translations.Local translations still do happen sometimes but they're strongly discouraged.Local messages mostly have to be deleted, moving the relevant translations to translatewiki.net and leaving on the wiki only the site-specific customisation; there's a huge backlog especially in older projects,this tool helps with cleanup.
English messages are very rarely out of sync with the code.Experience has shown that it's convenient to have all the English messages in the same place.Revising the English text can be done without reference to the code, just like translation can.Programmers sometimes make very poor choices for the default text.
So many things are localisable on MediaWiki that not all of them are directly available ontranslatewiki.net: seetranslatewiki:Translating:MediaWiki.If something requires adeveloper intervention on the code, you canrequest it on Phabricator, or ask attranslatewiki:Support if you don't know what to do exactly.
$datePreferences$dateFormats$defaultDateFormaticonv
$linkTrail. These are letters that can be glued after/before the closing/opening brackets of a wiki link, but appear rendered on the screen as if part of the link (that is, clickable and in the same colour),e.g.:[[foo]]bar. By default the link trail is "a-z"; you may want to add the accentuated or non-Latin letters used by your language to the list.cite_text-zyx for language codezyx.Neat functionality:
sprintfDateCurrently making namespace name translations is disabled on translatewiki.net, so you need to do this yourself in Gerrit, or file aPhabricator task asking for someone else to do it.[4]
To allow custom namespaces introduced by your extension to be translated, create aMyExtension.i18n.namespaces.php file that looks like this:
<?php/** * Translations of the namespaces introduced by MyExtension. * * @file */$namespaceNames=[];// For wikis where the MyExtension extension is not installed.if(!defined('NS_MYEXTENSION')){define('NS_MYEXTENSION',2510);}if(!defined('NS_MYEXTENSION_TALK')){define('NS_MYEXTENSION_TALK',2511);}/** English */$namespaceNames['en']=[NS_MYEXTENSION=>'MyNamespace',NS_MYEXTENSION_TALK=>'MyNamespace_talk',];/** Finnish (Suomi) */$namespaceNames['fi']=[NS_MYEXTENSION=>'Nimiavaruuteni',NS_MYEXTENSION_TALK=>'Keskustelu_nimiavaruudestani',];
Then load it from theextension.json file using ExtensionMessagesFiles like this:
{"name":"MyExtension","version":"0.0.1","descriptionmsg":"myextension-desc","ExtensionMessagesFiles":{"MyExtensionNamespaces":"MyExtension.i18n.namespaces.php"}}
Now, when a user installs MyExtension on their Finnish (fi) wiki, the custom namespace will be translated into Finnish magically, and the user doesn't need to do a thing!
Also remember to register your extension's namespace(s) on theExtension default namespaces page.
Seethe manual page for Special pages for up-to-date information.The following does not appear to be valid.
Create a new file for the special page aliases in this format:
<?php/** * Aliases for the MyExtension extension. * * @file * @ingroup Extensions */$aliases=[];/** English */$aliases['en']=['MyExtension'=>['MyExtension']];/** Finnish (Suomi) */$aliases['fi']=['MyExtension'=>['Lisäosani']];
Then load it from theextension.json file using ExtensionMessagesFiles like this:
{"name":"MyExtension","version":"0.0.1","descriptionmsg":"myextension-desc","ExtensionMessagesFiles":{"MyExtensionAlias":"MyExtension.i18n.alias.php"}}
When your special page code uses eitherSpecialPage::getTitleFor('MyExtension') or$this->getTitle() (in the class that provides Special:MyExtension), the localised alias will be used, if it's available.
Namespace name aliases are additional names which can be used to address existing namespaces.They are rarely needed, but not having them when they are, usually creates havoc in existing wikis.
You need namespace name aliases:
The generic English namespace names are always present as namespace name aliases in all localisations, so you need not, and should not, add those.
Aliases can't be translated onTranslatewiki.net, but can be requested there or onBugzilla: seetranslatewiki:Translating:MediaWiki#Namespace name aliases.
Some linguistic settings vary across geographies; MediaWiki doesn't have a concept of region, it only has languages and language variants.
These settings need to be set once as a language's default, then individual wikis can change them as they wish in their configuration.
Time and dates are shown on special pages and alike.The default time and date format is used for signatures, so it should be the most used and most widely understood format for users of that language.Also anonymous users see the default format.Registered users can choose other formats in their preferences.
If you are familiar with PHP's time() format, you can try to construct formats yourself.MediaWiki uses a similar format string, with some extra features.If you don't understand the previous sentence, that's OK.You can provide a list of examples forDevelopers.
SeeHelp:System message#Message sources.
language/classes/LanguageXx.php orlanguage/messages/MessagesXx.php files.{{#language:<code>}} documented inmagic words