Manuál:Jazyková nastavení

Jump to navigation Jump to search
This page is a translated version of the page Manual:Language and the translation is 32% complete.
Outdated translations are marked like this.
Other languages:
Bahasa Indonesia • ‎Deutsch • ‎English • ‎català • ‎dansk • ‎español • ‎français • ‎polski • ‎português • ‎português do Brasil • ‎svenska • ‎čeština • ‎русский • ‎تۆرکجه • ‎فارسی • ‎پښتو • ‎中文 • ‎日本語 • ‎한국어
i18n docs
Vizte také Manual:MediaWiki architecture#Languages (sloučit sem?)

V rámci MediaWiki rozlišujeme různá pojetí jazyků:

  • Jazyk uživatelského rozhraní ($contextSource->getLanguage() dříve $wgLang ), který lze nastavit v Nastavení, nebo použitím kódu &uselang=xyz v URL. Ve standardních případech zůstává během používání jedné wiki taktéž neměnný.
  • Jazyk obsahu stránky se může u každé stránky lišit, i když základní jazyk stránek a uživatelského rozhraní budou totožné. Je definován v getPageLanguage() v hlavičce a značí, v jakém jazyce je zdrojový wikitext psán.
    • Jazyk zobrazení stránky, neboli uživetelem nastavený jazyk je jazyková varianta jazyka stránky, kterou si uživatel zvolil. Lze ji nastavit pomocí &variant (nebo $wgVariantArticlePath ) v URL (např. zvolením některé ze záložek) pokud se jedná o variantu jazyka obsahu prohlížené stránky. Je definován v getPageViewLanguage() v hlavičce a značí, v jakém jazyce je vykreslený HTML obsah psán.

Všechny tři výše zmíněné chápeme jako jazykové objekty.

Kód jazyka

Not to be confused with Wikimedia project code; see also Language codes on Meta

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 with ISO 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 العربية.

Uniformity with Unicode standard is needed to provide a good language support, in particular in cooperation with CLDR; having an ISO 639-3 code is one requirement for a language to be added to MediaWiki locales.


Names.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 (via CLDR ), mind you!

Fallback languages

Fallback chains (Some of the lines shown are inaccurate due to double languages in the fallback. Check if the connection actually exists in the text version)

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 code frc (Cajun French), which falls back on the language code fr (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 associated languages/messages/MessagesXX.php file. For instance MessagesFrc.php. You can search the code for all uses. There is also a plain list from 2020-09 in this phabricator comment.

Výchozí jazyk webu

Viewing/getting the site content language

JavaScript :

mw.config.get( 'wgContentLanguage' );

Jazyk uživatelského rozhraní

MediaWiki version:
Set via
  • Special:Preferences
  • &uselang=zxx in the URL (see uselang)
Since interface messages can come from fallback languages but the language is not returned, the actual language of each message is not known.

Jazyk stránky

MediaWiki version:
Výchozí hodnota
  • $wgLang u speciálních stránek.
  • Angličtina pro stránky, které obsahují CSS a JS kódy.
  • For MediaWiki namespace pages, the language depends on the subpage. For example, MediaWiki:Message/ar will be set to Arabic (ar), and MediaWiki:Message will be $wgContLang.
  • All other pages are $wgContLang by default.
Extensions can change all other pages through the PageContentLanguage hook.

The value for special pages, CSS, JS, and MediaWiki namespace pages cannot be overridden.

The Translate extension uses it for the page translation feature. See translatewiki:Project:About/ar as a translation of translatewiki:Project:About. The directionality of the page is thus correctly set to right-to-left for Arabic.
MediaWiki version:
Manually changing page language
Page language selection is now achievable with help of Special:PageLanguage since MediaWiki 1.24.
Users can change content language of a page which is by default the default Wiki language($wgContLang). Language of pages in the MediaWiki namespace can't be changed.
The feature needs to be enabled with $wgPageLanguageUseDB = true and the pagelang permission must be granted to a wiki user rights group (who can then perform page language changes).
Changing page language causes the source translation page and its units to be moved to the correct target language. In case the target language translation page already exists, the language change isn't allowed.
Matching API can be found on API:SetPageLanguage.
What does it define?
  • In SkinTemplate, it adds a <div lang="xyz" dir="ltr/rtl" class="mw-content-ltr/rtl"></div> around the page text. The dir attribute sets the correct writing direction. The lang attribute will always be the root code, e.g. "de" even when "de-formal" is given.
  • For file pages, it is set in ImagePage.php, because there is a lot of HTML that is in the user language.
  • In Parser.php, it sets the table of contents (TOC) numberings, and stuff like grammar, although not really relevant mostly. To do that only, use parserOptions->setTargetLanguage().
  • The direction of the diff text (DifferenceEngine) is set to the page content language. In some cases this is not identical, in which case $diffEngineObject->setTextLanguage( $code ) can be used.
  • Since 1.19, it also sets the time and number-formatting magic words, including DIRECTIONMARK, but not NAMESPACE(E), as that really depends on the site language. Note that including a template marked as language A onto a page with language B, will be parsed with language B on that page.
Multiple languages on a single page
Multiple languages on a single page are in theory not supported, but simple <div lang="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.
Viewing/getting the page language
  • JavaScript: 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".


  • The page content language is mentioned on the page info view (action=info, linked in the toolbox)




  1. See languages/data/Names.php.
  2. Despite this, as of 2012 language codes validation is not yet a solved problem. See Niklas Laxström, Language validation in MediaWiki, August 28th, 2012.

Viz též

  • Obtaining language names from codes is possible using the core function {{#language:<code>}} documented in magic words