Jump to content

విక్షనరీ:Templates

విక్షనరీ నుండి

A template is a page in the Template: namespace, which contains special wiki code that allows it to be reproduced ("transcluded") on many different pages. Templates can either be transcluded directly, or you can pass on additional information (through "parameters") to the template that controls or modifies its behaviour.

The advantage of using templates is that when the template itself is changed, all pages that transclude the template will automatically be updated as well. This helps in reducing the duplication of identical content, and templates are a powerful tool for keeping the appearance of certain parts of a dictionary entry consistent. For example, a single template to generate a table of inflected forms of a verb can be used on hundreds of different pages, but will look and function the same on each one. Generally speaking, if you find yourself having to add more or less the same thing on several pages, it's probably better to write a template instead and transclude it onto the pages.

Wiktionary makes heavy use of templates, so it is a good idea to familiarise yourself with how they work and how to use them, even if you don't write your own. Templates can be found in Category:Templates and its subcategories.

Templates may either use a Scribunto module as underlying mechanism, or be written directly in template code. Although Scribunto is strongly preferred for templates with complex logic, a straightforward string-assembly template probably doesn't need a module. Some templates may also mix both, calling on Scribunto for some parts while using template/wiki code for the remainder.

There are some good guides for using and writing templates on Meta:

If you want to create a new template, but you're still inexperienced with them or with Wiktionary in general, it's probably best to ask first (at the WT:Grease Pit). Maybe there isn't really a need for such a template, because the problem you are trying to solve with it can be approached differently. Maybe someone else already wrote something similar to your idea; it would be better to use what already exists instead of doing it all over again. For that reason, the best way to "learn" templates is probably to study the ones we already have on Wiktionary.

Language-specific templates

[<small>మార్చు</small>]

Many languages have their own set of templates, which can be found in one of the subcategories of Category:Templates by language. Language-specific templates are better able to cater to the needs of a specific language than a general template can, and allow for specific exceptions or restrictions that general templates don't. Because they are made for a specific language, knowledge of that language's grammar can be embedded into them. For example, the template {{es-conj-ar}} automatically generates a table with a full set of inflected forms of a Spanish verb, while {{en-noun}} is capable of automatically showing the plural form of many English nouns.

While it may be easier to use generic templates like {{head}} to start off with, you'll eventually come to a point where it's better to create a tailor-made set of templates for your language. At that point, however, you'll already have all the "old" entries to deal with, which still use the generic all-language templates, which you'll then have to fix. For that reason, it's encouraged to create at least a basic set of headword-line templates (see below) for each language, before you start to create entries in that language.

Naming your templates

[<small>మార్చు</small>]

Try to use a name that is both short and descriptive. As a rule of thumb, the more often the template will be used, the more leeway there is in using a short name. Templates that are used only within other templates should have longer names, as they generally don't need to be used that often. If you can, try to avoid using characters outside the ASCII encoding (use only the Latin alphabet), so that everyone can easily type your template's name.

Templates that are intended specifically for one language should have a name that begins with that language's language code, followed by a hyphen. For example, {{en-verb}} is intended to be used for English entries, {{nl-adj form of}} for Dutch entries, {{fr-conj-er}} for French entries, {{sl-decl-adj}} for Slovene, and so on. What follows after the code is up to the creator of the template, but there are certain naming conventions that are followed, on which more below. If you are writing a template for a specific language, you include any of the characters that are used in that language as part of the name. However, even then, using just the Latin alphabet is preferable.

Headword-line templates

[<small>మార్చు</small>]

Headword-line templates are templates that are used to produce the headword line of a term. (historical note: this was formerly called the "inflection line", and headword-line templates used to be called "inflection templates") The headword line is the line that comes immediately below the header specifying the part of speech (such as Noun or Verb). At the very least, the headword line contains the headword in question, specially formatted in bold text. Additional information may also be presented on the headword line, such as the gender of a noun (for languages where that applies), or a selection of inflected forms.

Most languages have their own set of headword-line templates; these are the most common form of language-specific template. In cases where the language lacks an appropriate headword-line template, {{head}} should be used.

Headword-line templates are named using the language code, followed by an abbreviated form of the part of speech that the template is used for. For example, {{nl-verb}} is for the headword line of Dutch verbs, {{en-noun}} is for English nouns, and so on. The following abbreviated part-of-speech names are currently in common use:

  • Adjective: adj
  • Adverb: adv
  • Conjunction: con
  • Determiner: det
  • Interjection: interj
  • Noun: noun
  • Numeral: num
  • Particle: part
  • Postposition: postp
  • Preposition: prep
  • Pronoun: pron
  • Proper noun: proper noun
  • Verb: verb

