Module:Convert/doc
This is a documentation subpage for Module:Convert (see that page for the module itself). It contains usage information, categories and other content that is not part of the original module page. |
This module converts a value from one unit of measurement to another. For example:
{{convert|123|lb|kg}}
→ 123 pounds (56 kg)
The module is called using a template—parameters passed to the template are used by this module to control how a conversion is performed. For example, units can be abbreviated (like kg
), or displayed as names (like kilogram
), and the output value can be rounded to a specified precision.
The template that invokes this module is:
The following modules are required:
- Module:Convert – (this module) code to convert units
- Module:Convert/data – unit definitions
- Module:Convert/text – text messages, and parameter names and values
The following modules are optional and are used only if required and if the module exists:
- Module:Convert/extra – extra (temporary) unit definitions; used if a unit is not found in Module:Convert/data
- Module:ConvertNumeric – code to spell an input value in words (only English is supported)
A page containing a convert error is added to the following hidden category, providing the page is in a specified namespace (articles, by default):
Units are defined in the wikitext of the master list of units.
- Module:Convert/documentation/conversion data/doc – master list of unit definitions
- Module:Convert/makeunits – translates wikitext from the master list to Lua
- Module talk:Convert/makeunits – makeunits results; copy the text to Module:Convert/data
Module:Convert/data is transcluded into every page using the convert module, so experimenting with a new unit in that module would involve a significant overhead. The Module:Convert/extra module is an alternative which is only transcluded on pages with a unit that is not defined in the main data module.
Sandbox[edit]
When making a change, copy the current modules to the sandbox pages, then edit the sandbox copies:
- Module:Convert/sandbox
- Module:Convert/data/sandbox
- Module:Convert/text/sandbox
- Module:Convert/extra/sandbox
Use the following template to test the results (example {{convert/sandbox|123|lb|kg}}
):
Template:Convert/sandbox invokes Module:Convert/sandbox with parameter |sandbox=sandbox
which causes convert to use the sandbox modules rather than the normal modules.
The following should be used to test the results of editing the convert modules.
- Template:Convert/testcases#Sandbox testcases – links to testcases
- Module:Convert/tester – module to run tests by comparing template output with fixed text
It is not necessary to save a testcases page before viewing test results. For example, Template:Convert/testcases/sandbox4 could be edited to change the tests. While still editing that page, paste "Template talk:Convert/testcases/sandbox4
" (without quotes) into the page title box under "Preview page with this template", then click "Show preview".
Configuration[edit]
The template that invokes this module can define options to configure the module. For example:
{{#invoke:convert|convert|numdot=,|numsep=.}}
- Sets the decimal mark to be a comma, and the thousands separator to be a dot.
Other options, with default values, are:
|maxsigfig=14
– maximum number of significant figures|nscat=0
– namespaces (comma separated) in which an error or warning adds a category to the page|warnings=0
– 0 (zero) disables warnings; 1 shows important warnings; 2 shows all warnings
An option in the template can specify that the sandbox versions of the modules be used. If specified, the text on the right-hand side of the equals sign must be the name of the subpage for each sandbox module.
|sandbox=sandbox
– omit for normal operation
All text used for input parameters and for output messages and categories can be customized. In addition, input and output numbers can be formatted and can use digits in the local language.
Error
Could not read wikitext from "Module:Convert/wikidata".