From semantic-mediawiki.org
Jump to: navigation, search
This is a documentation subpage for Template:LangSwitch.

It contains usage information, categories and other content that is not part of the original template page.


LangSwitch provides a method to present a string of text selected from an array of many language translations in the language set in the user's preferences.

This template is based on Template:LangSwitch in WikiMedia Commons.


 {{ LangSwitch 
 | en = 
 | xx =
 | case = uc / lc / ucfirst / lcfirst
 | default =
 | lang =
 | anchor
 | nocat


  • en 
–  Text in English language. Unless default is used, this text will also be used if the languages provided do not include the language set in the user's preferences. If you do not want to show any text when the user's language is English, then use "en=~". LangSwitch templates without an en option will make an annotation above on Property:Warning in silence.
  • xx 
–  (Optional)  Translated text in language xx (The parameter name xx can be any supported language code, and you can specify as many such parameters as needed for each translated language). Use "~" if you do not want any message (or default) in some specific language.
  • case 
–  (Optional)  Format output text, with available values "uc" (convert to upper case), "lc" (convert to lower case), "ucfirst" (convert first character to upper case) and "lcfirst" (convert first character to lower case.)
  • default 
–  (Optional)  Default text in case one of the 'xx' languages is not the language of user’s preferences. By default, the English version will be shown, if provided.
Default value: {{{en|}}} (English version)
  • lang 
–  (Optional)  Language code (only needs to be provided if the language displayed is to be fixed and independent of the user’s preferences). This option is usually only used for template debugging.
Default value: Value of {{int:Lang}} (the preferred language of the visitor viewing the page).
  • anchor 
–  (Optional)  The output with English anchor. With this option user can link to the section with not only translated anchor name but also original (Engilsh) name.
  • nocat 
–  (Optional)  Suppress category tags in output. This template output one or more category tags to indicate some information, e.g. the page in which this template is embedded are plurilingual, and these category tags can make problems if they are placed in link tags. This parameter can avoid this problem.


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}} default French default
no En ; no default {{LangSwitch|fr=French|co=Corsu}} {{{ en }}} French Corsu
En; default {{LangSwitch|en=English|co=Corsu|default=default}} English default Corsu
En; no default {{LangSwitch|en=English|co=Corsu}} English English Corsu
empty En; default {{LangSwitch|en=~|fr=French|default=default}} ~ French default
empty En; no default {{LangSwitch|en=~|fr=French}} ~ French ~
En; default; empty Fr {{LangSwitch|en=English|fr=~|co=Corsu|default=default}} English ~ Corsu
En; default; empty Fr {{LangSwitch|en=English|fr=|co=Corsu|default=default}} English default Corsu
En; no default; empty Fr {{LangSwitch|en=English|fr=~|co=Corsu}} English ~ Corsu
simple case with "lang=" {{LangSwitch|en=English|fr=French|co=Corsu|default=default|lang=}} English English English

The default option is intended for providing more language independent option. For example:


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.