Diferencia entre revisiones de «Usuario:Stargazer/Template Guide»

De La Coppermind
Ir a la navegación Ir a la búsqueda
(Recreate following database overwrite)
 
m
Línea 1: Línea 1:
If you're going to be working with templates, I recommend going to the [[Especial:Preferencias#mw-prefsection-gadgets "Gadgets" section of your Preferences]] and turning on the syntax highlighter; it makes it a bit easier to tell what's going on.
+
If you're going to be working with templates, I recommend going to the [[Especial:Preferencias#mw-prefsection-gadgets|"Gadgets" section of your Preferences]] and turning on the syntax highlighter; it makes it a bit easier to tell what's going on.
   
 
== Parts of a Template ==
 
== Parts of a Template ==

Revisión del 20:49 6 ene 2022

If you're going to be working with templates, I recommend going to the "Gadgets" section of your Preferences and turning on the syntax highlighter; it makes it a bit easier to tell what's going on.

Parts of a Template

Broadly speaking, templates will be composed of four parts:

  1. Words that are part of the template output and are hard-coded into the template (i.e., they cannot be changed when you use the template). For example, the names of the rows on infoboxes (like "World," "Universe," "Featured in," etc.) fall into this category.
  2. Parameters, which allow you to input information when using a template. In MediaWiki syntax, parameters are designated in a template with three curly brackets. Parameters can be either named or unnamed. In a template, named parameters will look like {{{name}}}. If a parameter is not named, MediaWiki identifies it with a number based on the order in which it is passed when the template is used, so unnamed parameters will look like {{{1}}}. Some parameters may also have a pipe (|) immediately after their name or number. Everything between the pipe and the ending curly braces is a default value; if, when the template is used, the editor doesn't specify a value for a parameter with a default value, the default value will be used instead. Some default values are nothing.
    • Named parameters can be translated (and I'm sure you'll want to), though be aware that changing a parameter's name will mean that any page using the old parameter name won't work quite right anymore. If you get a bit of a head start on translating at least the main templates, you can probably just translate the parameters, fix their names on a content page to double check that they everything's working as you intended, and then let the rest stay broken until someone gets around to translating the content of the page.
    • Unnamed parameters shouldn't need to be translated.
    • Default values are generally hard-coded words, as discussed above.
  3. Most of the remainder of a template will be MediaWiki syntax. This includes parser functions like {{#if:...}} and {{#switch:...}}, partial transclusion tags like <noinclude>, instructions for creating a table (markup between a {| and a |}), and calls to other templates. Most of these, as far as I know, will not be translated. Calls to other templates should probably be updated when the parameters and name of the template being called are translated, so that they aren't broken until someone gets around to the template making the call.
  4. Comments are something of a special case. Anything that looks like <!-- comment text here --> won't show up when the template is used. This is often used to space out parts of the template to make it easier to read and, occasionally, to leave note for other editors about how a template works. Any text in a comment can be translated without concern.

Partial transclusion

By default, when you call a template, MediaWiki will import all of the contents of the template page. This usually is not desirable. Therefore, there are three partial transclusion tags that tell MediaWiki what parts to use when:

  • <noinclude>: This tag tells MediaWiki not to include anything after the tag when the template is used on a page. Usually, there will only be one <noinclude> tag in a template. Everything before the tag will be template code, everything after it will be documentation telling editors how the template works. So, only the parts before the <noinclude> tag need to be translated for the template to be "translated," though you'll want to translate the documentation as well, at least at some point.

The other partial transclusion tags are less relevant to translation:

  • <includeonly>: This tag tells MediaWiki to only include the content that follows when the template is called on another page, not the template page itself. For example, the {{character}} infobox automatically adds pages to Categoría: Characters. However, we don't want the template itself to show up in that category. So, the infobox template has the line <includeonly>[[Category: Characters]]</includeonly> (well, there are a few other things between the <includeonly> tags, but you get the point).
  • <onlyinclude>: This tag is used much less frequently. It tells MediaWiki that only the content that follows should be used when the template is called on another page (i.e., it effectively makes it as though the rest of the page has been subject to a <noinclude> tag)