Template:Plural

From Terraria Mods Wiki
Jump to navigation Jump to search
This template is i18n-ready, which means it is easy to localize for different languages. Please see tgc:Help:I18n & l10n for templates to learn more.
See Template:Plural/l10n for the localization of this template.
Template-info.svg Documentation The documentation below is transcluded from Template:Plural/doc. (edit | history)

This template is an alternative to {{plural:}} that supports internalization.

Usage

{{ plural | <integer> | <singular form> | <plural form> | <second plural form> (optional) | lang = <language code> (optional) }}

First unnamed parameter

An integer. The template outputs one of the words based on this parameter and the ruleset of the current language.

Second unnamed parameter

Singular form of the word.

Third unnamed parameter

Plural form of the word.

Fourth unnamed parameter

Second plural form of the word. This parameter is needed only in the case your language has complex ruleset. If the value is not set, it will be replaced with the second unnamed parameter.

lang

Language for the ruleset. By default it equals {{lang}}.

Examples

Code Result Note
{{plural|one|house|houses}}
{{plural}}: the first parameter must be an integer!
First parameter must be an integer
{{plural|3.14|house|houses}}
{{plural}}: the first parameter must be an integer!
{{plural|1|house}}
{{plural}}: at least 3 unnamed parameters must be used in this template: number, singular form, and plural form!
3 unnamed parameters are necessary for the correct work of the template.
{{plural|0|house|houses}} houses English and most of the languages have simple ruleset: if the amount is not 1 then use the plural form. Otherwise, use the singular form.
{{plural|1|house|houses}} house
{{plural|2|maison|maisons|lang=fr}} maisons French has a bit different ruleset: if the amount is more than 1 then use the plural form. Otherwise, use the singular form.
{{plural|1|maison|maisons|lang=fr}} maison
{{plural|0|maison|maisons|lang=fr}} maison
{{plural|-1|maison|maisons|lang=fr}} maison The template can work with negative numbers as well.
{{plural|-2|maison|maisons|lang=fr}} maisons
{{lang/set|ru}}
{{#loop:amount_of_houses|0|25|<nowiki/>
* {{#var:amount_of_houses}} {{plural|{{#var:amount_of_houses}}|дом|дома|домов}}
}}
{{lang/set|}}

  • 0 домов
  • 1 дом
  • 2 дома
  • 3 дома
  • 4 дома
  • 5 домов
  • 6 домов
  • 7 домов
  • 8 домов
  • 9 домов
  • 10 домов
  • 11 домов
  • 12 домов
  • 13 домов
  • 14 домов
  • 15 домов
  • 16 домов
  • 17 домов
  • 18 домов
  • 19 домов
  • 20 домов
  • 21 дом
  • 22 дома
  • 23 дома
  • 24 дома
Some languages (Russian as an example) have complex rulesets for plural forms. This localization guide has rulesets for many languages.