This template is protected from editing.

Difference between revisions of "Template:If lang"

From Team Fortress Wiki
Jump to: navigation, search
(better documentation)
(ok I lied, there is no greek.)
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{#ifeq:{{SUBPAGENAME}}|{{BASEPAGENAME}}|{{{1|}}}|{{{2|/{{SUBPAGENAME}}}}}|}}<noinclude>{{doc begin}}
+
{{#switch:{{SUBPAGENAME}}
{{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.
+
| ar|cs|da|de|es|fi|fr|hu|it|ja|ko|nl|no|pl|pt|pt-br|ro|ru|sv|tr|zh-hans|zh-hant = {{{2|{{{non-en|{{{lang|/{{SUBPAGENAME}}}}}}}}}}}
 +
| #default = {{{1|{{{en|}}}}}}
 +
}}<noinclude>{{doc begin}}
 +
{{tl|if lang}} is a template that can output specified values based on whether a particular page is a language subpage or not.
  
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 ==
 +
{| class="wikitable grid" width="60%"
 +
|-
 +
! Code
 +
! English page result
 +
! Language page result (de)
 +
|-
 +
| {{code|[[Soldier<nowiki>{{if lang}}</nowiki>]]}}
 +
| [[Soldier]]
 +
| [[Soldier/de]]
 +
|-
 +
| {{code|[[Soldier <nowiki>{{if lang}}</nowiki>]]}}
 +
| [[Soldier]]
 +
| [[Soldier_/de]]
 +
|-
 +
|}
  
== Usage ==
+
=== Advanced ===
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}}.  
+
{{tl|if lang}} can be used in more advanced ways by specifying the English and non-English outputs.
  
* For language links to work properly, {{tl|if lang}} must not have a space preceding it. For example:
+
* {{code|1=<nowiki>{{if lang | non-en = _{{SUBPAGENAME}}&nbsp;}}</nowiki>}} will generate {{code|_de}} when used on [[Equalizer/de]].
::{{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]].
+
** This example is used in [[:Category:Infobox templates|infobox templates]] to display item name images in the correct language.
  
=== Advanced ===
+
== Languages supported ==
Outputs can be changed, however, if the use of a character other than {{code|/}} is necessary. For example:
+
{{tl|if lang}} recognises only the below language subpages (the same as {{tl|lang}}):
::{{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}}.
+
{| class="wikitable grid" style="margin: 1em 0;"
 +
! Available languages
 +
| ar, cs, da, de, es, fi, fr, hu, it, ja, ko, nl, no, pl, pt, pt-br, ro, ru, sv, tr, zh-hans, zh-hant
 +
|}  
  
 
[[Category:Language templates|If lang]]
 
[[Category:Language templates|If lang]]
 
</noinclude>
 
</noinclude>

Revision as of 21:07, 31 October 2013

Documentation for If lang

{{if lang}} is a template that can output specified values based on whether a particular page is a language subpage or not.

Usage

Code English page result Language page result (de)
[[Soldier{{if lang}}]] Soldier Soldier/de
[[Soldier {{if lang}}]] Soldier Soldier_/de

Advanced

{{if lang}} can be used in more advanced ways by specifying the English and non-English outputs.

  • {{if lang | non-en = _{{SUBPAGENAME}} }} will generate _de when used on Equalizer/de.
    • This example is used in infobox templates to display item name images in the correct language.

Languages supported

{{if lang}} recognises only the below language subpages (the same as {{lang}}):

Available languages ar, cs, da, de, es, fi, fr, hu, it, ja, ko, nl, no, pl, pt, pt-br, ro, ru, sv, tr, zh-hans, zh-hant