Difference between revisions of "Template:Plural/doc"
Jump to navigation
Jump to search
Line 4: | Line 4: | ||
The template has two parameters: | The template has two parameters: | ||
− | <code><nowiki>{{</nowiki>Plural|''"value"''|''"text"''<nowiki>}}</nowiki></code> | + | <code><nowiki>{{</nowiki>Plural|''"value"''|''"text"''<nowiki>|link=}}</nowiki></code> |
* The first parameter can be any value, usually in form of an '''expression'''. This parameter is optional. When it i omitted the template just return the plural form of the second parameter. | * The first parameter can be any value, usually in form of an '''expression'''. This parameter is optional. When it i omitted the template just return the plural form of the second parameter. | ||
* The second parameter can be any text including links and templates. It should end with the '''unit''' of the value as this template simply adds an "s" at the end of the text, if the value isn't 1. | * The second parameter can be any text including links and templates. It should end with the '''unit''' of the value as this template simply adds an "s" at the end of the text, if the value isn't 1. | ||
+ | * The <code>link=</code> parameter can be set to any value, if the second parameter should be turned into a link. | ||
=== Examples === | === Examples === | ||
Line 15: | Line 16: | ||
<code><nowiki>{{Plural|1/3 round 2|component}}</nowiki></code> '''produces:''' {{Plural|1/3 round 2|component}} | <code><nowiki>{{Plural|1/3 round 2|component}}</nowiki></code> '''produces:''' {{Plural|1/3 round 2|component}} | ||
+ | |||
+ | <code><nowiki>{{Plural|2|component|link=true}}</nowiki></code> '''produces:''' {{Plural|2|component|link=true}} | ||
+ | |||
+ | <code><nowiki>{{Plural||component}}</nowiki></code> '''produces:''' {{Plural||component}} | ||
+ | |||
+ | ==== Special cases ==== | ||
+ | <code><nowiki>{{Plural|2|gold}}</nowiki></code> '''produces:''' {{Plural|2|gold}} ''(there is a hardcoded list of uncountable things)'' | ||
+ | |||
+ | <code><nowiki>{{Plural|2|molotov cocktails}}</nowiki></code> '''produces:''' {{Plural|2|molotov cocktails}} ''(everything ending in "s")'' | ||
+ | |||
+ | <code><nowiki>{{Plural|2|battery}}</nowiki></code> '''produces:''' {{Plural|2|battery}} ''(everything ending in "y")'' | ||
+ | |||
+ | <code><nowiki>{{Plural|2|art bench}}</nowiki></code> '''produces:''' {{Plural|2|art bench}} ''(everything ending in "bench")'' | ||
+ | |||
+ | |||
<includeonly>[[Category:Formatting templates]]</includeonly> | <includeonly>[[Category:Formatting templates]]</includeonly> | ||
<noinclude>[[Category:Template documentation]]</noinclude> | <noinclude>[[Category:Template documentation]]</noinclude> |
Revision as of 17:13, 10 January 2024
Usage
This template can be used to properly localise units.
The template has two parameters:
{{Plural|"value"|"text"|link=}}
- The first parameter can be any value, usually in form of an expression. This parameter is optional. When it i omitted the template just return the plural form of the second parameter.
- The second parameter can be any text including links and templates. It should end with the unit of the value as this template simply adds an "s" at the end of the text, if the value isn't 1.
- The
link=
parameter can be set to any value, if the second parameter should be turned into a link.
Examples
{{Plural|1|component}}
produces: 1 component
{{Plural|2|component}}
produces: 2 components
{{Plural|1/3 round 2|component}}
produces: 0.33 components
{{Plural|2|component|link=true}}
produces: 2 components
{{Plural||component}}
produces: components
Special cases
{{Plural|2|gold}}
produces: 2 gold (there is a hardcoded list of uncountable things)
{{Plural|2|molotov cocktails}}
produces: 2 molotov cocktails (everything ending in "s")
{{Plural|2|battery}}
produces: 2 batteries (everything ending in "y")
{{Plural|2|art bench}}
produces: 2 art benches (everything ending in "bench")