Note: This template is used on a lot of pages. In order not to put too much load on the servers, edits should be kept to a bare minimum. Please discuss proposed changes on the talk page first.
Afterwards, changes can initially be done at and tested with Template:LangSwitch/sandbox​.
  • Editing a template causes all pages that use the template to be re-rendered. If the template is used often, this can put a lot of load on the servers since it fills up the job queue.
  • Keep in mind that templates that are used on file description pages also show up on other wikis.
  • This page has been protected from editing to prevent vandalism. Only administrators can edit it. Get their attention by placing {{Edit protected}} at the talk page.
This template has been protected from editing to prevent vandalism.
Please discuss changes on the talk page or request unprotection.
Template documentation​view · edit · history ·purge ]
This documentation is transcluded from Template:LangSwitch/doc.
Uses Lua:
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 or the most appropriate fallback language.
The template automatically sets the following categories: Category:Internationalization templates using LangSwitch
 |en =
 |xx =
 |default =
Template parameters
 Parameter text is empty
<templatedata>JSON</templatedata> ./. {{TemplateBox}}
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.
-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
-tags into the Wikitext of the template, as described in various Wikipediae.
There is an ongoing discussion about that matter. Feel invited to comment if you are experienced in either way, your time permits and if you like to share your opinion or to make a suggestion.
Wikipedia's help about TemplateDataCommons-specific information
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 or the most appropriate fallback language.
Template parameters
This template prefers block formatting of parameters.
Default Fallbackdefault
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.
{{{en|}}} (English version)
EnglishenText in English language. Unless ''default'' option 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=~".Stringrequired
Language Codelang
Language code (only needs to be provided if the language displayed is to be fixed and independent of the user’s preferences). {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} is not necessary.
Value of {{int:Lang}} (the preferred language of the visitor viewing the page).
No Category?nocat"nocat=1" will overwrite the default behavior of tracking uses without "en" or "default" options.Stringoptional
xxTranslated text in language ''xx'' (the parameter name ''xx'' can be any supported language code (from BCP 47/ISO 639-1), and you can specify as many such parameters as needed for each translated language). Use "xx=~" if you do not want any message (or default) in some specific language. You can map multiple languages to a single text by using "{{LangSwitch|xx/yy/zz=text}}" which is equivalent to "{{LangSwitch|xx=text|yy=text|zz=text}}" .Stringoptional
Additional information
The template is intended to be used in the following namespaces: no namespace specified
The template is intended to be used by the following user groups: all users
Relies on:
See also
This template is not intended to be localized.
Help for choosing the right template for your use case:
I18n templates:{{Multilingual description|lang=
Recommended use atCategories, galleriesFile description pages (deprecated, can be safely replaced by {{Multilingual description}})Small templates, whenever the previous options are not suitable (removes the visual indication of the language before each translated text)Data tables with translated cells or larger templates, when used on pages that do not have language subpages (e.g. not having Main page/en, Main page/de) and where the language displayed will be automatically determined by the language set in user preferencesData tables with translated cells or larger templates, when used on pages that do have language subpages; most of the time these will be pages prepared with the Translate Extension
Requires JavaScript enabled for foldingYesNo
Folding can be disabled by userYesNo
Folding is done server-sideNoYes
Folding when at least n languages are provided1 (all translations are shown without folding if the preferred language selected by the user has no matching translation)41
Detection of duplicate, incorrect, or unsupported language codesYesNoYesDuplicate language codes are impossible by design. Incorrect or unsupported codes are never displayed, but not reported. The Translate extension's interface (if it's used on the translation subpages) doesn't let the user create translations with invalid codes, but other methods (e.g. entering the translation's URL directly) allow it without any warning.
Allows the same translation to be used for several languagesYesNoYes
Supports language fallbacksNoYesNo
Collation order of languages (when not folded)Consistent order by native language name, languages grouped by script:
  • LTR scripts: Latin, Latin or Cyrillic, Cyrillic, Greek, other simple LTR alphabets (Armenian, Georgian, etc.), abugidas (North Indian, South Indian, other South-East Asian, etc.), syllabaries (European, American, African, Asian), Korean alphabets (basic Jamos, Hangul including some sinograms), Japanese syllabaries (including some sinograms), sinograms (including some syllabaries)
  • RTL scripts: Hebrew, Arabic, other RTL abjads (Divehi, etc.), RTL syllabaries (N'ko)
As provided by the user in the wikitext (any inconsistent order may be difficult to lookup visually)N/A
Search indexing issuesNo (all translations are included on the same page, however search results may be less relevant with many languages mixed)Yes (may not index all languages depending on search engines, unless there's a list of links for visiting other languages)Partially (where used; language subpages of templates are indexed)No (translated pages should include a <languages/> navigation bar for visiting other languages)
Page size issuesYes (may exhaust size or time limits in the wiki parser if many languages are included; larger pages to download for all visitors; slower navigation for visitors with slow Internet access; may be costly for visitors with limited data plans)No (only the content for the selected language or a suitable fallback language is present in the generated page)
Contains expensive parser functionsNoYes, checks for several translations along the fallback chain until finds a suitableYes, 2–4 checks per call
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:
No en; default{{​LangSwitch​|it=Italian|default=default}}defaultItalianItalian
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}}EnglishdefaultCorsu
en; no default{{​LangSwitch​|en=English|co=Corsu}}EnglishEnglishCorsu
en; skip default{{​LangSwitch​|en=English|co=Corsu|default=~}}EnglishCorsu
en; empty default{{​LangSwitch​|en=English|co=Corsu|default=}}EnglishEnglishCorsu
Skip en; default{{​LangSwitch​|en=~|it=Italian|default=default}}ItalianItalian
Skip en; no default{{​LangSwitch​|en=~|it=Italian}}ItalianItalian
Empty en; no default{{​LangSwitch​|en=|it=Italian}}LangSwitch Error: no defaultItalianLangSwitch Error: no default
en; default; skip it{{​LangSwitch​|en=English|it=~|co=Corsu|default=default}}EnglishCorsu
en; default; empty it{{​LangSwitch​|en=English|it=|co=Corsu|default=default}}EnglishdefaultCorsu
en; no default; skip it{{​LangSwitch​|en=English|it=~|co=Corsu}}EnglishCorsu
Forced "lang=co"{{​LangSwitch​|en=English|co=Corsu|default=default|lang=co}}CorsuCorsuCorsu
Default option
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.
This template SHOULD NOT be used out of software interface purpose. For example it SHOULD NOT be used to manage multilingual description of the subject of a media or a category or whatsoever.
a b c would add Category:LangSwitch template without default version

Last edited on 4 June 2018, at 12:13
Wikimedia Commons
Files are available under licenses specified on their description page. All structured data from the file namespace is available under the Creative Commons CC0 License; all unstructured text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and the Privacy Policy.
Privacy policy
Terms of Use
 Home Random  Nearby  Log in  Settings  Donate  About Wikimedia Commons  Disclaimers