Manual:Language/zh


 * 另可参见手册:MediaWiki架构#语言（是否应合并至此？）

在MediaWiki中，有各种语言：


 * 网站内容语言（ ，基于 ），只要维基存在，通常应保持不变.
 * 网站内容语言变体（Manual:$wgDefaultLanguageVariant）是为该语言实现LanguageConverter时的默认变体.
 * 用户界面语言（$contextSource->getLanguage以前是 ），可以在您的首选项中更改或使用 在URL中，但在使用wiki时通常也保持不变.
 * 页面内容语言. 即使站点和用户语言相同，每个页面也可能不同. 它在Title中的getPageLanguage中定义，表示wiki文本源的编写语言.
 * 页面查看语言又名用户语言变体，它是页面内容语言的语言变体，由用户首选. 它也可以通过URL中的 （或）进行设置（例如，通过选择其中一个选项卡），如果它是页面的内容语言的变体查看. 它在标题中的getPageViewLanguage中定义，表示呈现的HTML内容的语言.

所有这三个都是语言对象.

语言代码

 * 不要与维基媒体项目代码混淆，另请参阅元维基上的语言代码

语言代码是MediaWiki支持的语言的有效标准缩写， 使用此类代码作为语言的标准标识符（大多数符合ISO 639-3，除了ISO 639-1的“已建立”区域设置的双字母代码）并公开或要求它们接口和代码的许多要点.

在下面的示例中， ， 是的语言代码.

需要使用Unicode标准的一致性来提供良好的语言支持，特别是与CLDR合作，拥有ISO 639-3代码的是要求添加到MediaWiki语言环境的语言.

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!

备选语言
MediaWiki中的某些语言具有所谓的“后备序列”. 如果MediaWiki无法找到所需的语言，那么这将是另一种语言. 这方面的一个例子是语言代码 （Cajun French），它依赖于语言代码 （法语）. 这样做的原因是有时语言中没有定义所有消息.

语言的后备可以在其关联的 文件中找到.

用户界面语言

 * 默认值
 * $contextSource->getLanguage


 * 设置通过


 * Special:Preferences
 * 在URL（见uselang）
 * （或）在网址如果它是您的用户语言的变体


 * 问题
 * 由于接口消息可能来自后备语言，但未返回语言，因此不知道每条消息的实际语言.

页面内容语言

 * 默认值


 * $wgLang在特殊页面上.
 * English for CSS and JS pages.
 * 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.


 * Configuration
 * Extensions can change all other pages through the PageContentLanguage hook. The value for special pages, CSS, JS, and MediaWiki namespace pages cannot be overridden.


 * Examples
 * The Translate extension uses it for the page translation feature. See translatewiki:Project list/ar as a translation of translatewiki:Project list. The directionality of the page is thus correctly set to right-to-left for Arabic.


 * 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  and permission needs to be set for.
 * 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  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, 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  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:  - 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 (, linked in the toolbox)
 * The page content language can be retrieved in the API via api.php?action=query&prop=info

参见

 * 多语言MediaWiki
 * Obtaining language names from codes is possible using the core function documented in magic words