Template:Plural: Difference between revisions
[[mw:]]>Shirayuki mNo edit summary |
ManfredoDo (talk | contribs) m (1 revision imported: Template documentation pages) |
(No difference)
|
Latest revision as of 18:05, 12 November 2022
{{{1}}} {{{2}}}s
This template allows easy formatting of statements of the form "# thing(s)", with correct use of plurals. It uses the "plural" magic word, so ideally it should work with minimal modification for other language.
Usage
With a space between the number and name (using numeric character reference  
):
- {{plural|number|name}}
- {{plural|number|singular name|plural name}}
With a non-breaking space between the number and name (using character entity reference
):
- {{plural|number|name|nb=yes}}
- {{plural|number|singular name|plural name|nb=yes}}
Examples
For most English nouns, the plural is formed by adding "s" to the end of the singular form. If that is the case, only one "name" parameter is required:
{{plural|0|page}}
returns "0 pages"{{plural|1|page}}
returns "1 page"{{plural|2|page}}
returns "2 pages"{{plural|-1|page}}
returns "-1 page"{{plural|-2|page}}
returns "-2 pages"{{plural|0.5|page}}
returns "0.5 pages"{{plural|1.5|page}}
returns "1.5 pages"{{plural|-0.5|page}}
returns "-0.5 pages"{{plural|-1.5|page}}
returns "-1.5 pages"
For plurals that require adding "es", or more unusual forms, the singular and plural forms must be specified explicitly:
{{plural|0|ox|oxen}}
returns "0 oxen"{{plural|1|ox|oxen}}
returns "1 ox"{{plural|2|ox|oxen}}
returns "2 oxen"{{plural|-1|ox|oxen}}
returns "-1 ox"{{plural|-2|ox|oxen}}
returns "-2 oxen"{{plural|0.5|ox|oxen}}
returns "0.5 oxen"{{plural|1.5|ox|oxen}}
returns "1.5 oxen"{{plural|-0.5|ox|oxen}}
returns "-0.5 oxen"{{plural|-1.5|ox|oxen}}
returns "-1.5 oxen"
With parameter |nb=
:
<div style="width:5em">{{plural|2|sesquipedalian|nb=yes}}</div>
returns:2 sesquipedalians<div style="width:5em">{{plural|2|sesquipedalian|nb=no}}</div>
returns:2 sesquipedalians
Notes
- While
{{plural|#|sheep|sheep}}
is valid, it is also fairly pointless. - The template does not handle missing parameters 1 or 2:
{{plural}}
returns "{{{1}}} {{{2}}}s" - The template does not handle empty parameters 1 or 2:
{{plural||}}
returns " s" - The template does not remove leading or trailing spaces in parameters 1 or 2:
{{plural | 2 | page }}
returns " 2 page s"
TemplateData
This is the TemplateData documentation for this template used by VisualEditor and other tools.
Plural
Allows easy formatting of statements using plural.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Number | 1 | The number of items: 0, 1, 2 etc. | Number | required |
Singular name | 2 | The text to use when one item is specified | String | required |
plural name | 3 | The text to use when two or more items are specified. The default is to append the singular form with 's'. | String | optional |