From The Mana World
(added some information)
m (→‎Translating templates: add some other languages)
Line 95: Line 95:
  <nowiki>{{switch: {{NAMESPACE}}
  <nowiki>{{switch: {{NAMESPACE}}
  | De = <!-- German translation here -->
  | De = <!-- German translation here -->
  | Es = <!-- Spanish translation here -->
  | Cz = <!-- Czech translation here -->
  | Fr = <!-- French translation here -->
  | Fr = <!-- French translation here -->
  | Zh = <!-- Traditional Chinese translation here -->
| It = <!-- Italian translation here -->
| Pl = <!-- Polish translation here -->
| Pt = <!-- Portugues translation here -->
| Ru = <!-- Russian translation here -->
  | Zh = <!-- Traditionnal Chinese translation here -->
  | #default = Original English text
  | #default = Original English text
}}</nowiki>
}}</nowiki>

Revision as of 10:06, 11 March 2015



Description

A template is a wiki page created to be included in other pages. Templates usually contain repetitive material that might need to show up on any number of articles or pages. They are commonly used for boilerplate messages, standard warnings or notices, infoboxes, navigational boxes, and similar purposes.


Usage

Existing templates can be used by adding them with {{Template name}}. For instance {{i18n}} which is the language selection template at the top of this page.

If you want to place a link to a template this works just like other wiki links. Remember to include "Template:". Using the language selection template as example again this would make [[Template:i18n]] -> Template:i18n.


Template categories

Our wiki keeps categories short and simple so we only use a few ones:

Template Category Usage
General Template General templates for this wiki.
Content Template Templates used for pages about content that's already in game.
Development Template Templates used for development-relevant pages.
Translation Template Templates with translations.
Template documentation Documentation about how a certain template works.

See also:


Creating a template

While creating a template itself works similar as creating new pages for the wiki (see Help:Editing) there are a few important points different.

A template is built like this:

Template code goes here

<noinclude>
{{:Template:{{PAGENAME}}/doc}}     <!-- this is to include documentation in this page, without transcluding it in the page where template is used -->
[[Category:General Template]]     <!-- this is to categorize the template. It will not be transcluded in the page where template is used -->
</noinclude>


"Template code goes here" is where you create the template itself. Inside the <noinclude></noinclude> tags you have to place the documentation (see below) and the category for the template.


If you create a new template please always categorize it the same way as listed above and do not create a new category unless you discussed it with a Wiki Administrator or Bureaucrat.


Note: Remember to always put the <noinclude></noinclude> tags around the documentation and category, otherwise all pages using the template will be categorized and include the documentation!


Documentation

Templates need documentations about how to use them. Besides creating the template itself you need to create a new page about its documentation which should be called "Template:template name/doc".

See following example:


[[File:50px-Template-info.png]] '''Template documentation:'''

Description about when to use the template.


'''Usage:'''

Copy the following code into your page:

<dl style="display:inline-block; padding-left:.75em; margin-left:0;">
 <nowiki>{{Templatename}}</nowiki>
</dl>
<noinclude>[[Category:Template documentation]]</noinclude>


It will then look like this:


50px-Template-info.png Template documentation:

Description about when to use the template.


Usage:

Copy the following code into your page:

{{Template name}}


Translating templates

Most templates are translatable within the original template, meaning you can put translations in the source of them instead of creating a new translated template page. "#switch: {{NAMESPACE}}" allows to create a switch. Depending on which translation page you are at, the variable {{NAMESPACE}} will display the corresponding content. The source looks like this:

{{switch: {{NAMESPACE}} | De = <!-- German translation here --> | Cz = <!-- Czech translation here --> | Fr = <!-- French translation here --> | It = <!-- Italian translation here --> | Pl = <!-- Polish translation here --> | Pt = <!-- Portugues translation here --> | Ru = <!-- Russian translation here --> | Zh = <!-- Traditionnal Chinese translation here --> | #default = Original English text }}

So when you are at the German (De) translation page using a template with this source, it will say "German translation". On the Spanish (Es) translation page it will say "Spanish translation" and so on. You might want to check other templates to understand better. See Category Translation Template.


However, not every template is translatable in this fashion. Those need new translated templates, just like translation pages. Please name them like this:

"Template:.Fr:Template name", for usage it's "{{.Fr:Template name}}".

Wikipedia templates

Although some templates on Wikipedia sound interesting, most of them are not suitable for TMW wiki as Lua programming language is not available here. Also, Wikipedia templates invoked modules, which are pages stored some Lua source code.