Help:Zh/Templates: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with "{{langsp}} {{Translate|type=inprogress}} {{Cleanup}} '''模板'''是一个创建用于包含在其他页面中的维基页面。模板通常包含可能需要在大量文章...")
 
(finished Simplified Chinese translations)
Line 1: Line 1:
{{langsp}} {{Translate|type=inprogress}} {{Cleanup}}
{{langsp}}
{{:User:1416006136/Signature|time=May 11 2024}}
{{Cleanup}}
'''模板'''是一个创建用于包含在其他页面中的维基页面。模板通常包含可能需要在大量文章或页面上显示的重复性材料。它们通常用于样板消息、标准化警告或通知、信息框、导航框以及类似目的。
'''模板'''是一个创建用于包含在其他页面中的维基页面。模板通常包含可能需要在大量文章或页面上显示的重复性材料。它们通常用于样板消息、标准化警告或通知、信息框、导航框以及类似目的。


Line 50: Line 52:


==制作模板==
==制作模板==
在模板可以被添加到某处之前,首先必须在其自己的页面上定义其内容。模板页面以前缀`Template:`开始。另见:[[Help:Page Creation]]。
在模板可以添加到某处之前,首先必须在其自己的页面上定义其内容。模板页面以前缀<code>Template:</code>开头。另请参阅:[[Help:Page Creation]]。


制作像[[Template:Restart]]这样的模板相当容易:在右上角的搜索栏中输入`Template:Restart`,点击它的红色链接(假设页面还不存在),输入您想要的文本,并保存它。之后,就可以按照上述描述使用这个新模板了。
制作像[[Template:Restart]]这样的模板相当容易:在右上角的搜索栏中输入<tt>Template:Restart</tt>,单击其红色链接(假设页面尚不存在),输入您想要的文本,然后保存。之后,这个新模板就可以像上面描述的那样使用了。
{{tip|制作模板时,您可能想要分隔您的代码以使其更易于阅读,但要注意无意中的空白,特别是换行符。HTML注释(`<!-- -->`)也可能有用。}}
{{tip|在制作模板时,您可能希望将代码分开以使其更易于阅读,但要注意不要意外添加空白,尤其是换行符。HTML注释(<code><nowiki><!-- --></nowiki></code>)也可能会有用。}}
{{note|命名参数(例如{{Param|title}})在模板结果中会被修剪前导和尾随空白,未命名参数(例如{{Param}})则不会。}}
{{note|命名参数(例如{{Param|title}})在模板结果中将删除前导和尾随空白,未命名参数(例如{{Param}})则不会。}}


