Yugipedia:Template parameter names

From Yugipedia
Jump to: navigation, search

Ideally template pages should use consistent naming for their parameters. This page lists a set of standard parameter names, and guidelines for naming new parameters, that editors should try to follow when creating new templates. Over time, existing templates will be updated to follow these guidelines as well.

General[edit]

Characters[edit]

MediaWiki allows almost any character to be used in a parameter name. However, for the purposes of this wiki, it is preferred to restrict the characters used in parameter names to numbers, letters, underscores (_), and dashes (-). In particular, punctuation and whitespace should be avoided, and non-basic-Latin characters (including ligatures and characters with diacritic marks) should not be used. This helps ensure that all editors can enter parameter names directly from their keyboards with a minimum of difficulty.

Parameter names should begin and end with a number or letter, not with an underscore or dash. In addition, to avoid being treated as unnamed parameters, parameter names must contain at least one non-numeric character.

Casing[edit]

Generally, parameter names should always be lowercase. This eliminates confusion on how a parameter name is capitalized.

Language[edit]

Parameters should be named using English words and phrases. For instance, a Spanish name parameter should be named es_name instead of nombre. Exceptions should be made for loanwords as appropriate and sensible (e.g. romaji instead of ja_romanized or similar).

Separating parts/words[edit]

Parameter names often consist of more than one part or word (for instance, a parameter for a Italian name would have the parts it and name); these parts should generally be separated by an underscore (it_name) instead of a dash, space, or capitalization. Such separations should consist of a single underscore.

English and Japanese parameters[edit]

Because of their ubiquity, parameters for English and Japanese information are usually treated slightly differently from other parameters. English parameters in particular should normally omit the otherwise-standard language code (e.g. name instead of en_name, though only when needed), and certain Japanese parameters should do the same (usually those parameters with Japanese loanwords for names, e.g. romaji instead of ja_romaji or ja_romanized).

Other language parameters may rarely also do so, e.g. a parameter for a Chinese pinyin name can be called pinyin instead of zh_pinyin or zh_romanized (zh_romanized is especially bad in this case, since there are multiple standard transliteration/romanization systems for Chinese which are in widespread use).

Multiples of a parameter[edit]

In cases where multiples of a nonspecific parameter must be supported (most often multiple name parameters for a given language), the first parameter should be named as normal, and the subsequent multiples should use that name followed by sequential numbering starting at 2. So, for example, three French name parameters in a template should be named fr_name, fr_name_2, and fr_name_3.

This doesn't apply if the multiples are more specific than the original; Portuguese name parameters for general use, manga names, and anime names would, for instance, be named pt_name, pt_manga_name, and pt_anime_name, respectively.

Languages and regions[edit]

Many items will have different parameters for different languages or regions. Typically these parameters will begin with an abbreviation for the language or region.

Most languages should use their ISO 639-1 code. The appropriate codes for the most widely-used languages on this wiki are as follows:

  • en - English
  • ja - Japanese
  • zh - Chinese
  • ko - Korean
  • fr - French
  • de - German
  • it - Italian
  • pt - Portuguese
  • es - Spanish

Using the following two-letter codes (which may or may not be valid ISO 639-1 codes) is generally discouraged:

  • jp (commonly used on-wiki for Japanese)
  • kr (commonly used on-wiki for Korean)
  • ch (commonly used on-wiki for Chinese)

Other abbreviations include:

  • ae - Asian-English
  • na - North American English
  • eu - European English
  • oc - Oceanic English
  • au - Australian English (this and oc should not be used for the same type of information in the same template)
  • fc - French Canadian
  • es-lat - Latin American Spanish
  • romaji - Japanese in rōmaji
  • hanja - Korean in Hanja
  • ko_rr - Korean in the revised romanization
  • pinyin - Chinese in pinyin

Names should use the region or language code followed by name, e.g. fr_name for French names.

Parameters for translated names should be offered for each supported language, using trans instead of name, e.g. fr_trans for translated French names.

For languages which use non-Latin alphabets, if no specific romanization parameter is listed above (e.g. there is none listed for Greek or Arabic), parameters for romanized names should be offered using romanized instead of name/trans, e.g. el_romanized for romanized Greek names.

