This template is protected from editing.

Difference between revisions of "Template:If lang"

From Team Fortress Wiki
Jump to: navigation, search
m (Protected "Template:If lang": High traffic page ([edit=sysop] (indefinite) [move=sysop] (indefinite)))
(better documentation)
Line 1: Line 1:
{{#ifeq:{{SUBPAGENAME}}|{{BASEPAGENAME}}|{{{1|}}}|{{{2|/{{SUBPAGENAME}}}}}|}}<noinclude>
+
{{#ifeq:{{SUBPAGENAME}}|{{BASEPAGENAME}}|{{{1|}}}|{{{2|/{{SUBPAGENAME}}}}}|}}<noinclude>{{doc begin}}
* If ''subpagename'' equals ''basepagename'', {{tl|if lang}} will output nothing.
+
{{tl|if lang}} tests whether a page is a language subpage and can output specified values based on this. It can be particularly useful in creating links to language pages without disrupting links to English pages.
* If ''subpagename'' equals ''ru'' or ''fr'', {{tl|if lang}} will output, by default, <code><nowiki>/{{SUBPAGENAME}}</nowiki></code>.
+
 
* Parameters: {{{1}}} for English, {{{2}}} for language subpages.
+
It tests the value of {{code|SUBPAGENAME}} and determines whether a page is a language subpage. If {{code|SUBPAGENAME}} is equal to the {{code|BASEPAGENAME}}, then {{tl|if lang}} will output the value of parameter 1. If {{code|SUBPAGENAME}} fails to match {{code|BASEPAGENAME}}, then {{tl|if lang}} will output {{code|/SUBPAGENAME}}.
 +
 
 +
== Usage ==
 +
By default, {{tl|if lang}} will output nothing if the page is English, and will output {{code|/ru}} or {{code|/fr}}, etc, depending on the {{code|SUBPAGENAME}}.
 +
 
 +
* For language links to work properly, {{tl|if lang}} must not have a space preceding it. For example:
 +
::{{code|1=[[Soldier&#123;&#123;if lang&#125;&#125;]]}} generates [[Soldier]] and [[Soldier/fr]], however,{{code|1=[[Soldier&#32;&#123;&#123;if lang&#125;&#125;]]}} will generate [[Soldier]] and [[Soldier_/fr]].
 +
 
 +
=== Advanced ===
 +
Outputs can be changed, however, if the use of a character other than {{code|/}} is necessary. For example:
 +
::{{tlx|if lang|2=1=|3=2=_<nowiki>{{SUBPAGENAME}}</nowiki>}} will generate "nothing" on an English page like [[Soldier]], whereas on [[Soldier/fr]], it will output {{code|_fr}}.
  
 
[[Category:Language templates|If lang]]
 
[[Category:Language templates|If lang]]
 
</noinclude>
 
</noinclude>

Revision as of 21:29, 3 September 2010

Documentation for If lang

{{if lang}} tests whether a page is a language subpage and can output specified values based on this. It can be particularly useful in creating links to language pages without disrupting links to English pages.

It tests the value of SUBPAGENAME and determines whether a page is a language subpage. If SUBPAGENAME is equal to the BASEPAGENAME, then {{if lang}} will output the value of parameter 1. If SUBPAGENAME fails to match BASEPAGENAME, then {{if lang}} will output /SUBPAGENAME.

Usage

By default, {{if lang}} will output nothing if the page is English, and will output /ru or /fr, etc, depending on the SUBPAGENAME.

  • For language links to work properly, {{if lang}} must not have a space preceding it. For example:
[[Soldier{{if lang}}]] generates Soldier and Soldier/fr, however,[[Soldier {{if lang}}]] will generate Soldier and Soldier_/fr.

Advanced

Outputs can be changed, however, if the use of a character other than / is necessary. For example:

{{if lang|1=|2=_{{SUBPAGENAME}}}} will generate "nothing" on an English page like Soldier, whereas on Soldier/fr, it will output _fr.