Difference between revisions of "Template:If lang"

From Kerbal Space Program Wiki
Jump to: navigation, search
(Created page with "{{#switch:{{SUBPAGENAME}} | 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...")
 
(Undo revision 81480 by Gaysmustdie (talk))
(24 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{#switch:{{SUBPAGENAME}}
+
{{If lang/Detection|suffix={{#if:{{{from|}}}|{{{from}}}|{{#titleparts:{{PAGENAME}}||-1}}}}|1={{{1|{{{en|}}}}}}|2={{{2|{{{non-en|{{{lang|}}}}}}}}}|3={{{3|{{{data|}}}}}}|prefix={{{prefix|/}}}|data enabled={{{data enabled|}}}}}<noinclude>{{doc start}}
| 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}}}}}}}}}}}
+
{{tlx|if lang}} is a template that can output specified values based on whether a particular page is a language subpage or not.
| #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.
 
  
 
== Usage ==
 
== Usage ==
Line 12: Line 9:
 
! Language page result (de)
 
! Language page result (de)
 
|-
 
|-
| {{code|[[Soldier<nowiki>{{if lang}}</nowiki>]]}}
+
| <code><nowiki>[[Kerbin{{if lang}}]]</nowiki></code>
| [[Soldier]]
+
| [[Kerbin]]
| [[Soldier/de]]
+
| [[Kerbin/de]]
 
|-
 
|-
| {{code|[[Soldier <nowiki>{{if lang}}</nowiki>]]}}
+
| <code><nowiki>[[Kerbin {{if lang}}]]</nowiki></code>
| [[Soldier]]
+
| [[Kerbin]]
| [[Soldier_/de]]
+
| [[Kerbin /de]]
 
|-
 
|-
 
|}
 
|}
  
 
=== Advanced ===
 
=== Advanced ===
{{tl|if lang}} can be used in more advanced ways by specifying the English and non-English outputs.
+
{{tlx|if lang}} can be used in more advanced ways by specifying the English and non-English outputs.
  
* {{code|1=<nowiki>{{if lang | non-en = _{{SUBPAGENAME}}&nbsp;}}</nowiki>}} will generate {{code|_de}} when used on [[Equalizer/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=
 +
{{Parameter row|1|name2=en|If the language code isn't recognized returns this parameter.|Not set}}
 +
{{Parameter row|2|name2=non-en|name3=lang|If the language code is recognized returns this parameter.|{{{prefix}}} and the language code}}
 +
{{Parameter row|3|name2=data|If the suffix is recognized as a data suffix returns this parameter.|{{{prefix}}} and the data suffix}}
 +
{{Parameter row|prefix|The prefix before the language code.|<tt>/</tt>}}
 +
{{Parameter row|data enabled|If set enables the data suffix detection.|Not set/Disabled}}
 +
}}
  
 
== Languages supported ==
 
== Languages supported ==
{{tl|if lang}} recognises only the below language subpages (the same as {{tl|lang}}):
+
{{tlx|if lang}} recognizes only the below language subpages (the same as {{tlx|lang}}):
 
{| class="wikitable grid" style="margin: 1em 0;"
 
{| class="wikitable grid" style="margin: 1em 0;"
 
! Available languages
 
! 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
+
| ar, cs, da, de, es, fi, fr, he, hr, hu, it, ja, ko, nl, no, pl, pt, pt-br, ro, ru, sv, th, tr, zh-cn, zh-tw
 +
|-
 +
! Available data suffixes
 +
| Data, Box, RefFrame
 
|}  
 
|}  
  
[[Category:Language templates|If lang]]
+
[[Category:Language templates]]
 +
[[Category:Language code templates]]
 +
[[Category:Templates from the Team Fortress 2 Wiki]]
 
</noinclude>
 
</noinclude>

Revision as of 06:55, 16 April 2018

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.
#/Name Optional Description Default
1 or en Yes If the language code isn't recognized returns this parameter. Not set
2 , non-en or lang Yes If the language code is recognized returns this parameter. {{{prefix}}} and the language code
3 or data Yes If the suffix is recognized as a data suffix returns this parameter. {{{prefix}}} and the data suffix
prefix Yes The prefix before the language code. /
data enabled Yes If set enables the data suffix detection. Not set/Disabled

Languages supported

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

Available languages ar, cs, da, de, es, fi, fr, he, hr, hu, it, ja, ko, nl, no, pl, pt, pt-br, ro, ru, sv, th, tr, zh-cn, zh-tw
Available data suffixes Data, Box, RefFrame