The above three guidelines should be generalized to non-name parameters where necessary, e.g. lore parameters, though in these cases the second parameter name part should be preserved in trans and romanized parameters, e.g. Russian would have the following lore parameters: ru_lore, ru_lore_trans, and ru_lore_romanized.

Release dates should use the region or language code and release_date. e.g. oc_release_date for Oceanic English release dates.

Media[edit]

Many items will have different parameters for different media. These parameters should include an abbreviation for these media. Video games use the set id from their promotional cards where they exist (a complete list can be found at Yugipedia:Image policy#Naming video game images). Other media include:

These prefixes can be freely mixed with language and region prefixes, in which case the language prefix is placed first in the parameter name, e.g. a parameter for a German manga lore would be named de_manga_lore.

A parameter for an appearance in a particular medium should use appears_in followed by the medium type, e.g. appears_in_anime.

Other[edit]

  • name - Used as an override for {{PAGENAME}}, when it won't always yield the desired name. Note that templates should automatically strip parenthesized parts of page names instead of relying on this parameter (but still provide the override for more complex cases); this can be accomplished with the code {{ #if: {{{name|}}} | {{{name}}} | {{ #explode: {{PAGENAME}} | ( }} }}.

Images[edit]

  • image - Name of an image to be used. This excludes the "File:" prefix and wiki markup. e.g. Example.jpg, rather than [[File:Example.jpg]]. Templates can silently support file names with or without the prefix ("silently" meaning the support is undocumented) with the code [[File:{{PAGENAME:{{{image}}}}}]], adapted as necessary for the particular use.
  • width - Width of an image in pixels. When this parameter is provided, its input should always be checked for validity with the following code (adapted as necessary for the particular use): {{ #if: {{{width|}}} | {{ #iferror: {{ #expr: {{{width}}} }} | MAX_WIDTH | {{ #ifexpr: {{{width}}} < MAX_WIDTH | {{{width}}} | MAX_WIDTH }} }} | MAX_WIDTH }}px ("MAX_WIDTH" should be replaced with the maximum allowed width for that image use).
  • caption - Image caption.

Special-case parameters[edit]

Unnamed parameters[edit]

Parameters whose names consist only of numbers are called "unnamed parameters" and are treated specially by MediaWiki: when using a template with an unnamed parameter, a value may be given to that parameter without using its name. For instance, {{Ruby}} is used simply like {{Ruby|base text|ruby text}}. In templates, unnamed parameters are numbered starting at 1, with the parameter's number corresponding to its position in a template call relative to other unnamed parameters (so, in the previous example, "base text" is the unnamed parameter 1, and is provided first in the template call, and "ruby text" is the unnamed parameter 2 and is provided second). If an unnamed parameter is used in a template call, but one or more preceding unnamed parameters are not, those unused parameters must still be provided; for example, to call {{Ruby}} with only Ruby text, it is necessary to write {{Ruby||ruby text}} instead of {{Ruby|ruby text}}.

Unnamed parameters should generally only be used on templates with a very small number of parameters that are used in most transclusions; for instance, almost every transclusion of {{Ruby}} will use both the base text and Ruby text parameters, so using unnamed parameters makes it simpler to use this template. In addition, unnamed and named parameters can be used alongside each other in templates; {{Ruby}} has the named parameter lang which is used for specifying the ISO 639 language code when the template is used with non-Japanese text.

Maintenance and internal-use parameters[edit]

Parameters which are not intended for general use (for example, parameters only used temporarily for template maintenance or tracking, or the parameters of a /core subtemplate which is only used directly on its root template) do not have to follow these guidelines, though it is still recommended. In particular, a different naming style for maintenance parameters could be used to visually differentiate them from standard parameters.

Parameters in imported templates[edit]

Several general-utility templates in use on this wiki have been imported from other wikis (for instance, {{Navbox}} is imported from Template:Navbox on Wikipedia). Parameters in imported templates may not follow these guidelines; in such cases, to preserve compatibility with the source wiki (in particular, to ease the process of importing updated copies of these templates) as well as any usages of the template that have also been imported, the parameter names generally should not be updated to follow these guidelines.

This does not apply if an in-house version of an imported template is developed; the in-house version of the template should follow these guidelines, with local usages being updated as necessary.