Module:UnitPlural/doc: Difference between revisions
More actions
Created page with "{{doc sub}} {{Module rating |beta}} <!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see Wikipedia:Wikidata) --> == Function main == The main function takes a number and unit name ({{para|quantity}}) and an optional language code ({{para|lang}}) from the frame. It returns the quantity with proper plural units in the given language, if it can. It will find use when the quantity is returned from Wikidata, so that t..." |
No edit summary |
||
Line 1: | Line 1: | ||
{{doc sub}} | {{doc sub}} | ||
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> | <!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> | ||
Line 37: | Line 36: | ||
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | | | <includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | | | ||
<!-- Categories below this line, please; interwikis at Wikidata --> | <!-- Categories below this line, please; interwikis at Wikidata --> | ||
[[Category:Modules]] | |||
}}</includeonly> | }}</includeonly><noinclude> | ||
[[Category:Module documentation pages]] | |||
</noinclude> |
Revision as of 03:58, 2 March 2025
This is a documentation subpage for Module:UnitPlural. It may contain usage information, categories and other content that is not part of the original module page. |
Function main
The main function takes a number and unit name (|quantity=
) and an optional language code (|lang=
) from the frame.
It returns the quantity with proper plural units in the given language, if it can.
It will find use when the quantity is returned from Wikidata, so that the numerical value is not yet known.
Examples
{{#invoke:UnitPlural |main |quantity=1 week}}
→ 1 week{{#invoke:UnitPlural |main |quantity=3 week}}
→ 3 weeks{{#invoke:UnitPlural |main |quantity=3.50 week}}
→ 3.50 weeks{{#invoke:UnitPlural |main |quantity=1 foot}}
→ 1 foot{{#invoke:UnitPlural |main |quantity=3 foot}}
→ 3 feet{{#invoke:UnitPlural |main |quantity=1 mile per hour}}
→ 1 mile per hour{{#invoke:UnitPlural |main |quantity=3 mile per hour}}
→ 3 miles per hour{{#invoke:UnitPlural |main |quantity=1 standard gravity}}
→ 1 standard gravity{{#invoke:UnitPlural |main |quantity=3 standard gravity}}
→ 3 standard gravities{{#invoke:UnitPlural |main |quantity=1 foot}}
→ 1 solar mass{{#invoke:UnitPlural |main |quantity=3 solar mass}}
→ 3 solar masses
Function plural
Function plural is equivalent to function main(frame), but takes parameters for use in other modules. The langcode is optional and is "Script error: No such module "WikidataIB"." by default on Script error: No such module "WikidataIB"..
- quant = plural(quant, langcode)
Function pl
Function pl returns the plural of the unit name, and takes parameters for use in other modules. The langcode is optional and is "Script error: No such module "WikidataIB"." by default on Script error: No such module "WikidataIB"..
- unitnameplural = pl(unitname, langcode)