Jump to content

Module:Convert/doc

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Johnuniq (talk | contribs) at 09:43, 19 July 2013 (overview). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

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 precision of the output value can be specified.

The template that invokes this module is:

The following modules are required:

Many testcase pages are available. Currently, the testcases compare the output from the current Template:Convert with the output from Template:Convert/sandboxlua.

Units are defined in the wikitext of the master list of units. Wikitext copied from that page is translated to create the unit definitions by running a Lua script on a local computer.

Configuration

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
  • warnings = no – yes if invalid options should show a warning

Other configuration is available in the translation_table at Module:Convert/text. For example, bn:Module:Convert/text uses:

  • group = 2 – group numbers 3 digits, then 2 digits
  • plural_suffix = '' – disable plural unit names (do not append "s")
  • Tables to translate digits to and from the English digits used in calculations.

Module:Convert/text contains nearly all text used for input parameters and for output messages and categories. For example, lk=on may be used at en.wikipedia to link each displayed unit to its article. The text module could be edited to replace "lk" and "on" with any desired text.