FANDOM


{{Transwiki guide|text=See [[Template:Convert/Transwiki guide|'''how to copy the convert template''']] for information on copying this module and modifying it for use on another wiki.}}
{{High-risk|819000+}}
{{Module rating|p}}
This module converts a value from one unit of measurement to another. For example:
* <code><nowiki>{{convert|123|lb|kg}}</nowiki></code>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 <code>kg</code>), or displayed as names (like <code>kilogram</code>), and the output value can be rounded to a specified precision. For usage information, see [[Help:Convert]].
 
The template that invokes this module is:
* [[Template:Convert]]
 
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; however, see [[:vi:Module:ConvertNumeric]])
 
The following help pages are available:
* [[Help:Convert]] – overview
* [[Help:Convert messages]] – describes error and warning messages; messages link to this page so it is required when the module is copied to another wiki
* [[Help:Convert units]] – overview of units
 
A page containing a convert error is added to the following hidden category, providing the page is in a specified [[WP:Namespace|namespace]] (articles, by default):
* {{clc|Convert errors}}
 
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 ==
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 <code><nowiki>{{convert/sandbox|123|lb|kg}}</nowiki></code>):
* [[Template:Convert/sandbox]]
 
[[Template:Convert/sandbox]] invokes [[Module:Convert/sandbox]] with parameter {{para|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 {{nowrap|"<code>Template talk:Convert/testcases/sandbox4</code>"}} (without quotes) into the page title box under "Preview page with this template", then click "Show preview".
 
== Configuration ==
The template that invokes this module can define options to configure the module. For example:
* <code><nowiki>{{#invoke:convert|convert|numdot=,|numsep=.}}</nowiki></code>
:Sets the [[decimal mark]] to be a comma, and the thousands separator to be a dot.
 
Other options, with default values, are:
* <code>|maxsigfig=14</code> – maximum number of significant figures
* <code>|nscat=0</code>[[WP:Namespace|namespaces]] (comma separated) in which an error or warning adds a category to the page
* <code>|warnings=0</code>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.
* <code>|sandbox=sandbox</code> – omit for normal operation
 
All text used for input parameters and for output messages and categories can be customized. For example, at enwiki the option <code>|lk=on</code> can be used to link each displayed unit to its article. The "<code>lk</code>" and "<code>on</code>" can be replaced with any desired text. In addition, input and output numbers can be formatted and can use digits in the local language. See the [[Template:Convert/Transwiki guide/translate|translation guide]] for more information.
 
== To do ==
Document the modules to access Wikidata!
{{#invoke:convert/tester|compare}}
 
== Module version history ==
* [[Template talk:Convert/Archive December 2013#Request to switch to Module:Convert|Version 1]] December 2013
* [[Template talk:Convert/Archive January 2014#Module v2 soon|Version 2]] January 2014
* [[Template talk:Convert/Archive April 2014#Module version 3|Version 3]] April 2014
* [[Template talk:Convert/Archive July 2014#Module version 4|Version 4]] July 2014
* [[Template talk:Convert/Archive September 2014#Module version 5|Version 5]] September 2014
* [[Template talk:Convert/Archive November 2014#Module version 6|Version 6]] November 2014
* [[Template talk:Convert/Archive December 2014#Module version 7|Version 7]] December 2014
* [[Template talk:Convert/Archive February 2015#Module version 8|Version 8]] February 2015
* [[Template talk:Convert/Archive February 2015#Module version 9|Version 9]] February 2015
* [[Template talk:Convert/Archive May 2015#Module version 10|Version 10]] May 2015
* [[Template talk:Convert/Archive June 2015#Module version 11|Version 11]] June 2015
* [[Template talk:Convert/Archive August 2015#Module version 12|Version 12]] August 2015
* [[Template talk:Convert/Archive March 2016#Module version 13|Version 13]] March 2016
* [[Template talk:Convert/Archive June 2016#Module version 14|Version 14]] June 2016
* [[Template talk:Convert/Archive September 2016#Module version 15|Version 15]] September 2016
* [[Template talk:Convert/Archive January 2017#Module version 16|Version 16]] January 2017
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
[[Category:Modules that add a tracking category]]
}}</includeonly>

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.