Help:Magic words/zh

魔术字是MediaWiki软件所识别的特定字符串，它们可以返回特定的值或触发其他的功能：比如时间、站点设置或是页面名称等等. 本页所描述的均是标准魔术字的用法；开发人员请参考.

魔术字有三种类型：


 * 状态开关：以两个下划线“__”为前后缀的大写单词，例如__FOO__.


 * 变量：字符被两个大括号括起来，所有字母大写，例如 . 用法与模板类似.


 * 解析器函数：一些形如或的魔术字，在使用时包含参数，且大小写不敏感. 另可参见.

变量和解析器函数可以像模板一样使用subst:. 无论这个魔术字是通过被引用的模板添加的或者被包含的系统信息中添加的，依赖页面的魔术字均将（默认）起作用或者返回当前页面的数据.

行为开关
状态开关可以控制页面的显示方式或其他行为. 它往往用于排除或加入特定的页面内容.

变量
变量可以返回关于当前页面、wiki站点或日期的信息. 变量的语法与模板类似. 其中标记为“ [高开销] ”的变量会被软件记录，且在一个页面中可使用的总数会被限制.

If a template name conflicts with a variable, the variable will be used (so to transclude the template    :PAGENAME you would need to write  ). In some cases, adding parameters will force the parser to invoke a template; for example,  transcludes     :CURRENTDAYNAME, not the variable.

日期和时间
以下的变量返回当前的日期和时间，遵照用户的时区选项，默认为UTC时间.

在MediaWiki与浏览器缓存的影响下，这些变量显示的往往是被缓存的值，而非当前的时间.

日期和时间魔术字被格式化为相应的语种. 自版本开始，她们取决于，页面内容语言.

如下变量和上列变量功能相同，但是使用的是所在服务器的时间或者$wgLocaltimezone.

“更详尽的时间格式，您可以在安装后，使用#time parser function”

技术元数据
注：历史版本变量返回的是与当前页面最近一次编辑有关的数据，即是当时您查看的是更旧版本的页面.

统计
这些变量返回的数字往往包含分隔符（根据本地语言参数设置而可能是逗号或空格）. 可以通过“:R”来返回无分隔号的数字（例如 &rarr;  and   &rarr; ）.

对于PAGESINCATEGORY等需要参数的变量则使用“|R”（例如 和 及 和 ）. 并且也适用于前述.

The number magic words are formatted in the wiki content language. Since, it depends on the page content language.

页面名称
The  and   magic words only work in namespaces that have subpages enabled. See for information on enabling subpages.

As of, these can all take a parameter, allowing specification of the page to be operated on, instead of just the current page:
 * &rarr; 

For example, if page name is "L'Aquila", the following code will produce the string "Numeric char encoding":

URL encoded page names
The following are equivalents encoded for use in MediaWiki URLs (i.e. spaces replaced with underscores and some characters HTML escaped using numeric character encoding):



Note that,   and   have distinct implementations. See Manual:PAGENAMEE encoding for details.

名字空间
The following are equivalents encoded for use in MediaWiki URLs (spaces replaced with underscores and some characters percent-encoded):



As of, these can take a full-page-name parameter and will return the requested namespace associated with that page, instead of with the current page:

Parameter must not be a namespace name:
 * &rarr; 
 * &rarr; 
 * &rarr; 
 * &rarr;   (Empty)

解析器函数
Parser functions are very similar to variables, but take one or more parameters (technically, any magic word that takes a parameter is a parser function), and the name is sometimes prefixed with a hash to distinguish them from templates.

This page only describes parser functions that are integral to the MediaWiki software. Other parser functions may be added by MediaWiki extensions such as the. For those see.

名字空间
returns the current localized name for the namespace with that index, canonical name, or local alias. Thus,  , and   (an old name for the File namespace) all return "    ". On a wiki where the content language is French,  is also valid, but   (the localisation of "File" in German) is not.

is the equivalent encoded for MediaWiki URLs. It does the same, but it replaces spaces with underscores, making it usable in external links.

Don't confuse localised namespaces with custom namespaces.

格式化
See also:.

本地化
Here are the magic words which are used as main localisation tools. Other magic words will often depend on the wiki's locale and configuration or on the chosen language: see in particular #Date and time, #Formatting, #Miscellaneous. More magic words are added by the.

The usage of these magic words can be very complex, and the documentation is currently incomplete; there's some more info on PLURAL, GRAMMAR, GENDER.

Transclusion modifiers
usually transcludes another page, by default from the Template:namespace. These magic words modify that behavior.