Difference between revisions of "Template:Lang"

From Valve Developer Community
Jump to: navigation, search
m
m (add noline and notitle parameters)
Line 4: Line 4:
 
Unlike otherlang2, this template requires an unnamed parameter to be defined to work. The contents of it should be the full name of the page the template is being applied on, including namespaces such as '''Help:'''. It should not include any language suffixes, however, such as ''':ru'''. Capitalization matters, even on the first letter of the page name! Underscores must be replaced with spaces. <code>ai_changehintgroup</code> must be written as <code>Ai changehintgroup</code>.
 
Unlike otherlang2, this template requires an unnamed parameter to be defined to work. The contents of it should be the full name of the page the template is being applied on, including namespaces such as '''Help:'''. It should not include any language suffixes, however, such as ''':ru'''. Capitalization matters, even on the first letter of the page name! Underscores must be replaced with spaces. <code>ai_changehintgroup</code> must be written as <code>Ai changehintgroup</code>.
  
The <code>title</code> parameter can be used to change the text of the page titlebar (logically, into the text that should be displayed for the language of the page).
+
*The <code>title</code> parameter can be used to change the text of the page titlebar (logically, into the text that should be displayed for the language of the page).
{{Warning|on some pages you may receive this error: '''Warning''': Display title "env_cubemap" overrides earlier display title <nowiki>"<code>Env cubemap</code>"</nowiki>. This can be due to the fact that the page uses a different template in which the page title is set.}}
 
  
The <code>noborder</code> parameter can be set to <code>1</code> to hide the border around icons. If you don't plan on using it, don't bother defining it.
+
*There is also a <code>notitle</code> parameter so that the page title is not displayed - '''<nowiki>{{lang|Template:Lang|notitle=1}}</nowiki>'''.
 +
{{Warning|on some pages you may receive this error: '''Warning''': Display title "env_cubemap" overrides earlier display title <nowiki>"<code>Env cubemap</code>"</nowiki>. This can be due to the fact that the page uses a different template in which the page title is set.}}
 +
{{Warning|do not use <code>title</code> and <code>notitle</code> together, otherwise you will have exactly the same error as the previous one.}}
 +
 
 +
*The <code>noborder</code> parameter can be set to <code>1</code> to hide the border around icons. If you don't plan on using it, don't bother defining it.
 +
 
 +