Languages may extend these names if they need templates for more specific purposes, such as {{nl-noun-dim}} for Dutch diminutive nouns. It's common to add -form at the end if the template is to be used for words that are not full dictionary entries (they are not lemmas) but are a form of another word. For example {{nl-adj-form}} for Dutch adjective forms.

Formatting the headword

[<small>మార్చు</small>]

The headword itself appears in boldface, unless it's in a writing system where bold text is harder to read, in which case it appears with a larger font-size (this is controlled through MediaWiki:Common.css). Within the template's code, the {{PAGENAME}} magic word is used to automatically display the name of the current page. Most headword-line templates also provide a parameter named head=, which allows other editors override this default display, in case this is desired (for example, if additional accent marks should be displayed on the headword). Some templates may use other names for this parameter, but head= is the most common and the most standard, so it is preferred for the sake of easy interoperability.

There are a few different ways that headword lines can be created using a template, but the result should appear the same in all cases:

  • A more recent method uses the "strong" HTML element with the class="headword" HTML attribute. This element is provided with a lang= HTML attribute to specify the language code of the language that the word is part of. An additional HTML class, the script code, should be provided if the headword is not written in the Latin alphabet but in some other writing system like Cyrillic or Chinese. Examples:
    <strong class="headword" lang="fr">{{{head|{{PAGENAME}}}}}</strong>
    <strong class="headword Cyrl" lang="ru">{{{head|{{PAGENAME}}}}}</strong>
    
  • An older (but still good) alternative is to use a script template to wrap the headword. This template is then provided with the lang= parameter for the language code, and the face=head parameter to tell the template to show the text in headword-line style formatting.
    {{Latn|{{{head|{{PAGENAME}}}}}|lang=fr|face=head}}
    {{Cyrl|{{{head|{{PAGENAME}}}}}|lang=ru|face=head}}
    
  • A method that is older still is to simply surround the headword with wikicode to make it appear bold. This method is deprecated and discouraged because it does not supply the appropriate language or styling information, which is needed by browsers to select the correct fonts and provide further support for the language (such as adjusting the language of a screen reader).
    '''{{{head|{{PAGENAME}}}}}'''
    

Genders and other grammar information

[<small>మార్చు</small>]

For languages that have grammatical genders, the gender usually immediately follows the headword. Genders should be formatted using Module:gender and number. Many templates allow you to indicate the gender by passing it as the first numbered parameter, although the g= parameter is also commonly used (it is used by {{head}}). Writing your template to use the numbered parameter is preferred, however, because it's less likely to be overlooked by other editors – you have to consciously "skip" the first parameter to get to the second, which makes it more obvious when you forget it. Thus, a template that is used like {{ca-noun|m}} is preferred to one that is used like {{ca-noun|g=m}} (the ca-noun template itself already uses the first format, so using the second is an error in this case).

It's usually good coding practice to add code to your template that checks whether the gender that has been provided to the template is valid. For example, French has no neuter gender, so if someone writes {{fr-noun|n}}, then that is an error. If it's not valid, the template should add the page to a cleanup category such as Category:French nouns lacking gender, so that it can be corrected.

Gender is indicated for word wherever appropriate. Some languages expect gender notation on each word form. Gender forms are rare in English however. The distinction between "neuter" and "common" is unclear (especially for English speakers) so you should check the "Wiktionary:About ___" page for each language, for guidelines on using these templates.

Gender Template Output
feminine {{f}} మహిళల పేరు
masculine {{m}} పురుషుల పేరు
masculine and feminine {{m|f}} పురుషుల పేరు
neuter {{n}} n.
common {{c}} పేరు
[<small>మార్చు</small>]

Following the headword and optional gender information, you can choose to display additional forms of the word, surrounded by parentheses. {{en-verb}} displays the various forms of an English verb, for example, while {{nl-adj}} displays the comparative and superlative form of a Dutch adjective.

When displaying and/or linking to forms in your template, you can either use a generic linking template like {{l}} or, preferably, write out the link manually. When writing out the link yourself, you should always link to the appropriate section. You should also provide the language code (with the lang= HTML attribute) and a HTML class for the script code if it's not Latin. The forms should be displayed in bold while the grammatical information (such as "comparative" or "past tense") is displayed in italics. This should be done even if the letters don't normally look right in bold font – the language and script tags will ensure (through style sheets) that the text will not actually be bolded if it's not appropriate. Here are some varieties you can use (with example words already filled in; normally your template would determine these through other means such as parameters or the page name):

