Template:LangSwitch/doc

From MeritBadgeDotOrg

Jump to: navigation, search

{{#invoke:Languages|autolang

 |base=TemplateBox/i18n
 |useargs=both
 |templateData={{#invoke:TemplateBox|templatedata}}
 |JSONFM={{#invoke:TemplateBox|templatedata|formatting=pretty}}
 |paramTable={{#invoke:TemplateBox|paramtable}}
 |usageSample={{#invoke:TemplateBox|usagesample}}
 |argCount={{#invoke:TemplateBox|argcount}}
 |desc={{#invoke:TemplateBox|description}}
|templateDataInfo=
{{#if:
 | [Template:LangSwitch/doc {{#if:ui-icon-help
 | 
 }}Parameter text is empty{{#if:
 | 
 }}]
 | {{#if:ui-icon-help
 | 
 }}Parameter text is empty{{#if:
 | 
 }}

}}

{{#invoke: fallback|autotranslate|base = TemplateDataInfo/i18n|lang= |1= |2= |3= |4= |5=|6= |7= |8= |9= |10= |11= |12= |13= |14= |15= }}{{#ifeq: Template:LangSwitch/doc |Template:TemplateDataInfo/i18n |}}
 |i18n-subpage={{#ifeq:  | . | Template:LangSwitch | Template:LangSwitch/i18n }}
 |usergroup=all
 |name=LangSwitch}}{{#ifeq:LangSwitch/doc|doc

| |{{#ifeq:Template|Template |{{#switch:-

 |autotranslate       =
 |switch              =
 |custommediawiki-msg =
 |mediawiki-msg       =
 |ext.translate       =
 |-                   =
 |#default            =

}}|}}}}

Contents

Examples

Without a default option

Here are a few examples showing template behavior for three languages: English, French and Corsu, which defaults to French if Corsu text is not available:

Test Code lang=en lang=fr lang=co
No en; default {{LangSwitch|fr=French|default=default}} langSwitch}} langSwitch}} langSwitch}}
No en; no default {{LangSwitch|fr=French|co=Corsu}} langSwitch}}[1] langSwitch}}[1] langSwitch}}[1]
en; default {{LangSwitch|en=English|co=Corsu|default=default}} langSwitch}} langSwitch}} langSwitch}}
en; no default {{LangSwitch|en=English|co=Corsu}} langSwitch}} langSwitch}} langSwitch}}
en; skip default {{LangSwitch|en=English|co=Corsu|default=~}} langSwitch}} langSwitch}} langSwitch}}
en; empty default {{LangSwitch|en=English|co=Corsu|default=}} langSwitch}} langSwitch}} langSwitch}}
Skip en; default {{LangSwitch|en=~|fr=French|default=default}} langSwitch}} langSwitch}} langSwitch}}
Skip en; no default {{LangSwitch|en=~|fr=French}} langSwitch}} langSwitch}} langSwitch}}
Empty en; no default {{LangSwitch|en=|fr=French}} langSwitch}} langSwitch}} langSwitch}}
en; default; skip fr {{LangSwitch|en=English|fr=~|co=Corsu|default=default}} langSwitch}} langSwitch}} langSwitch}}
en; default; empty fr {{LangSwitch|en=English|fr=|co=Corsu|default=default}} langSwitch}} langSwitch}} langSwitch}}
en; no default; skip fr {{LangSwitch|en=English|fr=~|co=Corsu}} langSwitch}} langSwitch}} langSwitch}}
Forced "lang=co" {{LangSwitch|en=English|co=Corsu|default=default|lang=co}} langSwitch}} langSwitch}} langSwitch}}

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.

Tools

If you wish to fill translations from a Wikidata item's labels, you can use the getLabelsForLangSwitch from commons-templates-from-wikidata.

Notes

  1. 1.0 1.1 1.2 would add Category:LangSwitch template without default version


Personal tools
language