Help:Templates: Difference between revisions

Jump to navigation Jump to search
→‎Translating templates: More detailed instruction on translating templates
(Sectioning, clarification etc)
(→‎Translating templates: More detailed instruction on translating templates)
Line 179: Line 179:
Translating templates is different from translating normal articles.  All translations are written within one and the same template.  To do that one can use the {{tl|LangSwitch}} template.
Translating templates is different from translating normal articles.  All translations are written within one and the same template.  To do that one can use the {{tl|LangSwitch}} template.


<pre>{{LangSwitch |en=English text |de=<German text> |fr=<French text> ...}}</pre>
<nowiki>{{LangSwitch
| en = <!-- English -->
{{ The template with English contents }}
| de = <!-- German -->
{{ The template with German contents }}
| fr = <!-- French -->
{{ The template with French contents }}
}}</nowiki>


It uses the two letter language code present in all but the English page titles.  If none of the languages that have been translated to is found, a template have not yet been translated to that language and the English text will be used instead, provided it is available.
Do note that many templates are based on tables and have to start from the beginning of the line, which is accomplished like in the above example, and that inserting blank lines will alter the way the template is rendered.
 
The {{tl|LangSwitch}} template uses the two letter language code present in all but the English page titles.  If none of the languages that have been translated to is found, a template have not yet been translated to that language and the English text will be used instead, provided it is available.
 
When checking out that the language versions render as they should you can add a '''lang''' parameter to the template for debugging purposes.  Remember to remove it before saving or the template will only be showed in that language.  The below example would show the French (fr) version of the template:
 
<nowiki>{{LangSwitch
...
| lang = fr }}</nowiki>


== Advanced template editing ==
== Advanced template editing ==

Navigation menu