===未命名参数===
===未命名参数===
要添加未命名参数,只需将{{Param}}放在您希望第一个未命名参数的值出现的地方。
要添加未命名参数,只需在想要第一个未命名参数值的位置放置{{Param}}
这是[[Template:Tip]]的代码的一部分:
这是[[Template:Tip]]代码的一部分:
:`Tip:{{Param}}`
:<code>提示:{{Param}}</code>
如果您之前见过这个模板,您就会知道它有自己特殊的外观,但现在我们只看这个。用户在转录时所要做的就是输入他们想要的文本:
如果您以前见过这个模板,就会知道它有自己特殊的外观,但目前我们只看这些内容。当传递此内容时,用户只需输入他们想要的文本:
:{|
:{|
| {{tlc|tip|之后不要进行顶点编辑。}}
| {{tlc|tip|不要在之后没有顶点编辑的情况下进行雕刻。}}
|-
|-
| ↓
| ↓
|-
|-
| {{tip|之后不要进行顶点编辑。}}
| {{tip|不要在之后没有顶点编辑的情况下进行雕刻。}}
|}
|}
如果您想添加多个未命名参数,只需更改数字即可。这是[[Template:Distinguish]]的旧(压缩)代码。这个模板有一些我们还没有讨论的内容,但您仍然可以看到使用了四个未命名参数:{{Param}}、{{Param|2}}、{{Param|3}}和{{Param|4}}。
如果要添加多个未命名参数,只需更改数字。这是[[Template:Distinguish]]的旧(压缩的)代码。此模板有一些我们尚未讨论的内容,但您仍然可以看到有四个未命名参数被使用:{{Param}}、{{Param|2}}、{{Param|3}} 和 {{Param|4}}。
<pre style="background-color:#444;border-color:#666;color:#ddd">''不要与[[:{{{1}}}]]混淆{{#if:{{{2|}}} |{{#if:{{{3|}}} |,[[:{{{2}}}]]|或[[:{{{2}}}]]。}}|}}{{#if:{{{3|}}} |{{#if:{{{4|}}} |,[[:{{{3}}}]]|[[:{{{3}}}]]。}}}}{{#if:{{{4|}}} |[[:{{{4}}}]]。}}''</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">:''请勿与[[:{{{1}}}]]混淆{{#if:{{{2|}}} |{{#if:{{{3|}}} |,[[:{{{2}}}]]| 或 [[:{{{2}}}]]。}}。{{#if:{{{3|}}} |{{#if:{{{4|}}} |,[[:{{{3}}}]]|,或 [[:{{{3}}}]]。}}{{#if:{{{4|}}} |,或 [[:{{{4}}}]]。}}''</pre>


用户在转录时所要做的就是这样:
当传递内容时,用户只需这样做:
:{|
:{|
| {{tlc|distinguish|Combine|Civil Protection|Overwatch}}
| {{tlc|distinguish|Combine|Civil Protection|Overwatch}}
Line 81: Line 83:


===命名参数===
===命名参数===
通常,您会希望命名参数只在转录时定义时才影响任何内容。我们稍后会讨论条件。现在,让我们看看[[Template:IO]],它有许多命名参数。在这个模板中,{{Param|param}}标记了一个添加转录时由`|param=texthere`定义的维基文本的位置。
通常,您希望只有在传递时定义了命名参数时才会影响任何内容。我们将在后面讨论条件。现在,让我们看一下[[Template:IO]],它有许多命名参数。在此模板中,{{Param|param}}标记了在传递时由<code>|param=texthere</code>定义的wikitext的位置。


带命名参数:
使用命名参数:
:{|
:{|
| {{tlc|IO|SetString|更新字符串。|param{{=}}string}}
| {{tlc|IO|SetString|更新字符串。|param{{=}}string}}
Line 92: Line 94:
|}
|}


不带命名参数:
不使用命名参数:
:{|
:{|
| {{tlc|IO|SetString|更新字符串。}}
| {{tlc|IO|SetString|更新字符串。}}
Line 102: Line 104:


===默认值===
===默认值===
要使参数默认具有值,请在参数名称的右侧添加`|`,然后定义默认值。命名和未命名参数都可以使用此功能。
要使参数默认具有值,请在参数名称右侧添加<code>|</code>,然后定义默认值。命名参数和未命名参数都可以使用这个功能。


如果用户没有指定,这将使{{Param}}的值默认为3000。
如果用户不指定,这会将{{Param}}的值设为3000。
{{CodeBlock|{{Param||3000}}}}
{{CodeBlock|{{Param||3000}}}}




如果用户没有指定`|value=...`,这将返回空字符串。注意{{param|value}}和{{param|value|}}之间的区别。前者如果用户没有定义,实际上会返回文本`{{{value}}}`
如果用户没有指定<code>|value=...</code>,则返回空字符串。请注意{{param|value}}和{{param|value|}}之间的区别。前者如果用户不定义它,将直接返回文本<code>{{{value}}}</code>
{{CodeBlock|{{Param|value|}}}}
{{CodeBlock|{{Param|value|}}}}


{{Note|为参数指定默认值仅适用于该参数的特定出现。如果您有多个出现的{{Param}},并且所有这些都应该有默认值`0`,那么您必须为所有这些键入{{param||0}}。另一方面,如果合适,这允许您在不同的出现中使用不同的默认值。}}
{{Note|为参数指定默认值仅适用于该参数的特定出现。如果有多个{{Param}}的出现,所有这些都应该具有默认值<tt>0</tt>,则必须为所有这些输入{{param||0}}。另一方面,如果合适的话,这也允许您在不同的出现中使用不同的默认值。}}


===解析函数===
===解析器函数===
为了使文本仅在定义了某个参数或将其设置为特定值时才(不)显示,以下表达式是实现此目的的方法。
要使文本(不)在仅在某个参数被定义或设置为特定值时出现,以下表达式是适用的。


解析函数`#if:`用于检查字符串是否为空。语法是`{{#if: <字符串> | <> | <> }}`。当`<字符串>`**不是**空字符串时,此表达式的结果为`<>`,否则为`<>`。可以省略`<>`值,在这种情况下,默认为空字符串;以下的`<>`也适用此规则。
解析器函数<code>#if:</code>检查字符串是否为空。语法是<code><nowiki>{{#if: <string> | <then> | <else> }}</nowiki></code>。如果<code><string></code>不是空字符串,则此表达式评估为<code><then></code>,否则为<code><else></code>。如果不指定<code><else></code>值,则默认为空字符串;以下<code><else></code>同样适用。
:`{{#if: &nbsp; | 非空 | 空 }}` &rarr; {{#if:  | 非空 | 空 }}
:<code><nowiki>{{#if: &nbsp; | 非空 | 空 }}</nowiki></code> &rarr; {{#if:  | 非空 | 空 }}
:`{{#if: X      | 非空 | 空 }}` &rarr; {{#if: X | 非空 | 空 }}
:<code><nowiki>{{#if: X      | 非空 | 空 }}</nowiki></code> &rarr; {{#if: X | 非空 | 空 }}
:`{{#if: &nbsp; | 非空 }}` &rarr; {{#if:  | 非空 }}
:<code><nowiki>{{#if: &nbsp; | 非空 }}</nowiki></code> &rarr; {{#if:  | 非空 }}
:`{{#if: X      | 非空 }}` &rarr; {{#if: X | 非空 }}
:<code><nowiki>{{#if: X      | 非空 }}</nowiki></code> &rarr; {{#if: X | 非空 }}
:`{{#if: {{{target|}}} | 目标获取 | 激活睡眠模式... }}` &rarr; {{#if: {{{target|}}} | 目标获取 | 激活睡眠模式... }}
:<code><nowiki>{{#if: {{{target|}}} | 已获取目标 | 休眠模式已激活... }}</nowiki></code> &rarr; {{#if: {{{target|}}} | 已获取目标 | 休眠模式已激活... }}
:`{{#if: 有东西在那里! | 目标获取 | 激活睡眠模式... }}` &rarr; {{#if: 有东西在那里! | 目标获取 | 激活睡眠模式... }}
:<code><nowiki>{{#if: 文字存在! | 已获取目标 | 休眠模式已激活... }}</nowiki></code> &rarr; {{#if: 文字存在! | 已获取目标 | 休眠模式已激活... }}
{{note|''表达式`{{{target|}}}`返回空字符串,因为您(可能)没有通过转录查看此页面,所以它从未有机会被定义,因此返回其默认值为空字符串。''}}
{{note|''表达式<code><nowiki>{{{target|}}}</nowiki></code>返回空字符串,因为您(可能)没有通过转录查看此页面,因此它从未有过定义的机会,因此返回其默认值为空字符串。''}}


`#ifeq:`用于检查两个字符串是否相等。语法是`{{#ifeq: <字符串1> | <字符串2> | <> | <> }}`。当两个(修剪后的)字符串完全相等时,此表达式的结果为`<>`,否则为`<>`
<code>#ifeq:</code>检查两个字符串是否相等。语法是<code><nowiki>{{#ifeq: <string1> | <string2> | <then> | <else> }}</nowiki></code>。如果两个(修剪后的)字符串完全相等,则评估为<code><then></code>,否则为<code><else></code>。
:`{{#ifeq: X | X | 相等 | 不相等 }}` &rarr; {{#ifeq: X | X | 相等 | 不相等 }}
:<code><nowiki>{{#ifeq: X | X | 相等 | 不相等 }}</nowiki></code> &rarr; {{#ifeq: X | X | 相等 | 不相等 }}
:`{{#ifeq: X | Y | 相等 | 不相等 }}` &rarr; {{#ifeq: X | Y | 相等 | 不相等 }}
:<code><nowiki>{{#ifeq: X | Y | 相等 | 不相等 }}</nowiki></code> &rarr; {{#ifeq: X | Y | 相等 | 不相等 }}
:`{{#ifeq: {{{target|}}} | 朋友 | 朋友... | 走开! }}` &rarr; {{#ifeq: {{{target|}}} | 朋友 | 朋友... | 走开! }}
:<code><nowiki>{{#ifeq: {{{target|}}} | friend | 朋友... | 走开! }}</nowiki></code> &rarr; {{#ifeq: {{{target|}}} | friend | 朋友... | 走开! }}
:`{{#ifeq: 朋友 | 朋友 | 朋友... | 走开! }}` &rarr; {{#ifeq: 朋友 | 朋友 | 朋友... | 走开! }}
:<code><nowiki>{{#ifeq: friend | friend | 朋友... | 走开! }}</nowiki></code> &rarr; {{#ifeq: friend | friend | 朋友... | 走开! }}


`#switch:`用于检查输入字符串与**多个**字符串是否相等。语法是
<code>#switch:</code>检查输入字符串与''多个''字符串之间的等式。语法是
`{{#switch: <输入> | <字符串1> = <值1> | <字符串2> = <值2> | ... | #default = <默认> }}`
<code><nowiki>{{#switch: <input> | <string1> = <value1> | <string2> = <value2> | ... | #default = <default> }}</nowiki></code>
此语句的结果为第一个与`<输入>`相等的`<字符串X>`对应的`<值X>`。如果该`<字符串X>`后面没有等号,即没有`<值X>`,则使用下一个有等号的`<字符串Y>``<值Y>`。如果没有找到相等的字符串,则返回`<默认>`,如果未指定,默认为空字符串。
此语句将评估为第一个<code><stringX></code>等于<code><input></code>的相应<code><valueX></code>。如果<code><stringX></code>没有跟随等号,因此没有<code><valueX></code>,则使用下一个具有等号的<code><stringY></code>的<code><valueY></code>。如果找不到等式,则返回<code><default></code>,如果未指定,则默认为空字符串。


`#expr:`用于解决数学问题。有关其所有功能,请参见[[m:Help:Calculation|帮助:计算]]。如果发生错误,将返回一个包含在`{{code|1=&lt;strong class="error">}}`元素中的字符串。
<code>#expr:</code>解决数学问题。请参阅[[m:Help:Calculation|Help:Calculation]]以获取其所有功能。如果发生错误,则返回{{code|1=&lt;strong class="error">}}元素中的字符串。
:`{{#expr: 2 + 2}}` &rarr; {{#expr: 2 + 2}}
:<code><nowiki>{{#expr: 2 + 2}}</nowiki></code> &rarr; {{#expr: 2 + 2}}
:`{{#expr: cos(pi/3)^2}}` &rarr; {{#expr: cos(pi/3)^2}}
:<code><nowiki>{{#expr: cos(pi/3)^2}}</nowiki></code> &rarr; {{#expr: cos(pi/3)^2}}
:`{{#expr: 0 and 1 or 1}}` &rarr; {{#expr: 0 and 1 or 1}}
:<code><nowiki>{{#expr: 0 and 1 or 1}}</nowiki></code> &rarr; {{#expr: 0 and 1 or 1}}
:`{{#expr: 1 + }}` &rarr; {{#expr: 1 + }}
:<code><nowiki>{{#expr: 1 + }}</nowiki></code> &rarr; {{#expr: 1 + }}
:`{{#ifeq: {{#expr: 1 + }} | 1 | 真 | 假}}` &rarr; {{#ifeq: {{#expr: 1 + }} | 1 | 真 | 假}}
:<code><nowiki>{{#ifeq: {{#expr: 1 + }} | 1 | 真 | 假}}</nowiki></code> &rarr; {{#ifeq: {{#expr: 1 + }} | 1 | 真 | 假}}


`#ifexpr:`用于测试数学表达式是真还是假,并根据结果返回不同的值。
<code>#ifexpr:</code>测试数学表达式是真还是假,并根据其返回不同的值。
:`{{#ifexpr: 6 + 3 = &nbsp;9 | 正确 | 错误 }}` &rarr; {{#ifexpr: 6 + 3 =  9 | 正确 | 错误 }}
:<code><nowiki>{{#ifexpr: 6 + 3 = &nbsp;9 | 正确 | 错误 }}</nowiki></code> &rarr; {{#ifexpr: 6 + 3 =  9 | 正确 | 错误 }}
:`{{#ifexpr: 6 + 3 = 63      | 正确 | 错误 }}` &rarr; {{#ifexpr: 6 + 3 = 63 | 正确 | 错误 }}
:<code><nowiki>{{#ifexpr: 6 + 3 = 63      | 正确 | 错误 }}</nowiki></code> &rarr; {{#ifexpr: 6 + 3 = 63 | 正确 | 错误 }}
{{Warning|offset=1|在将参数传递给表达式时,注意如果参数为空则不会出错。例如,如果一个整数参数如果留空应该像0一样处理,请添加小数点,因为`{{code|.}}`与`{{code|0.}}`转换为相同的零。<br>
{{Warning|offset=1|将参数传递给表达式时,要注意如果参数为空会导致错误。例如,如果整数参数在被留空时应该像0一样行为,则添加一个小数点,因为{{code|.}}会被转换为与{{code|0.}}
例如,使用`{{code|{{param|hl2|0}}.}}`而不是`{{code|{{param|hl2|0}}}}`,因为后者可能会失败,如果指定了`{{code|1=hl2=}}`:
 
:`{{#ifexpr: 1 or .      | 真 | 假}}` &rarr; {{#ifexpr: 1 or . | 真 | 假}}
同的零。<br>
:`{{#ifexpr: 1 or &nbsp; | 真 | 假}}` &rarr; {{#ifexpr: 1 or  | 真 | 假}}
例如,使用{{code|{{param|hl2|0}}.}}而不是{{code|{{param|hl2|0}}}},因为如果指定了{{code|1=hl2=}},后者可能会失败:
:<code><nowiki>{{#ifexpr: 1 or .      | 真 | 假}}</nowiki></code> &rarr; {{#ifexpr: 1 or . | 真 | 假}}
:<code><nowiki>{{#ifexpr: 1 or &nbsp; | 真 | 假}}</nowiki></code> &rarr; {{#ifexpr: 1 or  | 真 | 假}}
}}
}}


`lc:``uc:`将字符串转换为小写或大写。请注意,这些与`#if:`等不同,没有井号。
<code>lc:</code><code>uc:</code>将字符串转换为小写或大写。请注意,与<code>#if:</code>等不同,这些没有哈希标记。
还有`lcfirst:``ucfirst:`,它们只操作表达式的第一个字符。
还有<code>lcfirst:</code><code>ucfirst:</code>,它们仅操作表达式的第一个字符。
:`{{tlc|lc:Case Sensitivity}}` &rarr; {{lc:Case Sensitivity}}
:{{tlc|lc:Case Sensitivity}} &rarr; {{lc:Case Sensitivity}}
:`{{tlc|uc:Case Sensitivity}}` &rarr; {{uc:Case Sensitivity}}
:{{tlc|uc:Case Sensitivity}} &rarr; {{uc:Case Sensitivity}}
:`{{tlc|lcfirst:Case Sensitivity}}` &rarr; {{lcfirst:Case Sensitivity}}
:{{tlc|lcfirst:Case Sensitivity}} &rarr; {{lcfirst:Case Sensitivity}}


{{Seealso|[[mw:Help:Extension:ParserFunctions|帮助:扩展:解析函数]]}}
{{Seealso|[[mw:Help:Extension:ParserFunctions|Help:Extension:ParserFunctions]]}}


===文档===
===文档===
请描述您的模板的功能,尤其是示例。为了防止描述文本出现在使用模板的页面上,或使模板页面本身看起来更清洁,您可以使用三种不同的HTML标签。
请描述您的模板所做的事情,特别是提供示例。为了使页面上不使用模板的描述文本,或使模板页面本身看起来更整洁,您可以使用三种不同的HTML标签。
* `<noinclude>...</noinclude>`防止维基文本被转录到其他页面。它只会显示在模板的页面上。
* <code>&lt;noinclude>...&lt;/noinclude></code> 防止wikitext被传递到其他页面。它仅会显示在模板的页面上。
* `<onlyinclude>...</onlyinclude>`使得只有其中的维基文本出现在目标页面上。其他所有内容都不会被转录,但仍会显示在模板的页面上。
* <code>&lt;onlyinclude>...&lt;/onlyinclude></code> 使其中的wikitext仅出现在目标页面上。其他所有内容都不会被传递,但仍将出现在模板的页面上。
* `<includeonly>...</includeonly>`防止其中的维基文本出现在模板的页面上。它对目标页面没有影响。
* <code>&lt;includeonly>...&lt;/includeonly></code> 防止其中的wikitext出现在模板的页面上。它不会对目标页面产生影响。


因此,您可以用`<onlyinclude>`包围所有应该被转录的内容,或者用`<noinclude>`包围其他所有内容。此外,您可以使用`<includeonly>`来隐藏模板页面上的模板文本。
因此,您可以使用<code>&lt;onlyinclude></code>将应该传递的所有内容包围起来,或者将其他所有内容都包围在<code>&lt;noinclude></code>中。此外,您可以使用<code>&lt;includeonly></code>在模板页面上隐藏模板文本。
这些标签一开始听起来可能非常令人困惑。如果您对如何使用它们感到困惑,请检查模板的源代码,因为几乎所有模板都出于某种目的使用它们。
这些标签起初可能听起来很令人困惑。如果您不确定如何使用它们,请检查模板的源代码,因为几乎所有模板都以某种方式使用它们。


如果文档不能保持简短,那么将所有解释和/或示例移动到自己的页面是一个好主意。按照惯例,模板的文档页面应该是其子页面`/doc`。例如,[[Template:Note]]有其文档页面[[Template:Note/doc]]。创建后,文档使用表达式{{tl2|doc}}被转录到模板页面,当然必须使用上述标签排除。
如果文档不能保持简短,那么将所有解释和/或示例移至单独的页面是一个好主意。按照惯例,模板的文档页面应为其子页面<code>/doc</code>。例如,[[Template:Note]]有其文档页面[[Template:Note/doc]]。创建后,文档将使用表达式{{tl2|doc}}传递到模板页面,当然,必须使用上述标签排除它。
 
有时,模板的使用方式完全相同。正如您可能知道的,[[Template:Tip]]和Template:Note都以完全相同的方式使用它们的一个参数,因此没有必要为Tip再创建一个具有相同文档的页面。Tip可以使用与Note相同的文档,使用表达式{{tlc|documentation|Template:Note/doc}};这背后唯一的魔法是Template:Note/doc使用表达式{{tlc|ROOTPAGENAME}}而不是`Note`来进行示例,以便示例适应它们显示的页面。如果Template:Note/doc不是为此而制作的,这将不会奏效。
其他正在使用的类似“通用文档”包括[[Template:Hl2]]和[[Template:Yes]]。


有时,模板的使用方式是相同的。您可能知道,[[Template:Tip]]和[[Template:Note]]都以完全相同的方式使用其一个参数,因此无需另一个具有相同文档的页面来描述Tip。Tip可以使用与Note相同的文档,使用表达式{{tlc|documentation|Template:Note/doc}};这背后的唯一魔法是Template:Note/doc使用表达式{{tlc|ROOTPAGENAME}}而不是<code>Note</code>用于其示例,以便示例适应其显示的页面。如果Template:Note/doc不是为此而制作的,那么这将行不通。
其他像这样使用的“通用文档”包括[[Template:Hl2]]和[[Template:Yes]]。


===模板未更新===
===模板未更新===
如果您最近编辑了一个模板,但更改没有应用到已转录该模板的页面上,请在这些页面的URL末尾添加`?action=purge`。这将指示服务器立即更新页面的HTML。您也可以通过编辑页面并在不做任何更改的情况下保存它来达到相同的效果。
如果您最近编辑了一个模板,但更改未应用到已经转录到的页面上,请在这些页面的URL末尾添加<code>?action=purge</code>。这将告诉服务器立即更新页面的HTML。您也可以通过编辑页面并保存而不进行任何更改来实现相同的效果。
如果您在带有文档的模板页面上,您也可以使用“[purge]”按钮达到相同的效果。
如果您在具有文档的模板页面上,您还可以使用相同效果的“[刷新]”按钮。


===模板快捷方式===
===模板快捷方式===
一些模板可能有模板[[Template:shortcut|快捷方式]],这些是缩写或以其他形式不同于其目标模板的重定向。模板快捷方式可以像其目标模板一样被转录。
一些模板可能具有模板[[Template:shortcut|快捷方式]],这些是重定向,是目标模板的缩写或其他不同形式。模板快捷方式可以像其目标模板一样转录。


===翻译===
===翻译===
模板应包含翻译,以便讲其他母语的人更容易理解模板的内容。有两种方法可以实现这一点。
模板应包含翻译,以便以其他语言为母语的人更容易理解模板的内容。有两种方法可以实现这一点。


====方法一:{{tl|link=Autolang}}====
====方法一:{{tl|link=Autolang}}====
这通常用于文本较少的小型模板。此模板会自动检测用户界面的语言并提供相应的翻译(如果有)。这通常就足够了,但对于较大的模板,通常建议使用方法二。
这通常用于文本少的小型模板。该模板自动检测UI的语言,并提供适当的翻译(如果有)。通常这已经足够了,但对于较大的模板,通常建议使用方法二。


====方法二:字符串子页面====
====方法二:字符串子页面====
较大的模板(例如{{tl|link=Software page}})往往包含大量文本,将它们全部放在一个页面上会使页面无意义地杂乱且非常难以编辑。为了解决这个问题,这些模板上几乎所有的文本都放在字符串子页面上(例如{{tl|link=Software page/strings}}),当指定了特定字符串时,它将呈现适当的翻译文本。这不仅使文本编辑变得更容易,而且因为编辑者不必穿过大量代码来找到他们想要编辑/翻译的一小段文本,翻译也变得更容易。然而,这对于小型模板来说可能非常复杂,因此通常保留给较大的模板。
较大的模板(例如{{tl|link=Software page}})往往具有大量文本,在一个页面上将它们全部放在一起会使其显得杂乱无章且很难编辑。为了解决这个问题,几乎所有这些模板上的文本都放在了一个字符串子页面(例如{{tl|link=Software page/strings}})上,当指定特定字符串时,它将呈现相应的翻译文本。这不仅有助于文本编辑,还有助于翻译,因为编辑者不必在大量代码中寻找他们想要编辑/翻译的小文本。然而,对于较小的模板来说,这可能会非常复杂,因此通常只用于较大的模板。


{{Tip|您可能会看到一些模板仍在使用旧的后缀翻译方法。请记住,这不再是首选方法,如果您知道如何操作,应该更新为使用当前的方法。}}
{{Tip|您可能会看到一些模板仍在使用旧的后缀翻译方法。请注意,这不再是首选方法,如果您知道如何操作,应该更新为使用当前的方法。}}


==Useful Templates==
==有用的模板==


All templates in '''{{style|color:#8BC53F|green text}}''' are that color so that they stand out against the greyscale tones of most pages. Most templates with that color also automatically add pages they are transcluded on into [[:Category:TODO]].
所有以'''{{style|color:#8BC53F|绿色文本}}'''显示的模板都是该颜色,以便与大多数页面的灰度色调形成对比。大多数具有该颜色的模板还会自动将其转录到的页面添加到[[:Category:TODO]]


===Per-game Templates===
===按游戏分类的模板===


All games have templates named by their shortcut that can deliver their associated icon and/or a link to their page. See [[:Category:Game icons]] for a full list of game shortcuts. All of them accept the same set of parameters that are described on every template page. The following table should give examples and also give ideas on when to use them.
所有游戏都有以其快捷方式命名的模板,可以提供其关联图标和/或链接到其页面的链接。请参阅[[:Category:Game icons]]以获取游戏快捷方式的完整列表。它们都接受每个模板页面上描述的相同一组参数。以下表格应该给出示例,同时也给出了何时使用它们的想法。
{| class="wikitable mw-collapsible" width=100% style=background-color:transparent
{| class="wikitable mw-collapsible" width=100% style=background-color:transparent
! Wikitext
! Wikitext
!colspan=3| Example
!colspan=3| 示例
! Description
! 描述
! Formerly used template/Alternatives
! 以前使用的模板/替代品
|-
|-
| {{tlc|<shortcut>}} || {{tl2|hl2}}||→||{{hl2}} || Displays the game's icon which links to its game's page and shows the game's name as a hover text. Putting this at the beginning (or end) of a word or line is the shortest and most common way of clarifying that something applies only to a specific game, but there are more ways. ||
| {{tlc|<shortcut>}} || {{tl2|hl2}}||→||{{hl2}} || 显示游戏的图标,链接到其游戏页面,并将游戏名称显示为悬停文本。将其放在单词或行的开头(或结尾)是澄清仅适用于特定游戏的最简短和最常见的方式,但还有其他更多的方法。||
|-
|-
| {{tlc|<shortcut>|2}} || {{tlc|hl2|2}}||→||{{hl2|2}} || Displays the game's icon followed by its name which both link to the game's page. Useful in sentences when the icon alone is too little but the next style is too much. || {{tl2|game link}} {{deprecated}}
| {{tlc|<shortcut>|2}} || {{tlc|hl2|2}}||→||{{hl2|2}} || 显示游戏的图标,后跟其名称,两者都链接到游戏页面。在句子中使用时,仅图标太小,但下一个样式太多时,此项非常有用。|| {{tl2|game link}} {{deprecated}}
|-
|-
| {{tlc|<shortcut>|4}} || {{tlc|hl2|4}}||→||{{hl2|4}} || Does the same but using colorful text which grabs more attention, so don't overuse this on a page. Especially if you name the same game multiple times in a text, you definitely don't need a long, colorful link every time, let alone a link. || {{tl2|game name}} {{deprecated}}
| {{tlc|<shortcut>|4}} || {{tlc|hl2|4}}||→||{{hl2|4}} || 使用色彩丰富的文本执行相同操作,引起更多关注,因此不要在页面上过度使用此功能。特别是如果在文本中多次命名同一款游戏,那么绝对不需要每次都是一个长而且有色彩的链接,更不要说链接了。|| {{tl2|game name}} {{deprecated}}
|-
|-
| {{tlc|<shortcut>|in}} || {{tlc|hl2|in}} ||→|| {{hl2|in}} || Can be used to indicate that something applies to a specific game. Useful at the end of a line or key word; The same applies to the following variants. || {{tl2|in}}
| {{tlc|<shortcut>|in}} || {{tlc|hl2|in}} ||→|| {{hl2|in}} || 可用于指示某些内容适用于特定游戏。在行尾或关键字处使用时很有用;后续变体也是如此。|| {{tl2|in}}
|-
|-
| {{tlc|<shortcut>|since}} || {{tlc|portal2|since}} ||→|| {{portal2|since}} || Can be used to quickly note features that were added in a game and are available in all Source games afterwards. || {{tl2|since}}
| {{tlc|<shortcut>|since}} || {{tlc|portal2|since}} ||→|| {{portal2|since}} || 可用于快速注明添加在游戏中并在之后所有Source游戏中可用的功能。|| {{tl2|since}}
|-
|-
| {{tlc|<shortcut>|only}} || {{tlc|csgo|only}} ||→|| {{csgo|only}} || Indicates features that are exclusive to a specific game. || {{tl2|only}}
| {{tlc|<shortcut>|only}} || {{tlc|csgo|only}} ||→|| {{csgo|only}} || 表示仅适用于特定游戏的功能。|| {{tl2|only}}
|-
|-
| {{tlc|<shortcut>|also}} || {{tlc|as|since}}&nbsp;{{tlc|gmod|also}} ||→|| {{as|since}}&nbsp;{{gmod|also}} || Notes that earlier game also has a feature, usually backported from newer engine branches. These should be used with in conjunction with another game notice template. || {{tl2|also}}
| {{tlc|<shortcut>|also}} || {{tlc|as|since}}&nbsp;{{tlc|gmod|also}} ||→|| {{as|since}}&nbsp;{{gmod|also}} || 指出较早的游戏也具有一个功能,通常是从较新的引擎分支中移植过来的。这些应与另一个游戏通知模板一起使用。|| {{tl2|also}}
|-
|-
| {{tlc|<shortcut>|removed}} || {{tlc|l4d|removed}} ||→|| {{l4d|removed}} || Indicates that a feature was removed in a game and all later engine branches. || {{tl2|removed}}
| {{tlc|<shortcut>|removed}} || {{tlc|l4d|removed}} ||→|| {{l4d|removed}} || 表示某个功能在游戏中被移除,以及之后的所有引擎分支。|| {{tl2|removed}}
|-
|-
| {{tlc|<shortcut>|not}} || {{tlc|czds|not}} ||→|| {{czds|not}} || Indicates that a feature might be in other games but not in a specific one. || {{tl2|not}}
| {{tlc|<shortcut>|not}} || {{tlc|czds|not}} ||→|| {{czds|not}} || 表示某个功能可能在其他游戏中,但在特定游戏中不存在。|| {{tl2|not}}
|}
|}


=== Inline Note Templates ===
=== 内联注释模板 ===


The following are some of the [[:Category:inline note templates|inline note templates]].
以下是一些[[:Category:inline note templates|内联注释模板]]
{| class="wikitable mw-collapsible" width=100% style=background-color:transparent
{| class="wikitable mw-collapsible" width=100% style=background-color:transparent
! Description
! 描述
! Wikitext and Result
! Wikitext 和 结果
|-
|-
| [[Template:Bug]] notifies readers of a [[Wikipedia:Software bug|bug]].
| [[Template:Bug]] 通知读者[[Wikipedia:Software bug|bug]]
| {{tlc|bug|The amount is double what it should be. Be careful!}}<br>{{bug|The amount is double what it should be. Be careful!}}
| {{tlc|bug|数量是应有的两倍。小心!}}<br>{{bug|数量是应有的两倍。小心!}}
|-
|-
| [[Template:Clarify]] marks things that should be clarified.
| [[Template:Clarify]] 标记应该澄清的事项。
| <code>PAS is a kind of bounding-box for Player or NPC AI sound detection.{{tlc|clarify}}</code><br>PAS is a kind of bounding-box for Player or NPC AI sound detection.{{clarify}}
| <code>PAS是用于玩家或NPC AI声音检测的一种包围框。{{tlc|clarify}}</code><br>PAS是用于玩家或NPC AI声音检测的一种包围框。{{clarify}}
|-
|-
|rowspan=2| [[Template:Confirm]] marks something that needs to be confirmed. It's green color is meant to stand out.
|rowspan=2| [[Template:Confirm]] 标记需要确认的内容。它的绿色用于突出显示。
| {{tlc|confirm|Always goes to the left.}}<br><div style="margin:0.4em 1em 0.5em;">{{confirm|Always goes to the left.}}</div>
| {{tlc|confirm|始终向左移动。}}<br><div style="margin:0.4em 1em 0.5em;">{{confirm|始终向左移动。}}</div>
|-
|-
|<code>Always goes to the left.{{tlc|confirm}}</code><br>Always goes to the left.{{confirm}}
|<code>始终向左移动。{{tlc|confirm}}</code><
 
br>始终向左移动。{{confirm}}
|-
|-
| [[Template:Distinguish]] lets you notify users about pages that share similar names or may be confused for something else.
| [[Template:Distinguish]] 让您通知用户有关共享相似名称的页面或可能被误认为其他内容的页面。
| {{tlc|distinguish|"Follow Freeman!"|desc1{{=}}The HL2 chapter}}<br>{{distinguish|"Follow Freeman!"|desc1=The HL2 chapter}}
| {{tlc|distinguish|"跟随弗里曼!"|desc1{{=}}HL2章节}}<br>{{distinguish|"跟随弗里曼!"|desc1=HL2章节}}
|-
|-
| [[Template:How]] asks the question ''how?''
| [[Template:How]] 提出问题''如何?''
| <code>Players can get past these.{{tlc|how}}</code><br>Players can get past these.{{how}}
| <code>玩家可以越过这些。{{tlc|how}}</code><br>玩家可以越过这些。{{how}}
|-
|-
| [[Template:Idea]] is a nifty way to suggest ideas.
| [[Template:Idea]] 是提出建议的好方法。
| {{tlc|idea|Reward players for being clever and creative, instead of forcing things to be only one way.}}<br>{{idea|Reward players for being clever and creative, instead of forcing things to be only one way.}}
| {{tlc|idea|奖励玩家的聪明和创造性,而不是强制性的一种方式。}}<br>{{idea|奖励玩家的聪明和创造性,而不是强制性的一种方式。}}
|-
|-
| [[Template:Main]] notes that there is a more detailed article about a certain topic.
| [[Template:Main]] 注明有关某一特定主题的更详细文章。
| {{tlc|main|Soundscripts}}<br>{{main|Soundscripts}}
| {{tlc|main|Soundscripts}}<br>{{main|Soundscripts}}
|-
|-
| [[Template:Note]] is for making notes stand out more.
| [[Template:Note]] 用于突出显示注释。
| {{tlc|note|This will spawn at the map origin if you do not specify the position.}}<br>{{note|This will spawn at the map origin if you do not specify the position.}}
| {{tlc|note|如果不指定位置,这将在地图原点生成。}}<br>{{note|如果不指定位置,这将在地图原点生成。}}
|-
|-
| [[Template:Question]] denotes a question
| [[Template:Question]] 表示问题
| {{tlc|question|Does this work in newer engine branches?}}<br>{{question|Does this work in newer engine branches?}}
| {{tlc|question|这在较新的引擎分支中有效吗?}}<br>{{question|这在较新的引擎分支中有效吗?}}
|-
|-
| [[Template:Suggestion]] is for suggesting something
| [[Template:Suggestion]] 用于提出建议
| {{tlc|suggestion|Levels should be optimized for peak performance.}}<br>{{suggestion|Levels should be optimized for peak performance.}}
| {{tlc|suggestion|关卡应该针对最佳性能进行优化。}}<br>{{suggestion|关卡应该针对最佳性能进行优化。}}
|-
|-
| [[Template:Tip]] marks text as a tip to readers.
| [[Template:Tip]] 将文本标记为读者的提示。
| {{tlc|tip|This is a much less tricky process when using the vertex edit tool as well.}}<br>{{tip|This is a much less tricky process when using the vertex edit tool as well.}}
| {{tlc|tip|使用顶点编辑工具时,这个过程要简单得多。}}<br>{{tip|使用顶点编辑工具时,这个过程要简单得多。}}
|-
|-
| [[Template:Todo]] marks things that need to be done. It's green color is meant to stand out.
| [[Template:Todo]] 标记需要完成的任务。它的绿色用于突出显示。
| {{tlc|todo|Find where this is in the game files.}}<br><strong style="color:#8BC53F;white-space:nowrap;">To do:&nbsp;</strong>Find where this is in the game files.
| {{tlc|todo|找到游戏文件中的位置。}}<br><strong style="color:#8BC53F;white-space:nowrap;">待办事项:&nbsp;</strong>找到游戏文件中的位置。
|-
|-
| [[Template:Warning]] marks things that readers should take caution of when doing something.
| [[Template:Warning]] 标记读者在做某事时应注意的事项。
| {{tlc|warning|This tool has been known to corrupt files. Try an alternative listed below.}}<br>{{warning|This tool has been known to corrupt files. Try an alternative listed below.}}
| {{tlc|warning|该工具已知会损坏文件。请尝试下面列出的备用方法。}}<br>{{warning|该工具已知会损坏文件。请尝试下面列出的备用方法。}}
|-
|-
| [[Template:Workaround]] informs readers of a workaround
| [[Template:Workaround]] 通知读者一个解决方法
| {{tlc|workaround|This should be automated with logic instead.}}<br>{{workaround|This should be automated with logic instead.}}
| {{tlc|workaround|应该使用逻辑自动化此操作。}}<br>{{workaround|应该使用逻辑自动化此操作。}}
|-
|-
| [[Template:Why]] asks the question ''why?''
| [[Template:Why]] 提出问题''为什么?''
| <code>This shader has been deprecated.{{tlc|why}}</code><br>This shader has been deprecated.{{why}}
| <code>此着色器已被弃用。{{tlc|why}}</code><br>此着色器已被弃用。{{why}}
|}
|}


=== Notice Templates ===
===通知模板===
The following is a list of some [[:Category:Notice_templates|notice templates]].
以下是一些[[:Category:Notice_templates|通知模板]]的列表。
{| class="wikitable mw-collapsible" width=100% style=background-color:transparent
{| class="wikitable mw-collapsible" width=100% style=background-color:transparent
! Description
! 描述
!width=70%| Wikitext and Result
!width=70%| Wikitext 和 结果


|-
|-
| {{tl2|Cleanup}} marks a page that needs to be fixed up, preferably by someone knowledgeable. The text message is optional. If you do not give sufficient reason for the notice on the transclusion or the talk page, expect it to be removed by someone else.
| {{tl2|Cleanup}} 标记需要修复的页面,最好由了解情况的人进行。文本消息是可选的。如果您在转录或讨论页面上没有提供足够的通知原因,则可以预期其他人将其删除。
| {{tlc|cleanup|The last section needs to be clarified.}}<br>{{cleanup|nocat=1|The last section needs to be clarified}}
| {{tlc|cleanup|最后一部分需要澄清。}}<br>{{cleanup|nocat=1|最后一部分需要澄清。}}


|-
|-
| {{tl2|Delete}} marks a page that should be deleted. If you do not give sufficient reason for the notice on the transclusion or the talk page, expect it to be removed by someone else. When putting this on a page, you should also list the reason on that page's talk page, for any future readers that may want to know the purpose of the deletion.
| {{tl2|Delete}} 标记应删除的页面。如果您在转录或讨论页面上没有提供足够的通知原因,则可以预期其他人将其删除。在页面上放置此标记时,您还应在该页面的讨论页面上列出原因,以供将来可能希望了解删除目的的读者查看。
| {{tlc|delete}}{{delete|nocat=1}}
| {{tlc|delete}}{{delete|nocat=1}}
|-
|-


| {{tl2|Merge}} is a notice that notifies editors that it's been suggested for two or more pages to be combined into one. All merges should be discussed before being done.
| {{tl2|Merge}} 是一个通知,通知编辑人员建议将两个或更多页面合并为一个。在执行任何合并操作之前,应进行讨论。
| {{tlc|merge|HDR}}<br>{{merge|[[HDR]]|nocat=1}}
| {{tlc|merge|HDR}}<br>{{merge|[[HDR]]|nocat=1}}
|-
|-


| {{tl2|Messagebox}} provides a standard message box. This template is used by many notice templates.
| {{tl2|Messagebox}} 提供标准消息框。该模板被许多通知模板使用。
| {{tlc|messagebox|text{{=}}Remember to follow wiki etiquette.}}<br>{{messagebox|text=Remember to follow wiki etiquette.}}
| {{tlc|messagebox|text{{=}}请记得遵守维基礼仪。}}<br>{{messagebox|text=请记得遵守维基礼仪。}}


|-
|-


| {{tl2|Metanotice}} is a modernized alternative to {{tl|Messagebox}}. Its syntax is simple but very modular.
| {{tl2|Metanotice}} {{tl|Messagebox}}的现代化替代方案。它的语法简单但非常模块化。
| {{tlc|metanotice|text{{=}}Is this what you are looking for?}}<br>{{metanotice|text=Is this what you are looking for?}}
| {{tlc|metanotice|text{{=}}这是您要找的吗?}}<br>{{metanotice|text=这是您要找的吗?}}


|-
|-
| {{tl2|Morescreenshots}} marks pages that should have more images on them. It allows for an optional text message to clarify what needs images.
| {{tl2|Morescreenshots}} 标记应该有更多图像的页面。它允许可选的文本消息以阐明需要图像的内容。
| {{tlc|morescreenshots|$envmapcontrast, $envmapsaturation}}<br>{{messagebox
| {{tlc|morescreenshots|$envmapcontrast, $envmapsaturation}}<br>{{messagebox
  |text = This article or section needs additional screenshots for:'''<p style="font-style: italic;">$envmapcontrast, $envmapsaturation</p>| .
  |text = 此文章或部分需要更多截图:<p style="font-style: italic;">$envmapcontrast, $envmapsaturation</p>| .
  |small = You can upload screenshots at [[Special:Upload]]. For help, see the [[Help:Images]].
  |small = 您可以在[[Special:Upload]]上传截图。有关帮助,请参阅[[Help:Images]]
  |image = [[File:Nuvola apps ksnapshot.png|50px|link=]]
  |image = [[File:Nuvola apps ksnapshot.png|50px|link=]]
  |bdcolor = #F4C430
  |bdcolor = #F4C430
Line 316: Line 321:


|-
|-
| {{tl2|Obsolete}} marks things that should no longer be used. Accepts three parameters, entity, tool, and shader.
| {{tl2|Obsolete}} 标记不应再使用的内容。接受三个参数,实体、工具和着色器。
| {{tlc|obsolete|entity{{=}}1}}<br>{{messagebox
| {{tlc|obsolete|entity{{=}}1}}<br>{{messagebox
  |text = This entity is '''obsolete'''; its use is discouraged and it may only exist/function in older engine branches.
  |text = 此实体已经'''过时''';不鼓励使用它,它可能仅存在/功能在较旧的引擎分支中。
  |image = [[File:obsolete.png|40px|link=]]
  |image = [[File:obsolete.png|40px|link=]]
  |bdcolor = #F4C430
  |bdcolor = #F4C430
Line 324: Line 329:


|-
|-
| {{tl2|Spammer}} marks users that should be banned for spamming. For suspicious but not bannable behavior, there is also [[Template:Minor Spammer]]. {{bug|This template's formatting may look weird sometimes. It's intended to be the only thing on a page.}}
| {{tl2|Spammer}} 标记应该因垃圾邮件而被禁止的用户。对于可疑但不能被禁止的行为,还有[[Template:Minor Spammer]]{{bug|有时该模板的格式可能看起来奇怪。它意在成为页面上唯一的东西。}}
| {{tlc|spammer}}<br>[[File:Spammer.jpg|left]]
| {{tlc|spammer}}<br>[[File:Spammer.jpg|left]]
<div style="overflow:auto;">
<div style="overflow:auto;">
{{Note|''This user is a [[Wikipedia:Spammer|spammer]], [[Wikipedia:Vandalism|vandal]] or other problem poster and should be considered for a [[Special:Ipblocklist|ban]]''}}
{{Note|''此用户是[[Wikipedia:Spammer|垃圾邮件发送者]][[Wikipedia:Vandalism|破坏者]]或其他问题发布者,应考虑[[Special:Ipblocklist|禁止]]''}}
----
----
* [{{SERVER}}{{localurl:Special:Blockip|ip={{PAGENAMEE}}}}&wpBlockExpiry=infinite&wpHardBlock=1&wpAutoBlock=1&wpCreateAccount=0$wpBlockEmail=1&wpBlockReasonList=Spamming Block this user.] (Requires admin rights)
* [{{SERVER}}{{localurl:Special:Blockip|ip={{PAGENAMEE}}}}&wpBlockExpiry=infinite&wpHardBlock=1&wpAutoBlock=1&wpCreateAccount=0$wpBlockEmail=1&wpBlockReasonList=Spamming 封禁此用户。] (需要管理员权限)
* [{{SERVER}}{{localurl:Special:Log|type=block&page=User:{{PAGENAMEE}}}} Check if this user has been banned.]
* [{{SERVER}}{{localurl:Special:Log|type=block&page=User:{{PAGENAMEE}}}} 检查此用户是否已被封禁。]
* [[Special:Contributions/{{PAGENAMEE}}|View this user's contributions.]]
* [[Special:Contributions/{{PAGENAMEE}}|查看此用户的贡献。]]
</div>
</div>


|-
|-
| {{tl2|Banned user}} marks users that have been banned (usually by Valve employees) for spamming, vandalizing pages, edit warring or trolling along with many other reasons.
| {{tl2|Banned user}} 标记已经被禁止(通常由Valve员工)因垃圾邮件,破坏页面,编辑战争或玩弄 along with many other reasons。
| {{tlc|Banned user}}{{Banned user|nocat=1}}
| {{tlc|Banned user}}{{Banned user|nocat=1}}
|-
|-
| {{tl2|Split-apart}} marks pages that should be split into multiple pages. All splits should be discussed before being done.
| {{tl2|Split-apart}} 标记应该分割成多个页面的页面。所有拆分操作都应在执行之前进行讨论。
| {{tlc|split-apart}}{{split-apart|nocat=1}}
| {{tlc|split-apart}}{{split-apart|nocat=1}}
|-
|-
| {{tl2|Stub}} marks pages that are very small. See [[Help:Stubs]] for info on using.
| {{tl2|Stub}} 标记非常小的页面。请参阅[[Help:Stubs]]以获取有关使用的信息。
| {{tlc|stub}}{{stub|nocat=1}}
| {{tlc|stub}}{{stub|nocat=1}}


|-
|-
| {{tl2|Translate}} marks pages where translation is needed and adds the page to a category.
| {{tl2|Translate}} 标记需要翻译的页面,并将页面添加到一个类别。
| {{tlc|Translate}}{{translate|nocat=1}}
| {{tlc|Translate}}{{translate|nocat=1}}


|-
|-
| {{tl2|Update}} marks outdated pages.
| {{tl2|Update}} 标记过时的页面。
| {{tlc|update}}{{update|nocat=1}}
| {{tlc|update}}{{update|nocat=1}}


|-
|-
| {{tl2|Wip}} marks pages that are in the middle of major edits. The adder requests that other users do not edit in the meantime.
| {{tl2|Wip}} 标记正在进行重大编辑的页面。添加者要求其他用户在此期间不要编辑。
| {{tlc|Wip}}{{wip|nocat=1}}
| {{tlc|Wip}}{{wip|nocat=1}}


|-
|-
| {{tl2|Draft}} marks pages that are currently being worked on.
| {{tl2|Draft}} 标记目前正在工作的页面。
| {{tlc|draft}}{{draft|nocat=1}}
| {{tlc|draft}}{{draft|nocat=1}}
|}
|}


===Miscellaneous Templates===
===杂项模板===


These templates have the purpose of helping the editor.
这些模板的目的是帮助编辑人员。
{| class="wikitable mw-collapsible" width=100% style=background-color:transparent
{| class="wikitable mw-collapsible" width=100% style=background-color:transparent
! Description
! 描述
!style=width:60%| Wikitext and Result
!style=width:60%| Wikitext 和 结果
|-
|-
|rowspan=2| [[Template:=]] is a template that only returns an equal sign. The character is sometimes needed because multiple wiki features make use of it. Especially, the equals sign is a special character in template calls, so if an equals sign should be passed as a parameter value, then {{tlc|{{=}}}} is needed for "escaping". For the same purpose, there is also [[Template:!]] for a pipe, [[Template:(((]] for curly brackets and many more, see [[:Category:Templates for within templates]].
|rowspan=2| [[Template:=]] 是一个只返回等号的模板。有时候需要这个字符,因为多个维基功能会用到它。特别是在模板调用中,等号是一个特殊字符,所以如果等号应该作为参数值传递,那么需要使用{{tlc|{{=}}}}进行“转义”。出于同样的目的,还有[[Template:!]]用于管道符、[[Template:(((]]用于大括号等等,详见[[:Category:Templates for within templates]]
| {{tlc|{{=}}}}<br>{{=}}
| {{tlc|{{=}}}}<br>{{=}}
|-
|-
| {{tlc|note|If x &#123;&#123;{{=}}&#125;&#125; 0, you lose.}}<br>{{note|If x {{=}} 0, you lose.}}
| {{tlc|note|如果 x &#123;&#123;{{=}}&#125;&#125; 0,你就输了。}}<br>{{note|如果 x {{=}} 0,你就输了。}}


|-
|-
| [[Template:Clr]] clears the vertical space to the left and right of floating tables, floating images etc. To clear only one side, use {{tlc|clr|left}} or {{tlc|clr|right}}. This is commonly used before headlines to push them down so that they don't appear next to an image. In the example on the right, one could also use {{tlc|clr|left}} for the same effect.
| [[Template:Clr]] 清除悬浮表格、悬浮图片等左右两侧的垂直空间。要仅清除一侧,请使用{{tlc|clr|left}}{{tlc|clr|right}}。这通常在标题之前使用,以将它们向下推,使其不会出现在图像旁边。在右侧的示例中,也可以使用{{tlc|clr|left}}达到同样的效果。
| <code><nowiki>[[File:Skull and crossbones.png|50px|left]]
| <code><nowiki>[[File:Skull and crossbones.png|50px|left]]
This text is next to the image.{{clr}}This text is below the image.</nowiki></code><br><br>
这段文字在图像旁边。{{clr}}这段文字在图像下面。</nowiki></code><br><br>
[[File:Skull and crossbones.png|50px|left]]
[[File:Skull and crossbones.png|50px|left]]
This text is next to the image.{{clr}}This text is below the image.
这段文字在图像旁边。{{clr}}这段文字在图像下面。


|-
|-
| [[Template:Ent]] is a really small template for making text that's both code and a link.
| [[Template:Ent]] 是一个非常小的模板,用于制作既是代码又是链接的文本。
| {{tlc|ent|noclip}}<br>{{ent|noclip}}
| {{tlc|ent|noclip}}<br>{{ent|noclip}}


|-
|-
|rowspan=2| [[Template:Expand]] or [[Template:ExpandBox]] allows you to hide stuff inside a box that can be shrunk down so that it doesn't make pages as long.
|rowspan=2| [[Template:Expand]] [[Template:ExpandBox]] 允许您隐藏盒子内的内容,以便它不会使页面变得太长。
| {{tlc|Expand|{{tlc|KV BaseEntity|noscroll{{=}}1}}}}<br>{{Expand|{{KV BaseEntity|noscroll=1}}}} <!-- doesn't inherit Categories, no need to subst: -->
| {{tlc|Expand|{{tlc|KV BaseEntity|noscroll{{=}}1}}}}<br>{{Expand|{{KV BaseEntity|noscroll=1}}}} <!-- doesn't inherit Categories, no need to subst: -->


Line 392: Line 397:


|-
|-
| [[Template:MultiPage]] is used for translations, which replaced the deprecated {{t|Lang}} template, which stands for '''lang'''uage. This page itself uses the MultiPage template, using the wikitext {{tlc|MultiPage}}, and with the {{t|Language subpage}} template added to the language subpages (for example, it is located in [[Help:Templates/en]] for English language, containing everything else with the {{t|Language subpage}} template on top).<br><br>The {{t|MultiPage}}, and it's predecessor, {{t|Lang}} template creates flags at the top right corner of a page such as {{Flag|en}} {{Flag|ru}} {{Flag|zh}} and thus must be the first template to be transcluded to be in the right position.
| [[Template:MultiPage]] 用于替换不推荐使用的{{t|Lang}}模板,它代表'''lang'''uage(语言)。本页本身使用MultiPage模板,使用wikitext {{tlc|MultiPage}},并在语言子页面(例如,位于[[Help:Templates/en]]的英语页面,包含了所有带有{{t|Language subpage}}模板的内容)。<br><br>{{t|MultiPage}}和它的前身{{t|Lang}}模板在页面的右上角创建了国旗,例如{{Flag|en}} {{Flag|ru}} {{Flag|zh}},因此必须是要转录的第一个模板,以确保位置正确。


Every page can and should use this template as it lets the reader know of the existence of (correctly titled) [[Valve Developer Community:Alternative Languages|language pages]] of the current page and clicking on the flags links to them. Read more on [[Template:MultiPage]].
每个页面都可以和应该使用此模板,因为它让读者知道当前页面的(正确命名的) [[Valve Developer Community:Alternative Languages|语言页面]] 的存在,并点击国旗链接到它们。更多详情请阅读[[Template:MultiPage]]
| {{tlc|lang|Help:Templates}}<br>''The result is at the very top of this page.''
| {{tlc|lang|Help:Templates}}<br>''结果就在本页的顶部。''


|-
|-
| [[Template:Param]] displays the values like parameters in the way that they are used in templates. Useful for template documentations.
| [[Template:Param]] 以模板中使用的方式显示值,类似于参数。对模板文档非常有用。
| {{tlc|param|color|#fff}}<br>{{Param|color|#FFF}}
| {{tlc|param|color|#fff}}<br>{{Param|color|#FFF}}


|-
|-
| [[Template:Shortcut]] displays a small box noting (abbreviated) redirects to a page.
| [[Template:Shortcut]] 显示一个小框,指示(缩写的)重定向到一个页面。
| {{tlc|shortcut|VDC:AL}}<br>{{shortcut|VDC:AL}}
| {{tlc|shortcut|VDC:AL}}<br>{{shortcut|VDC:AL}}


|-
|-
| [[Template:Tl2]] stands for '''T'''emplate '''L'''ink (2 as it is a replacement for an older template). It creates a link to a template surrounded by &#123;&#123; &#125;&#125;. It also accepts parameters that act like parameters for the template that is linked to.
| [[Template:Tl2]] 代表'''T'''emplate '''L'''ink(2代表它是一个较老模板的替代)。它创建一个由&#123;&#123; &#125;&#125;包围的模板链接。它还接受行为像链接的模板的参数。
| {{tlc|tl2|note|Example}}<br>{{tl2|note|Example}}
| {{tlc|tl2|note|Example}}<br>{{tl2|note|Example}}
|-
|-
| [[Template:Tlc]] does the same but not creating a link, which is useful when trying to display template examples (like this entire page!).
| [[Template:Tlc]] 做同样的事情,但不创建链接,这在尝试显示模板示例时非常有用(就像整个页面一样!)。
| {{tlc|tlc|note|Example}}<br>{{tlc|note|Example}}
| {{tlc|tlc|note|Example}}<br>{{tlc|note|Example}}
|-
|-
| [[Template:Toc-right]] shifts the [[Help:Table of Contents|table of contents]] over to the right side of a page.
| [[Template:Toc-right]] [[Help:Table of Contents|目录]]移到页面的右侧。
| For an example, see [[Half-Life 2 map reference]].
| 请参见[[Half-Life 2 map reference]]的示例。


|-
|-
| [[Template:Unsigned]] is for [[Help:Etiquette|talk pages]]. It should be added at the ends of unsigned comments.
| [[Template:Unsigned]] 用于[[Help:Etiquette|讨论页面]]。应在未签名评论的末尾添加。
| {{tlc|unsigned|JeffLane}}<br>{{unsigned|JeffLane}}
| {{tlc|unsigned|JeffLane}}<br>{{unsigned|JeffLane}}
|}
|}


==Magic Words==
==魔术词==
Magic words are special character strings that are kind of like templates. To apply one, simply type it on the page.
魔术词是一种特殊的字符字符串,有点像模板。要应用一个魔术词,只需在页面上键入它。


===<code><nowiki>__TOC__</nowiki></code>===
===<code><nowiki>__TOC__</nowiki></code>===
Forces the [[Help:Table of Contents|table of contents]] to be placed at this spot.
强制[[Help:Table of Contents|目录]]放置在此位置。


===<code><nowiki>__FORCETOC__</nowiki></code>===
===<code><nowiki>__FORCETOC__</nowiki></code>===
Forces the table of contents to be placed at its normal spot. (Only useful on pages that don't have enough sections to automatically display a TOC.)
强制将目录放置在其正常位置。(仅在页面没有足够的章节自动显示目录时有用。)


===<code><nowiki>__NOTOC__</nowiki></code>===
===<code><nowiki>__NOTOC__</nowiki></code>===
Hides the table of contents.
隐藏目录。


===<code><nowiki>__HIDDENCAT__</nowiki></code>===
===<code><nowiki>__HIDDENCAT__</nowiki></code>===
Marks a [[Help:Categories|category]] as hidden. To make the website show hidden categories for you, check the '''Show hidden categories''' box in [[Special:Preferences#mw-prefsection-rendering|Special:Preferences]].
[[Help:Categories|类别]]标记为隐藏。要让网站为您显示隐藏的类别,请在[[Special:Preferences#mw-prefsection-rendering|特殊:首选项]]中勾选'''显示隐藏类别'''框。


===<code><nowiki>{{DISPLAYTITLE:title}}</nowiki></code>===
===<code><nowiki>{{DISPLAYTITLE:title}}</nowiki></code>===
Changes the title of a page at the top bar ''only''.
仅更改页面顶部栏的标题。


==See also==
==另请参阅==
*[[Special:ExpandTemplates]] - Shows completely expanded versions of templates, including substituted wikitext code and automatic substitution for any nested templates.
*[[Special:ExpandTemplates]] - 显示模板的完全展开版本,包括替换的维基文本代码和任何嵌套模板的自动替换。
*[[Special:MostTranscludedPages]] - Lists templates most frequently used on pages. This doesn't show ''just'' templates actually; any page can be transcluded.
*[[Special:MostTranscludedPages]] - 列出页面上最常用的模板。这并不仅仅显示实际的模板;任何页面都可以被引用。
*[[Special:UncategorizedTemplates]] - Lists templates that are not listed under any categories.
*[[Special:UncategorizedTemplates]] - 列出未列在任何类别下的模板。
*[[Special:UnusedTemplates]] - Lists templates that are not used on any pages.
*[[Special:UnusedTemplates]] - 列出未在任何页面上使用的模板。
*[[Special:WantedTemplates]] - Lists templates that are frequently used on pages, but do not exist. This list should be showing no pages, ideally.
*[[Special:WantedTemplates]] - 列出页面上经常使用但不存在的模板。理想情况下,此列表不应显示任何页面。
*[[Wikipedia:Help:Magic_words_for_beginners]] - More about magic words.
*[[Wikipedia:Help:Magic_words_for_beginners]] - 关于魔术词的更多信息。
*[[Wikipedia:Help:Template]] - A very helpful resource for template programming.
*[[Wikipedia:Help:Template]] - 模板编程的一个非常有用的资源。
*[[New Help Desk]] - Questions? Ask here.
*[[New Help Desk]] - 有问题?在这里提问。

Revision as of 13:49, 10 May 2024

English (en)Русский (ru)中文 (zh)Translate (Translate)
Info content.png
This translated page needs to be updated.
You can help by updating the translation.
Also, please make sure the article complies with the alternate languages guide.(en)
This notice is put here by LanguageBar template and if you want to remove it after updating the translation you can do so on this page.


This page was translated by DaKang233 on May 11, 2024 (UTC+8). Anyone is welcome to add new content or fix errors.


Broom icon.png
This article or section needs to be cleaned up to conform to a higher standard of quality
For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.

模板是一个创建用于包含在其他页面中的维基页面。模板通常包含可能需要在大量文章或页面上显示的重复性材料。它们通常用于样板消息、标准化警告或通知、信息框、导航框以及类似目的。

它们使您能够更快速和/或更容易地完成事情。模板在页面上非常频繁地使用,因此最好了解它们。当维基看到它在页面上识别的模板时,它会自动将其替换为其他内容。那里出现的内容取决于用户。

如何使用模板

要向页面添加模板(称为转录),只需键入{{,模板的名称,然后}}。 如果您希望添加任何参数,请在模板名称和}}之间放置一个|,并在那里定义参数。您定义的所有参数都需要由另一个|分隔。

Note.png注意:实际上,任何页面都可以被另一个页面转录。可以使用{{:Main Page}}转录Main Page,但我们在这里不这样做,因为它会将Main Page的所有标题添加到本页面的目录中。

示例

这是一个我们没有定义任何参数的模板。预览时,表达式{{restart}}(或{{Restart}})将被Template:Restart页面的内容替换。如果您访问它,您会看到它只包含那五个单词。

{{restart}} → Requires restart to take effect.
Note.png注意:下面是一个关于sv_cheats控制台命令的示例,这是错误的,因为它不是一个实体。请对控制台命令使用{{Command}}

{{Ent}}可以接受多达两个未命名参数。如其页面所述,该模板的工作方式是,它会以等宽字体显示第一个参数的值,并使其成为一个维基链接。假设我们想要一个指向sv_cheats的代码风格链接;要使用此模板,我们键入{{,然后是模板名称,即entEnt,然后对于第一个参数,我们键入一个管道符号和值sv_cheats。如果我们愿意,我们还可以指定第二个参数,该参数(如模板所指定)也将以代码风格显示,但不作为链接。未命名参数的顺序很重要。如果我们没有指定参数,模板就不会按预期工作。

{{ent|sv_cheats}}sv_cheats
{{ent|sv_cheats|1}}sv_cheats 1
{{ent}}[[zh/{{{1}}}|{{{1}}}]]

Template:KV是用于显示实体类keyvalue信息的最常见模板之一。它接受多个可选的命名参数,例如onlynofgd。要为这些指定值,我们需要键入参数的名称、等号,然后是值。命名参数可以以任何顺序定义。请注意,我们可以同时指定未命名和命名参数。在以下示例中,我们有三个未命名参数(ammo, integer和最后一个)和两个命名参数(only=反恐精英:起源nofgd=1)。

{{KV|only=反恐精英:起源|ammo|nofgd=1|integer|要添加的备用弹药量。默认值为0。}}
ammo ([todo internal name (i)]) <整数(en)> (存在于 反恐精英:起源 之中) 不存在于FGD!
要添加的备用弹药量。默认值为0。

如果没有|nofgd=1不存在于FGD!部分就不会显示。

Note.png注意:未命名参数可以像命名参数一样以任何顺序指定,例如:{{ent|2=1|1=sv_cheats}}sv_cheats 1。事实上,未命名参数确实有一个可以定义的名称,即它们的参数编号。这样,人们也可以例如指定第三个参数,但不是第一个和第二个。
Note.png注意:调用模板时,您总是可以指定任意数量的命名和未命名参数。唯一的问题是模板是否考虑它们,产生不同的结果或相同的结果。顺便说一下,多次指定一个参数会在页面顶部显示一个错误。

模板也可以使用模板,称为嵌套。不支持递归,因此模板不能使用自己。

替换

这是给高级用户的。与其转录模板,不如选择替换它。替换将用模板的内容替换模板调用的维基文本。 不要轻率地替换,因为替换后的维基文本在模板更新时不会更新。有关更多信息,请参见Wikipedia:Help:Substitution

要替换模板,请像通常一样转录它,然后在{{和模板名称之间添加subst:。之后,点击保存按钮,维基文本将自动添加。

例如,如果您在页面上写下{{restart}},保存它,然后再次编辑页面,您仍会在维基文本中的同一位置找到{{restart}}。相比之下,如果您保存{{subst:restart}}然后再次编辑页面,您会发现需要重启才能生效。。可以想象维基是“复制粘贴”内容过来的,但它确实考虑了参数值:

{{subst:delete|这是一个糟糕的页面。}}

如果页面保存了这个,那么文本将被Template:Delete的内容替换,其中每次出现{{{1}}}都被替换为这是一个糟糕的页面。

{{Delete-meta|{{#if: 这是一个糟糕的页面。 | 这是一个糟糕的页面。 }} }}[[Category:Candidates for speedy deletion]]

注意参数的自动转发。替换时,页面的外观不应与转录时有任何不同。唯一的区别在于页面代码。

Tip.png提示:编辑时,请务必在保存替换之前使用查看更改,以查看您实际对维基文本做了什么。

制作模板

在模板可以添加到某处之前,首先必须在其自己的页面上定义其内容。模板页面以前缀Template:开头。另请参阅:Help:Page Creation

制作像Template:Restart这样的模板相当容易:在右上角的搜索栏中输入Template:Restart,单击其红色链接(假设页面尚不存在),输入您想要的文本,然后保存。之后,这个新模板就可以像上面描述的那样使用了。

Tip.png提示:在制作模板时,您可能希望将代码分开以使其更易于阅读,但要注意不要意外添加空白,尤其是换行符。HTML注释(<!-- -->)也可能会有用。
Note.png注意:命名参数(例如{{{title}}})在模板结果中将删除前导和尾随空白,未命名参数(例如{{{1}}})则不会。

未命名参数

要添加未命名参数,只需在想要第一个未命名参数值的位置放置{{{1}}}。 这是Template:Tip代码的一部分:

提示:{{{1}}}

如果您以前见过这个模板,就会知道它有自己特殊的外观,但目前我们只看这些内容。当传递此内容时,用户只需输入他们想要的文本:

{{tip|不要在之后没有顶点编辑的情况下进行雕刻。}}
Tip.png提示:不要在之后没有顶点编辑的情况下进行雕刻。

如果要添加多个未命名参数,只需更改数字。这是Template:Distinguish的旧(压缩的)代码。此模板有一些我们尚未讨论的内容,但您仍然可以看到有四个未命名参数被使用:{{{1}}}{{{2}}}{{{3}}}{{{4}}}

:''请勿与[[:{{{1}}}]]混淆{{#if:{{{2|}}} |{{#if:{{{3|}}} |,[[:{{{2}}}]]| 或 [[:{{{2}}}]]。}}。{{#if:{{{3|}}} |{{#if:{{{4|}}} |,[[:{{{3}}}]]|,或 [[:{{{3}}}]]。}}。{{#if:{{{4|}}} |,或 [[:{{{4}}}]]。}}''

当传递内容时,用户只需这样做:

{{distinguish|Combine|Civil Protection|Overwatch}}

命名参数

通常,您希望只有在传递时定义了命名参数时才会影响任何内容。我们将在后面讨论条件。现在,让我们看一下Template:IO,它有许多命名参数。在此模板中,{{{param}}}标记了在传递时由|param=texthere定义的wikitext的位置。

使用命名参数:

{{IO|SetString|更新字符串。|param=string}}
SetString <字符串(en)>
更新字符串。

不使用命名参数:

{{IO|SetString|更新字符串。}}
SetString
更新字符串。

默认值

要使参数默认具有值,请在参数名称右侧添加|,然后定义默认值。命名参数和未命名参数都可以使用这个功能。

如果用户不指定,这会将{{{1}}}的值设为3000。

{{{1|3000}}}


如果用户没有指定|value=...,则返回空字符串。请注意{{{value}}}{{{value|}}}之间的区别。前者如果用户不定义它,将直接返回文本{{{value}}}

{{{value|}}}
Note.png注意:为参数指定默认值仅适用于该参数的特定出现。如果有多个{{{1}}}的出现,所有这些都应该具有默认值0,则必须为所有这些输入{{{1|0}}}。另一方面,如果合适的话,这也允许您在不同的出现中使用不同的默认值。

解析器函数

要使文本(不)在仅在某个参数被定义或设置为特定值时出现,以下表达式是适用的。

解析器函数#if:检查字符串是否为空。语法是{{#if: <string> | <then> | <else> }}。如果<string>不是空字符串,则此表达式评估为<then>,否则为<else>。如果不指定<else>值,则默认为空字符串;以下<else>同样适用。

{{#if:   | 非空 | 空 }} → 空
{{#if: X | 非空 | 空 }} → 非空
{{#if:   | 非空 }}
{{#if: X | 非空 }} → 非空
{{#if: {{{target|}}} | 已获取目标 | 休眠模式已激活... }} → 休眠模式已激活...
{{#if: 文字存在! | 已获取目标 | 休眠模式已激活... }} → 已获取目标
Note.png注意:表达式{{{target|}}}返回空字符串,因为您(可能)没有通过转录查看此页面,因此它从未有过定义的机会,因此返回其默认值为空字符串。

#ifeq:检查两个字符串是否相等。语法是{{#ifeq: <string1> | <string2> | <then> | <else> }}。如果两个(修剪后的)字符串完全相等,则评估为<then>,否则为<else>

{{#ifeq: X | X | 相等 | 不相等 }} → 相等
{{#ifeq: X | Y | 相等 | 不相等 }} → 不相等
{{#ifeq: {{{target|}}} | friend | 朋友... | 走开! }} → 走开!
{{#ifeq: friend | friend | 朋友... | 走开! }} → 朋友...

#switch:检查输入字符串与多个字符串之间的等式。语法是 {{#switch: <input> | <string1> = <value1> | <string2> = <value2> | ... | #default = <default> }}。 此语句将评估为第一个<stringX>等于<input>的相应<valueX>。如果<stringX>没有跟随等号,因此没有<valueX>,则使用下一个具有等号的<stringY><valueY>。如果找不到等式,则返回<default>,如果未指定,则默认为空字符串。

#expr:解决数学问题。请参阅Help:Calculation以获取其所有功能。如果发生错误,则返回<strong class="error">元素中的字符串。

{{#expr: 2 + 2}} → 4
{{#expr: cos(pi/3)^2}} → 0.25
{{#expr: 0 and 1 or 1}} → 1
{{#expr: 1 + }}Expression error: Missing operand for +.
{{#ifeq: {{#expr: 1 + }} | 1 | 真 | 假}} → 假

#ifexpr:测试数学表达式是真还是假,并根据其返回不同的值。

{{#ifexpr: 6 + 3 =  9 | 正确 | 错误 }} → 正确
{{#ifexpr: 6 + 3 = 63 | 正确 | 错误 }} → 错误
Warning.png警告:将参数传递给表达式时,要注意如果参数为空会导致错误。例如,如果整数参数在被留空时应该像0一样行为,则添加一个小数点,因为.会被转换为与0.

同的零。
例如,使用{{{hl2|0}}}.而不是{{{hl2|0}}},因为如果指定了hl2=,后者可能会失败:

{{#ifexpr: 1 or . | 真 | 假}} → 真
{{#ifexpr: 1 or   | 真 | 假}}Expression error: Missing operand for or.

lc:uc:将字符串转换为小写或大写。请注意,与#if:等不同,这些没有哈希标记。 还有lcfirst:ucfirst:,它们仅操作表达式的第一个字符。

{{lc:Case Sensitivity}} → case sensitivity
{{uc:Case Sensitivity}} → CASE SENSITIVITY
{{lcfirst:Case Sensitivity}} → case Sensitivity

文档

请描述您的模板所做的事情,特别是提供示例。为了使页面上不使用模板的描述文本,或使模板页面本身看起来更整洁,您可以使用三种不同的HTML标签。

  • <noinclude>...</noinclude> 防止wikitext被传递到其他页面。它仅会显示在模板的页面上。
  • <onlyinclude>...</onlyinclude> 使其中的wikitext仅出现在目标页面上。其他所有内容都不会被传递,但仍将出现在模板的页面上。
  • <includeonly>...</includeonly> 防止其中的wikitext出现在模板的页面上。它不会对目标页面产生影响。

因此,您可以使用<onlyinclude>将应该传递的所有内容包围起来,或者将其他所有内容都包围在<noinclude>中。此外,您可以使用<includeonly>在模板页面上隐藏模板文本。 这些标签起初可能听起来很令人困惑。如果您不确定如何使用它们,请检查模板的源代码,因为几乎所有模板都以某种方式使用它们。

如果文档不能保持简短,那么将所有解释和/或示例移至单独的页面是一个好主意。按照惯例,模板的文档页面应为其子页面/doc。例如,Template:Note有其文档页面Template:Note/doc。创建后,文档将使用表达式{{doc}}传递到模板页面,当然,必须使用上述标签排除它。

有时,模板的使用方式是相同的。您可能知道,Template:TipTemplate:Note都以完全相同的方式使用其一个参数,因此无需另一个具有相同文档的页面来描述Tip。Tip可以使用与Note相同的文档,使用表达式{{documentation|Template:Note/doc}};这背后的唯一魔法是Template:Note/doc使用表达式{{ROOTPAGENAME}}而不是Note用于其示例,以便示例适应其显示的页面。如果Template:Note/doc不是为此而制作的,那么这将行不通。 其他像这样使用的“通用文档”包括Template:Hl2Template:Yes

模板未更新

如果您最近编辑了一个模板,但更改未应用到已经转录到的页面上,请在这些页面的URL末尾添加?action=purge。这将告诉服务器立即更新页面的HTML。您也可以通过编辑页面并保存而不进行任何更改来实现相同的效果。 如果您在具有文档的模板页面上,您还可以使用相同效果的“[刷新]”按钮。

模板快捷方式

一些模板可能具有模板快捷方式,这些是重定向,是目标模板的缩写或其他不同形式。模板快捷方式可以像其目标模板一样转录。

翻译

模板应包含翻译,以便以其他语言为母语的人更容易理解模板的内容。有两种方法可以实现这一点。

方法一:{{Autolang}}

这通常用于文本少的小型模板。该模板自动检测UI的语言,并提供适当的翻译(如果有)。通常这已经足够了,但对于较大的模板,通常建议使用方法二。

方法二:字符串子页面

较大的模板(例如{{Software page}})往往具有大量文本,在一个页面上将它们全部放在一起会使其显得杂乱无章且很难编辑。为了解决这个问题,几乎所有这些模板上的文本都放在了一个字符串子页面(例如{{Software page/strings}})上,当指定特定字符串时,它将呈现相应的翻译文本。这不仅有助于文本编辑,还有助于翻译,因为编辑者不必在大量代码中寻找他们想要编辑/翻译的小文本。然而,对于较小的模板来说,这可能会非常复杂,因此通常只用于较大的模板。

Tip.png提示:您可能会看到一些模板仍在使用旧的后缀翻译方法。请注意,这不再是首选方法,如果您知道如何操作,应该更新为使用当前的方法。

有用的模板

所有以绿色文本显示的模板都是该颜色,以便与大多数页面的灰度色调形成对比。大多数具有该颜色的模板还会自动将其转录到的页面添加到Category:TODO

按游戏分类的模板

所有游戏都有以其快捷方式命名的模板,可以提供其关联图标和/或链接到其页面的链接。请参阅Category:Game icons以获取游戏快捷方式的完整列表。它们都接受每个模板页面上描述的相同一组参数。以下表格应该给出示例,同时也给出了何时使用它们的想法。

Wikitext 示例 描述 以前使用的模板/替代品
{{<shortcut>}} {{hl2}} 半衰期2 显示游戏的图标,链接到其游戏页面,并将游戏名称显示为悬停文本。将其放在单词或行的开头(或结尾)是澄清仅适用于特定游戏的最简短和最常见的方式,但还有其他更多的方法。
{{<shortcut>|2}} {{hl2|2}} 半衰期2 半衰期2 显示游戏的图标,后跟其名称,两者都链接到游戏页面。在句子中使用时,仅图标太小,但下一个样式太多时,此项非常有用。 {{game link}} [Obsolete-notext.png 已弃用]
{{<shortcut>|4}} {{hl2|4}} 半衰期2 半衰期2 使用色彩丰富的文本执行相同操作,引起更多关注,因此不要在页面上过度使用此功能。特别是如果在文本中多次命名同一款游戏,那么绝对不需要每次都是一个长而且有色彩的链接,更不要说链接了。 {{game name}} [Obsolete-notext.png 已弃用]
{{<shortcut>|in}} {{hl2|in}} (存在于 半衰期2 之中) 可用于指示某些内容适用于特定游戏。在行尾或关键字处使用时很有用;后续变体也是如此。 {{in}}
{{<shortcut>|since}} {{portal2|since}} (存在于自 传送门2 以来) 可用于快速注明添加在游戏中并在之后所有Source游戏中可用的功能。 {{since}}
{{<shortcut>|only}} {{csgo|only}} (存在于 反恐精英:全球攻势 之中) 表示仅适用于特定游戏的功能。 {{only}}
{{<shortcut>|also}} {{as|since}} {{gmod|also}} (存在于自 异形丛生 以来) (也存在于 Garry's Mod 之中) 指出较早的游戏也具有一个功能,通常是从较新的引擎分支中移植过来的。这些应与另一个游戏通知模板一起使用。 {{also}}
{{<shortcut>|removed}} {{l4d|removed}} (被移除求生之路 以来) 表示某个功能在游戏中被移除,以及之后的所有引擎分支。 {{removed}}
{{<shortcut>|not}} {{czds|not}} (存在于 零点行动 关卡模式) 表示某个功能可能在其他游戏中,但在特定游戏中不存在。 {{not}}

内联注释模板

以下是一些内联注释模板

描述 Wikitext 和 结果
Template:Bug 通知读者bug {{bug|数量是应有的两倍。小心!}}
Icon-Bug.png错误:数量是应有的两倍。小心!  [todo tested in ?]
Template:Clarify 标记应该澄清的事项。 PAS是用于玩家或NPC AI声音检测的一种包围框。{{clarify}}
PAS是用于玩家或NPC AI声音检测的一种包围框。[澄清]
Template:Confirm 标记需要确认的内容。它的绿色用于突出显示。 {{confirm|始终向左移动。}}
证实:始终向左移动。
始终向左移动。{{confirm}}<

br>始终向左移动。[证实]

Template:Distinguish 让您通知用户有关共享相似名称的页面或可能被误认为其他内容的页面。 {{distinguish|"跟随弗里曼!"|desc1=HL2章节}}
注意区分 "跟随弗里曼!" (HL2章节).
Template:How 提出问题如何? 玩家可以越过这些。{{how}}
玩家可以越过这些。[如何?]
Template:Idea 是提出建议的好方法。 {{idea|奖励玩家的聪明和创造性,而不是强制性的一种方式。}}
Tip.png想法:奖励玩家的聪明和创造性,而不是强制性的一种方式。
Template:Main 注明有关某一特定主题的更详细文章。 {{main|Soundscripts}}
主条目:  Soundscripts
Template:Note 用于突出显示注释。 {{note|如果不指定位置,这将在地图原点生成。}}
Note.png注意:如果不指定位置,这将在地图原点生成。
Template:Question 表示问题 {{question|这在较新的引擎分支中有效吗?}}
Icon-silk-question.png Question: 这在较新的引擎分支中有效吗?
Template:Suggestion 用于提出建议 {{suggestion|关卡应该针对最佳性能进行优化。}}
Icon-silk-comment.pngSuggestion: 关卡应该针对最佳性能进行优化。
Template:Tip 将文本标记为读者的提示。 {{tip|使用顶点编辑工具时,这个过程要简单得多。}}
Tip.png提示:使用顶点编辑工具时,这个过程要简单得多。
Template:Todo 标记需要完成的任务。它的绿色用于突出显示。 {{todo|找到游戏文件中的位置。}}
待办事项: 找到游戏文件中的位置。
Template:Warning 标记读者在做某事时应注意的事项。 {{warning|该工具已知会损坏文件。请尝试下面列出的备用方法。}}
Warning.png警告:该工具已知会损坏文件。请尝试下面列出的备用方法。
Template:Workaround 通知读者一个解决方法 {{workaround|应该使用逻辑自动化此操作。}}
PlacementTip.png解决方案:应该使用逻辑自动化此操作。
Template:Why 提出问题为什么? 此着色器已被弃用。{{why}}
此着色器已被弃用。[Why?]

通知模板

以下是一些通知模板的列表。

描述 Wikitext 和 结果
{{Cleanup}} 标记需要修复的页面,最好由了解情况的人进行。文本消息是可选的。如果您在转录或讨论页面上没有提供足够的通知原因,则可以预期其他人将其删除。 {{cleanup|最后一部分需要澄清。}}
Broom icon.png
This article or section needs to be cleaned up to conform to a higher standard of quality because:
最后一部分需要澄清。
For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.
{{Delete}} 标记应删除的页面。如果您在转录或讨论页面上没有提供足够的通知原因,则可以预期其他人将其删除。在页面上放置此标记时,您还应在该页面的讨论页面上列出原因,以供将来可能希望了解删除目的的读者查看。 {{delete}}
Warning icon.png
This help page has been marked as a candidate for speedy deletion.
If you object to this decision, then please discuss why here (If you make a discussion section also create this redirect page). If this page doesn't meet the criteria for speedy deletion, then please remove this notice, but do not remove it from pages that you have created yourself
Administrators / Moderators - Remember to check if anything links here and the page history before deleting.
{{Merge}} 是一个通知,通知编辑人员建议将两个或更多页面合并为一个。在执行任何合并操作之前,应进行讨论。 {{merge|HDR}}
Merge-arrows.png
It has been suggested that this article or section be merged with HDR。 (Discuss)
{{Messagebox}} 提供标准消息框。该模板被许多通知模板使用。 {{messagebox|text=请记得遵守维基礼仪。}}
{{Metanotice}}{{Messagebox}}的现代化替代方案。它的语法简单但非常模块化。 {{metanotice|text=这是您要找的吗?}}
Icon-help.png
这是您要找的吗?
{{Morescreenshots}} 标记应该有更多图像的页面。它允许可选的文本消息以阐明需要图像的内容。 {{morescreenshots|$envmapcontrast, $envmapsaturation}}
{{Obsolete}} 标记不应再使用的内容。接受三个参数,实体、工具和着色器。 {{obsolete|entity=1}}
{{Spammer}} 标记应该因垃圾邮件而被禁止的用户。对于可疑但不能被禁止的行为,还有Template:Minor Spammer
Icon-Bug.png错误:有时该模板的格式可能看起来奇怪。它意在成为页面上唯一的东西。  [todo tested in ?]
{{spammer}}
Spammer.jpg
Note.png注意:此用户是垃圾邮件发送者破坏者或其他问题发布者,应考虑禁止

{{Banned user}} 标记已经被禁止(通常由Valve员工)因垃圾邮件,破坏页面,编辑战争或玩弄 along with many other reasons。 {{Banned user}}
Icon-crystalclear-flag.png
This userhas beenbannedfor an unspecified reason, such as Wikipedia icon spamming, Wikipedia icon vandalism, Wikipedia icon copyright violations, Wikipedia icon sockpuppetry, Wikipedia icon edit warring, trolling or Wikipedia icon harassment, and/or violating the Valve Developer Community's Terms of Use along with other misbehavior。
{{Split-apart}} 标记应该分割成多个页面的页面。所有拆分操作都应在执行之前进行讨论。 {{split-apart}}

Split-arrows.png 分裂

It has been suggested that this article or section be split into multiple articles。 (Discuss)

{{Stub}} 标记非常小的页面。请参阅Help:Stubs以获取有关使用的信息。 {{stub}}

小作品

This article or section is a stub. You can help by expanding it.

{{Translate}} 标记需要翻译的页面,并将页面添加到一个类别。 {{Translate}}
Info content.png
This page needs to be translated.
This page either contains information that is only partially or incorrectly translated, or there isn't a translation yet.
If this page cannot be translated for some reason, or is left untranslated for an extended period of time after this notice is posted, the page should be requested to be deleted.
Also, please make sure the article complies with the alternate languages guide.(en)
{{Update}} 标记过时的页面。 {{update}}
Broom icon.png
This article or section needs to be updated to include current information regarding the subject。
Remember to check for any notes left by the tagger at this article's talk page.
{{Wip}} 标记正在进行重大编辑的页面。添加者要求其他用户在此期间不要编辑。 {{Wip}}
Under construction.png
This Help page is actively undergoing a major edit.
As a courtesy, please do not edit this Help while this message is displayed.
If this page has not been edited for at least several hours to a few days, please remove this template. This message is intended to help reduce edit conflicts; please remove it between editing sessions to allow others to edit the page.

The person who added this notice will be listed in its edit history should you wish to contact them.


{{Draft}} 标记目前正在工作的页面。 {{draft}}
Icon-under construction-blue.png
This is a draft help page. It is a work in progress open to editing by anyone.
Remember to check for any notes left by the tagger at this article's talk page.

杂项模板

这些模板的目的是帮助编辑人员。

描述 Wikitext 和 结果
Template:= 是一个只返回等号的模板。有时候需要这个字符,因为多个维基功能会用到它。特别是在模板调用中,等号是一个特殊字符,所以如果等号应该作为参数值传递,那么需要使用{{=}}进行“转义”。出于同样的目的,还有Template:!用于管道符、Template:(((用于大括号等等,详见Category:Templates for within templates {{=}}
=
{{note|如果 x {{=}} 0,你就输了。}}
Note.png注意:如果 x = 0,你就输了。
Template:Clr 清除悬浮表格、悬浮图片等左右两侧的垂直空间。要仅清除一侧,请使用{{clr|left}}{{clr|right}}。这通常在标题之前使用,以将它们向下推,使其不会出现在图像旁边。在右侧的示例中,也可以使用{{clr|left}}达到同样的效果。 [[File:Skull and crossbones.png|50px|left]] 这段文字在图像旁边。{{clr}}这段文字在图像下面。

Skull and crossbones.png
这段文字在图像旁边。
这段文字在图像下面。
Template:Ent 是一个非常小的模板,用于制作既是代码又是链接的文本。 {{ent|noclip}}
noclip
Template:ExpandTemplate:ExpandBox 允许您隐藏盒子内的内容,以便它不会使页面变得太长。 class="mw-collapsible mw-collapsed" style="background:rgba(0,0,0,0.05) ;float:no;margin-bottom:1em;margin-left:0;padding-right:0.5em;border:1px solid rgba(255,255,255,0.1); border-left:solid 1px #8bb9e0; padding-left:1em;"

|- | {{ExpandBox|{{KV BaseEntity|noscroll=1}}}}


|- | Template:MultiPage 用于替换不推荐使用的{{Lang}}模板,它代表language(语言)。本页本身使用MultiPage模板,使用wikitext {{MultiPage}},并在语言子页面(例如,位于Help:Templates/en的英语页面,包含了所有带有{{Language subpage}}模板的内容)。

{{MultiPage}}和它的前身{{Lang}}模板在页面的右上角创建了国旗,例如English (en) Русский (ru) 中文 (zh),因此必须是要转录的第一个模板,以确保位置正确。

每个页面都可以和应该使用此模板,因为它让读者知道当前页面的(正确命名的) 语言页面 的存在,并点击国旗链接到它们。更多详情请阅读Template:MultiPage。 | {{lang|Help:Templates}}
结果就在本页的顶部。

|- | Template:Param 以模板中使用的方式显示值,类似于参数。对模板文档非常有用。 | {{param|color|#fff}}
{{{color|#FFF}}}

|- | Template:Shortcut 显示一个小框,指示(缩写的)重定向到一个页面。

| {{shortcut|VDC:AL}}

|- | Template:Tl2 代表Template Link(2代表它是一个较老模板的替代)。它创建一个由{{ }}包围的模板链接。它还接受行为像链接的模板的参数。 | {{tl2|note|Example}}
{{note|Example}} |- | Template:Tlc 做同样的事情,但不创建链接,这在尝试显示模板示例时非常有用(就像整个页面一样!)。 | {{tlc|note|Example}}
{{note|Example}} |- | Template:Toc-right目录移到页面的右侧。 | 请参见Half-Life 2 map reference的示例。

|- | Template:Unsigned 用于讨论页面。应在未签名评论的末尾添加。 | {{unsigned|JeffLane}}
Unsigned comment added by JeffLane (talkcontribs) Always sign your posts with four tildes (~~~~) |}

魔术词

魔术词是一种特殊的字符字符串,有点像模板。要应用一个魔术词,只需在页面上键入它。

__TOC__

强制目录放置在此位置。

__FORCETOC__

强制将目录放置在其正常位置。(仅在页面没有足够的章节自动显示目录时有用。)

__NOTOC__

隐藏目录。

__HIDDENCAT__

类别标记为隐藏。要让网站为您显示隐藏的类别,请在特殊:首选项中勾选显示隐藏类别框。

{{DISPLAYTITLE:title}}

仅更改页面顶部栏的标题。

另请参阅