Difference between revisions of "Template:If lang"

From Kerbal Space Program Wiki
Jump to: navigation, search
(*maybe also be able in category ns;)
m (+parameter table; +prefix;)
Line 1: Line 1:
 
{{#switch:{{#if:{{{from|}}}|{{{from}}}|{{#titleparts:{{PAGENAME}}||-1}}}}
 
{{#switch:{{#if:{{{from|}}}|{{{from}}}|{{#titleparts:{{PAGENAME}}||-1}}}}
| ar|cs|da|de|es|fi|fr|hu|it|ja|ko|nl|no|pl|pt|pt-br|ro|ru|sv|tr|zh-cn|zh-tw = {{{2|{{{non-en|{{{lang|/{{#titleparts:{{PAGENAME}}||-1}}}}}}}}}}}
+
| ar|cs|da|de|es|fi|fr|hu|it|ja|ko|nl|no|pl|pt|pt-br|ro|ru|sv|tr|zh-cn|zh-tw = {{{2|{{{non-en|{{{lang|{{{prefix|/}}}{{#titleparts:{{PAGENAME}}||-1}}}}}}}}}}}
 
| #default = {{{1|{{{en|}}}}}}
 
| #default = {{{1|{{{en|}}}}}}
 
}}<noinclude>{{doc start}}
 
}}<noinclude>{{doc start}}
Line 27: Line 27:
 
* <code><nowiki>{{if lang|non-en=_{{SUBPAGENAME}}}}</nowiki></code> will generate <code>_de</code> when used on [[Gilly/de]].
 
* <code><nowiki>{{if lang|non-en=_{{SUBPAGENAME}}}}</nowiki></code> will generate <code>_de</code> when used on [[Gilly/de]].
 
** This example is used in [[:Category:Infobox templates|infobox templates]] to display item name images in the correct language.
 
** This example is used in [[:Category:Infobox templates|infobox templates]] to display item name images in the correct language.
 +
 +
{{Parameter Table|name=both|parameters=
 +
{{ParameterRow|1|name2=en|If the language code isn't recognized returns this parameter.|Not set}}
 +
{{ParameterRow|2|name2=non-en|name3=lang|If the language code is recognized returns this parameter.|{{{prefix}}} and the language code}}
 +
{{ParameterRow|prefix|The prefix before the language code.|<tt>/</tt>}}
 +
}}
  
 
== Languages supported ==
 
== Languages supported ==

Revision as of 19:41, 10 June 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)
[[Kerbin{{if lang}}]] Kerbin Kerbin/de
[[Kerbin {{if lang}}]] Kerbin Kerbin /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 Gilly/de.
    • This example is used in infobox templates to display item name images in the correct language.

Template:Parameter Table

Languages supported

{{if lang}} recognizes 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-cn, zh-tw