Difference between revisions of "Template:Plural/doc"

From RimWorld Wiki
Jump to navigation Jump to search
(updated to reflect changes how strings with brackets are handled.)
 
(5 intermediate revisions by 2 users not shown)
Line 21: Line 21:
 
<code><nowiki>{{Plural||component}}</nowiki></code> '''produces:''' {{Plural||component}}
 
<code><nowiki>{{Plural||component}}</nowiki></code> '''produces:''' {{Plural||component}}
  
==== Special cases (evalueated in this order) ====
+
==== Special cases (evaluated in this order) ====
 +
===== Bracket names =====
 +
<code><nowiki>{{Plural|2|Animalist slab (broad)}}</nowiki></code> '''produces:''' {{Plural|2|Animalist slab (broad)}} ''(the plural is defined by the last word before the first "(" in the string)''
 +
 
 
===== Uncountable things =====
 
===== Uncountable things =====
 
<code><nowiki>{{Plural|2|gold}}</nowiki></code> '''produces:''' {{Plural|2|gold}} ''(there is a hardcoded list of uncountable things)''
 
<code><nowiki>{{Plural|2|gold}}</nowiki></code> '''produces:''' {{Plural|2|gold}} ''(there is a hardcoded list of uncountable things)''
  
 
===== Depending on last two letters =====
 
===== Depending on last two letters =====
 +
<code><nowiki>{{Plural|2|day}}</nowiki></code> '''produces:''' {{Plural|2|day}} ''(everything ending in "-ay")''
 +
 
<code><nowiki>{{Plural|2|sash}}</nowiki></code> '''produces:''' {{Plural|2|sash}} ''(everything ending in "-ch", "-sh" or "-ss")''
 
<code><nowiki>{{Plural|2|sash}}</nowiki></code> '''produces:''' {{Plural|2|sash}} ''(everything ending in "-ch", "-sh" or "-ss")''
  
Line 40: Line 45:
  
 
<code><nowiki>{{Plural|2|battery}}</nowiki></code> '''produces:''' {{Plural|2|battery}} ''(everything ending in "-y")''
 
<code><nowiki>{{Plural|2|battery}}</nowiki></code> '''produces:''' {{Plural|2|battery}} ''(everything ending in "-y")''
 
  
 
<includeonly>[[Category:Formatting templates]]</includeonly>
 
<includeonly>[[Category:Formatting templates]]</includeonly>
 
<noinclude>[[Category:Template documentation]]</noinclude>
 
<noinclude>[[Category:Template documentation]]</noinclude>

Latest revision as of 15:37, 18 October 2024

Usage[edit]

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[edit]

{{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:components

{{Plural||component}} produces: components

Special cases (evaluated in this order)[edit]

Bracket names[edit]

{{Plural|2|Animalist slab (broad)}} produces: 2 Animalist slabs (broad) (the plural is defined by the last word before the first "(" in the string)

Uncountable things[edit]

{{Plural|2|gold}} produces: 2 gold (there is a hardcoded list of uncountable things)

Depending on last two letters[edit]

{{Plural|2|day}} produces: 2 days (everything ending in "-ay")

{{Plural|2|sash}} produces: 2 sashes (everything ending in "-ch", "-sh" or "-ss")

{{Plural|2|knife}} produces: 2 knives (everything ending in "-fe")

{{Plural|2|gladius}} produces: 2 gladii (everything ending in "-us")

Depending on last letter[edit]

{{Plural|2|shelf}} produces: 2 shelves (everything ending in "-f")

{{Plural|2|molotov cocktails}} produces: 2 molotov cocktails (everything ending in "-s")

{{Plural|2|toy box}} produces: 2 toy boxes (everything ending in "-x")

{{Plural|2|battery}} produces: 2 batteries (everything ending in "-y")