*The <code>noline</code> parameter can be set to <code>1</code> to hide the line under the title. If you don't plan on using it, don't bother defining it.
  
 
Here's an example for a hypothetical Spanish page called '''Category:Hello:es''':
 
Here's an example for a hypothetical Spanish page called '''Category:Hello:es''':
 
<pre>{{lang|Category:Hello|title=Categoría:Hola|noborder=1}}</pre>
 
<pre>{{lang|Category:Hello|title=Categoría:Hola|noborder=1}}</pre>
 
Here's one more example for a Russian page called '''Your_First_Map:ru''':
 
<pre>{{lang|Your First Map|title=Ваша первая карта}}</pre>
 
  
 
This will add icons for all the versions of this page in different languages. It will also change the displayed title to a Spanish version of the name, and hide the icon borders.
 
This will add icons for all the versions of this page in different languages. It will also change the displayed title to a Spanish version of the name, and hide the icon borders.
Line 68: Line 70:
 
|Hebrew                ||Page_name:he      ||[[File:He.png]]
 
|Hebrew                ||Page_name:he      ||[[File:He.png]]
 
|}
 
|}
Also, this template automatically adds a page language category at the bottom of the page.
+
*Also, this template automatically adds a page language category at the bottom of the page.
  
 
{{TODO}} simplify code for <nowiki><mark></nowiki> tags
 
{{TODO}} simplify code for <nowiki><mark></nowiki> tags
Line 80: Line 82:
 
[X language suffix]: JUST a language suffix, which is different for every language
 
[X language suffix]: JUST a language suffix, which is different for every language
  
title
+
removes the line under the title
-->{{#if: {{{title|}}} | {{DISPLAYTITLE:{{{title}}}}} }}<!--
+
-->{{#if: {{{noline|}}} | <div style="position:relative;top:-26px;margin-bottom:-40px;float:right;padding:2px;line-height:11px;background:#262626; margin-top:5px;border:0;width:100%">&nbsp;</div> }}<!--
  
 
html to make the buttons appear in the header space
 
html to make the buttons appear in the header space
Line 88: Line 90:
 
taking away of the icon borders
 
taking away of the icon borders
 
-->{{#if: {{{noborder|}}} | margin-top:5px;border:0; | border:1px solid #65635F;border-bottom:0;}}"><!--
 
-->{{#if: {{{noborder|}}} | margin-top:5px;border:0; | border:1px solid #65635F;border-bottom:0;}}"><!--
 +
 +
title
 +
-->{{#if: {{{title|}}} | {{DISPLAYTITLE:{{{title}}}}} }}<!--
 +
 +
No title
 +
-->{{#if: {{{notitle|}}} | {{DISPLAYTITLE:<span style="display:none">{{FULLPAGENAME}}</span>}} }}<!--
  
 
English
 
English

Revision as of 06:55, 24 May 2021

 English 

This template is an improved version of Template:Otherlang2. It retains all the functionality, adds Hebrew properly, and automatically detects which languages a page has been translated into. It works on English and non-English pages, with or without namespaces. Otherlang2 may still be used, in the rare case that a translated page does not follow the wiki's standard method for translated page titles.

Unlike otherlang2, this template requires an unnamed parameter to be defined to work. The contents of it should be the full name of the page the template is being applied on, including namespaces such as Help:. It should not include any language suffixes, however, such as :ru. Capitalization matters, even on the first letter of the page name! Underscores must be replaced with spaces. ai_changehintgroup must be written as Ai changehintgroup.

  • The title parameter can be used to change the text of the page titlebar (logically, into the text that should be displayed for the language of the page).
  • There is also a notitle parameter so that the page title is not displayed - {{lang|Template:Lang|notitle=1}}.
Warning.png Warning: on some pages you may receive this error: Warning: Display title "env_cubemap" overrides earlier display title "<code>Env cubemap</code>". This can be due to the fact that the page uses a different template in which the page title is set.
Warning.png Warning: do not use title and notitle together, otherwise you will have exactly the same error as the previous one.
  • The noborder parameter can be set to 1 to hide the border around icons. If you don't plan on using it, don't bother defining it.
  • The noline parameter can be set to 1 to hide the line under the title. If you don't plan on using it, don't bother defining it.

Here's an example for a hypothetical Spanish page called Category:Hello:es:

{{lang|Category:Hello|title=Categoría:Hola|noborder=1}}

This will add icons for all the versions of this page in different languages. It will also change the displayed title to a Spanish version of the name, and hide the icon borders.


Currently supported languages:

Language Page name Icon
English Page_name En.png
Catalan Page_name:ca Ca.png
Czech Page_name:cs Cs.png
German Page_name:de De.png
Spanish Page_name:es Es.png
French Page_name:fr Fr.png
Hungarian Page_name:hu Hu.png
Italian Page_name:it It.png
Dutch Page_name:nl Nl.png
Norwegian Page_name:no No.png
Polish Page_name:pl Pl.png
Portuguese Page_name:pt Pt.png
Portuguese (Brazilian) Page_name:pt-br Pt-br.png
Russian Page_name:ru Ru.png
Ukrainian Page_name:ua Ua.png
Swedish Page_name:sv Sv.png
Turkish Page_name:tr Tr.png
Japanese Page_name:jp Jp.png
Chinese (PRC) Page_name:zh-cn Cn.png
Chinese (Taiwan) Page_name:zh-tw Tw.png
Korean Page_name:ko Ko.png
Georgian Page_name:ka Ka.png
Hebrew Page_name:he He.png
  • Also, this template automatically adds a page language category at the bottom of the page.

To do simplify code for <mark> tags


For information on how the template detects other languages, view this page's source code.