(''plural'' <b lang="nl">[[woorden#Dutch|woorden]]</b>, ''diminutive'' <b lang="nl">[[woordje#Dutch|woordje]]</b>)
(''genitive'' <span lang="sl">'''[[besede#Slovene|bésede]]'''</span>)
(''simplified'' <b lang="cmn" class="Hani">[[马#Mandarin|马]]</b>, ''pinyin'' <b lang="cmn-pinyin">mǎ</b>, ''Wide-Giles'' <b lang="cmn-wadegile">ma<sup>3</sup></b>)

A template may need additional parameters to correctly display the additional forms, while some forms can be determined automatically. Different templates currently use different approaches. {{nl-noun}} requires you to manually enter the forms, and will display a notice on the page and add the entry to a category if they are missing. {{en-verb}} on the other hand generates them automatically. There are pros and cons to both approaches. Determining the forms automatically makes things easier for the editor, because they do not have to concern themselves with the details. On the other hand, automatically-generated forms may not be correct, while they will more likely be correct if they have to be entered manually. Requiring editors to manually enter the forms also means that a user can add your template to an entry without having to worry whether the forms it has generated are correct (this is useful because an editor may not know the language but still want to add the template to an entry in that language). You will therefore have to make a trade-off. If the forms that your template can automatically generate are correct in the majority of cases, then it makes sense to do so. However, if automatically generated forms can only be correct in a small amount of cases, it makes more sense to require the editor to enter them.

Be very mindful of which forms you choose to include in this way. While a lightly-inflected language like English only has a few forms, languages like Latin may have dozens, and they could never fit onto a single line (also keep in mind that some users might have smaller screens!). If a word in your language has too many distinct forms to fit on one line (4–5 is probably about the limit) then it's better to show either no forms on the headword-line, or show only a few key forms that help users figure out the remainder themselves. For Latin verbs in particular, the four verb forms that are displayed on the headword line are the least predictable forms, which most other forms can be regularly derived from (so-called "principal parts").

It is generally expected that every headword-line template will add the entry to a category corresponding to its part of speech. {{en-verb}} adds the entry it is added to to Category:English verbs, {{fr-noun}} adds it to Category:French nouns, {{nl-adj-form}} adds it to Category:Dutch adjective forms. The template {{head}} has a parameter to specify the language and category: {{head|ru|adjective}} adds the entry to Category:Russian adjectives.

Inflection-table templates

[<small>మార్చు</small>]

Languages that use several different forms of the same word often use inflection-table templates. These are templates that display a table or list containing all or most of the inflected forms of a particular word. Unless they are very small, these tables should be made collapsible, by enclosing them in the following code:

<div class="NavFrame">
<div class="NavHead">(text to display when the table is collapsed)</div>
<div class="NavContent">
(put the table itself here)
</div>
</div>

By convention, tables that show the forms of nouns, pronouns and adjectives are named decl and are placed in a ====Declension==== section on the page, while tables that show the forms of verbs are named conj and are placed in a ====Conjugation==== section. Usually, the name also includes the specific inflection type or class that the word may follow. {{nl-decl-adj}} is used for Dutch adjectives, for example, while {{es-conj-ir}} is used for Spanish verbs ending in -ir, and {{de-conj-strong}} is used for German strong verbs. However, sometimes there is no need for such a distinction and only a single template is needed: {{eo-conj}}.

If a language needs at least two different templates for different inflectional classes of the same type of word (for example German {{de-conj-strong}} and {{de-conj-weak}}), then it is considered good practice to create a third template, with the name ending in -table. This template should display the table itself, but should not create any of the forms that appear in the table. It should be "indifferent" to the specific kind of inflection, so to speak (programmers call this "separating interface and implementation"). An example of this is {{ca-conj-table}}, which is used as a general table, while {{ca-conj-ar}}, {{ca-conj-ir}} and others transclude the basic table template and fill it with the appropriate forms. If your language only needs one table of its kind (like {{eo-conj}} in Esperanto, where all verbs inflect exactly the same), then you probably won't need to separate the templates' duties in this way, but it may still help for clarity if nothing else.

On Wiktionary, a form-of entry is an entry for a word that is considered an inflected form of another word. Such entries don't contain a full definition. Usually the definition is a short description of the grammatical properties of this form, and a link to the main entry. Compare, for example, the entries for locate and its past-tense form located. The definitions of such entries are generated automatically with templates. There is a wide variety of form-of templates, and many of them not specific to one language but can be used for most languages. For that reason, it is often not necessary to create form-of templates for your language. It doesn't hurt to do so anyway, but it may be considered wasteful and redundant if your template does what a generic template already does perfectly.

Some form-of templates also add the entry to a category. {{comparative of}}, when provided with the parameter lang=da, adds the entry to Category:Danish adjective comparative forms. This may or may not be desirable. Generally, the headword-line should add the category, so it is at the very least redundant if the form-of template also does this. Furthermore, a template may be used for more than one part of speech (case in point: {{comparative of}} can be used for adjectives, adverbs or determiners), and it may also conflict with the way a language's categories are structured. Therefore, it's probably good practice to not add categories with form-of templates, or to add only additional categories and not the main part-of speech category.

Context label templates

[<small>మార్చు</small>]

(please expand)

  • {{context|____}} Tag a term in a definition and add a category link for it. Put this just after the "#" character and before the definition text. For example, to have (mathematics) appear, one may use {{context|mathematics}} and the term will also be added to Category:Mathematics. Note that many existing topics (including mathematics) have one or more shortcut templates already defined, e.g., {{math}} and {{mathematics}}. It is generally more readable to use these in articles.
  • {{qualifier|____}} Shows the given qualifiers in a reader-customizable style, e.g., (qualifier). The default style is with parentheses and italics. This template is intended generally only used in the definition of other templates, but may also be used directly in articles at the beginning of a list item if no other template applies.

Category boilerplate templates

[<small>మార్చు</small>]

(please expand)

Templates for entering quotations (also Category:Citation templates):

Templates for referring to sources in quotations:

Long lists of terms (such as derived terms or translations) usually look better when formatted into columns. The templates below provide an easy method of doing this.

Current Wiktionary style is to put such material in collapsible tables so that the user can display it only if they wish to. This makes an entry easier to read and navigate. Alternatively, content may be made permanently visible. It is preferable to use collapsible tables for long lists and to make only short lists permanently visible, or to use collapsible tables for all lists (given that short lists may eventually become much longer).

To use any of these templates, place the "top" template immediately before the content and the "bottom" template immediately after. Place the "mid" (or "mid2") template as close to halfway through the content as possible. If using the templates for more than two columns, place a "mid3" template at one-third and another two-thirds of the way through the content, or the "mid4" at one-quarter, one-half and three-quarters of the way through.

Use the templates from one group only at any one time. Do not combine templates from different groups, as this will give odd results or might not be parsed correctly by the browser.

For "Translations" sections

The following templates display translations in two columns in a collapsible table. They are for use only in the Translations section of an article; in other sections, use the templates below.

The "trans-top" template takes an argument that is used as the header for the table. A gloss summarising the meaning being translated is put here. For example, in the entry for time, the gloss "inevitable passing of events" is given in the first table of translations, and this is generated thus: {{trans-top|inevitable passing of events}}.

Currently, templates for collapsible translation tables are available only in two-column format.

For other lists

Collapsible tables

The following templates display lists in two columns in a collapsible table. They are for use in sections other than the Translations section of an article (not just the Related terms section, despite the name); in the Translations sections, use the templates above.

The "rel-top" template takes an argument that is used as the header for the table. A gloss summarising the content of the table. For example, in the entry for time, the table of derived terms has the header "terms derived from time", and this is generated thus: {{rel-top|terms derived from ''time''}}. Note that this is the preferred format of a gloss for derived and related terms (which would have the header "terms related to time"). Note that the word or phrase which the terms are derived from or related to is italicised.

Very long lists can be formatted in four columns using the following:

where {{rel-mid4}} is to be used three times within the content to separate it into four columns of equal or approximately equal length.

For lists that are always displayed

Alternatively, a list of terms can be formatted so that it is always displayed (that is, not hidden in a collapsible table). This format is best reserved for short lists.

The following templates display content in two, three or four columns. They are not for use in a Translations section of an article; in the Translations section, use {{trans-top}} etc. as described above.

Two columns
Three columns
Four columns

Etymology templates:

  • {{back-form}} - Indicates that the term is a back-formation.
  • {{etyl}} - general-purpose template
  • {{term}}
  • {{compound}}
  • {{rfe}} -- request for etymology

Languages: These templates "wrap" the language abbreviations used in Webster 1913 (see Wiktionary:Abbreviations in Webster#Languages). One function of these templates is to make transcribing etymologies from Webster 1913 simple. Another function is to expand the obscure abbreviation into the full name of the language. A third function of these templates is to automatically categorize words according to their etymologies (see Wiktionary:Categorization).

These templates will automatically both add a word to an etymology category and create an interwiki link to the language article on Wikipedia, as well as expand to the name of the language, and are suitable for use in the "Etymology" section of an article.

All these templates can be found at Wiktionary:Etymology/language templates.

External links:

  • {{Wikipedia}} -- Inclusion of this inserts a highly visible link to Wikipedia for the same word/topic. If there are enough headings, then this should go above the ==English== header line to make it appear correctly.
  • {{Wikisource}}
  • {{Wikibooks}}
  • {{pedialite}} -- A simple one-liner entry that gets tucked away in ===External links=== to link to Wikipedia with the page title.
See the separate page Wiktionary:Maintenance templates.

See also Category:Pronunciation templates and Wiktionary:Pronunciation#Section layout and templates.

The main pronunciation templates are

  • {{IPA}}
  • {{X-SAMPA}}
  • {{rfap}} - request for audio pronunciation
  • {{rfp}} - request for pronunciation

Reference templates, templates used to link to external sources used as a reference:

See Category:Reference templates.

Some often used reference templates:

Request templates (also Category:Request templates):

Request templates for dictionary entries in the main namespace. Parameters are optional, unless marked with an asterisk (*). (See Wiktionary:Maintenance templates for additional information.)

Deletion and verification:

  • {{delete|reason}} - Request for immediate deletion of mistakes, vandalism, and other garbage
  • {{rfd|reason}} - Listed request for deletion of potentially encycopedic or non-idiomatic terms
  • {{rfd-redundant}} - Request for deletion of sense; the definition is redundant
  • {{rfv|reason}} - Listed request for verification; entry is disputed at WT:RFV
  • {{rfv-sense}} - Request for verification of sense; the sense is disputed at WT:RFV

Language and translations:

  • {{rftrans}} - Request for translations; this English article needs translation into other languages
  • {{gloss-stub|language name}} - Request for clarification of sense; the translation to English is imprecise
  • {{rfscript|script name*}} - Request for foreign-language script
  • {{subst:nolanguage}} - Request for language header; the entry lacks language identification
  • {{subst:notenglish}} - Request for translation; the article is not in English
  • {{rfc-trans}} - Request for translation table split; the existing table needs to be split by meaning

Information and cleanup:

  • {{rfap|region|region}} - Request for audio pronunciation; an audio file is wanted
  • {{rfc|reason}} - Request for cleanup; the article is not formatted well
  • {{rfc-case|details, if not uc./lc.}} - Request for case split; the article includes both capitalized and lower-case words
  • {{rfdate}} - Request for date; the quotation lacks a date
  • {{rfdef}} - Request for definition; the entry lacks a definition
  • {{rfe|reason}} - Request for etymology; the entry lacks an etymology
  • {{rfp|reason}} - Request for pronunciation; the entry lacks a pronunciation (e.g. IPA)
  • {{rfphoto}} - Request for photo; an image file is wanted
  • {{rfdrawing}} - Request for drawing; a drawing is wanted
  • {{rft|reason|fragment=link text}} - Entry is under discussion in the Tea Room
  • {{rndc}} - Request for new definition; the existing definition violates copyright

Other entries:

Request templates for pages in other namespaces:

  • {{delete|reason}} - Request for immediate deletion of mistakes or vandalism
  • {{rfd|reason}} - Request for deprecation of categories and templates or deletion of other pages

Results of requests:

See Wiktionary:Script templates and Category:Script templates.

Templates for Appendix:Swadesh lists.

Templates for Swadesh lists
Templates for boxes
  • {{Swadesh lists}}: box with all Swadesh lists of individual languages, language families and branches
Other templates

See Category:TOC templates.

See Category:User warning templates.

Welcome templates (also Category:Welcome templates):

Templates used in WT:Wikisaurus:

  • {{ws header|Xxx}} - Marks page as a Wikisaurus entry, and list alphabetically under the Xxx entry within the Wikisaurus category. Also put in top of page layout for a Wikisaurus entry.
  • {{ws beginlist}} - Top of list of Wikisaurus line entries
  • {{ws|Xxx|Yyy}} - Single line Wikisaurus entry - Xxx is the entry word, Yyy is a brief definition/usage note.
  • {{ws endlist}} - Top of list of Wikisaurus line entries

See also Wiktionary:Wikisaurus#Templates.