Template:LangSwitch/doc
This template uses Lua: |
- TemplateData
TemplateData is a way to store information about template parameters (the description of those and of the whole template) for both humans and machines. It is used by VisualEditor and possibly other tools like Upload Wizard.
Existing template documentation
At Wikimedia Commons, it is recommended to use {{TemplateBox}} with either useTemplateData=1
or useTemplateData=only
on the /doc
subpage and transcluding it with {{Documentation}} into the template. <nowiki>
-tags can be wrapped around the arguments, if required, to avoid templates being expanded.
Newly created template documentation and imports
Another option, especially for imported templates, or for users with JSON experience, is placing raw <templatedata>-tags into the Wikitext of the template, as described in various Wikipediae.
Wikipedia's help about TemplateData • Commons-specific information
Examples
Without a default option
Here are a few examples showing template behavior for three languages: English, Italian and Corsu, which defaults to Italian if Corsu text is not available:
Test | Code | lang=en | lang=it | lang=co |
---|---|---|---|---|
No en; default | {{LangSwitch|it=Italian|default=default}}
|
default | Italian | Italian |
No en; no default | {{LangSwitch|it=Italian|co=Corsu}}
|
LangSwitch Error: no default[1] | LangSwitch Error: no default[1] | LangSwitch Error: no default[1] |
en; default | {{LangSwitch|en=English|co=Corsu|default=default}}
|
English | default | Corsu |
en; no default | {{LangSwitch|en=English|co=Corsu}}
|
English | English | Corsu |
en; skip default | {{LangSwitch|en=English|co=Corsu|default=~}}
|
English | Corsu | |
en; empty default | {{LangSwitch|en=English|co=Corsu|default=}}
|
English | English | Corsu |
Skip en; default | {{LangSwitch|en=~|it=Italian|default=default}}
|
Italian | Italian | |
Skip en; no default | {{LangSwitch|en=~|it=Italian}}
|
Italian | Italian | |
Empty en; no default | {{LangSwitch|en=|it=Italian}}
|
LangSwitch Error: no default | LangSwitch Error: no default | LangSwitch Error: no default |
en; default; skip it | {{LangSwitch|en=English|it=~|co=Corsu|default=default}}
|
English | Corsu | |
en; default; empty it | {{LangSwitch|en=English|it=|co=Corsu|default=default}}
|
English | default | Corsu |
en; no default; skip it | {{LangSwitch|en=English|it=~|co=Corsu}}
|
English | Corsu | |
Forced "lang=co" | {{LangSwitch|en=English|co=Corsu|default=default|lang=co}}
|
Corsu | Corsu | Corsu |
Default option
The default option is intended for providing more language independent option. For example:
{{LangSwitch
|de=[[:de:Warschau|Warschau]]
|en=[[:en:Warsaw|Warsaw]]
|fr=[[:fr:Varsovie|Varsovie]]
|ja=[[:ja:ワルシャワ|ワルシャワ]]
|pl=[[:pl:Warszawa|Warszawa]]
|default=[[d:Q270]]
}}
will provide link to Wikipedia articles in case one of the languages provided matches user's language but will link to Commons gallery page (Warsaw) if any other language is used.
Warning
Notes
- ↑ a b c would add Category:LangSwitch template without default version