Difference between revisions of "Module:Convert/doc"

From blackwiki
Jump to navigation Jump to search
blackwiki>DePiep
m (high-risk 912183)
blackwiki>Johnuniq
Line 7: Line 7:
 
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 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:
+
== Templates and modules ==
 +
Templates that invoke this module are:
 
* [[Template:Convert]]
 
* [[Template:Convert]]
 +
* [[Template:Cvt]] {{green|1=(convert with abbr=on)}}
  
 
The following modules are required:
 
The following modules are required:
Line 19: Line 21:
 
* [[Module:ConvertNumeric]] – code to spell an input value in words (only English is supported; however, see [[:vi:Module:ConvertNumeric]])
 
* [[Module:ConvertNumeric]] – code to spell an input value in words (only English is supported; however, see [[:vi:Module:ConvertNumeric]])
  
For Wikidata support you need the following modules:
+
For Wikidata support the following modules are required:
 
* [[Module:Convert/wikidata]]
 
* [[Module:Convert/wikidata]]
 
* [[Module:Convert/wikidata/data]]
 
* [[Module:Convert/wikidata/data]]
Line 37: Line 39:
  
 
[[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.
 
[[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.
 +
 +
[[Module talk:Convert/show]] lists all unit links so they can be checked.
  
 
== Sandbox ==
 
== Sandbox ==
 
When making a change, copy the current modules to the sandbox pages, then edit the sandbox copies:
 
When making a change, copy the current modules to the sandbox pages, then edit the sandbox copies:
* [[Module:Convert/sandbox]]
+
{{#invoke:convert/tester|compare}}
* [[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>):
 
Use the following template to test the results (example <code><nowiki>{{convert/sandbox|123|lb|kg}}</nowiki></code>):
Line 73: Line 74:
 
== To do ==
 
== To do ==
 
Document the modules to access Wikidata!
 
Document the modules to access Wikidata!
{{#invoke:convert/tester|compare}}
 
  
 
== Module version history ==
 
== Module version history ==
Line 96: Line 96:
 
* [[Template talk:Convert/Archive August 2017#Module version 19|Version 19]] August 2017
 
* [[Template talk:Convert/Archive August 2017#Module version 19|Version 19]] August 2017
 
* [[Template talk:Convert/Archive December 2017#Module version 20|Version 20]] December 2017 {{green|(changed symbols for dot and micro)}}
 
* [[Template talk:Convert/Archive December 2017#Module version 20|Version 20]] December 2017 {{green|(changed symbols for dot and micro)}}
 +
* [[Template talk:Convert/Archive January 2018#Module version 21|Version 21]] January 2018 {{green|(remove many deprecated options)}}
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
 
[[Category:Modules that add a tracking category]]
 
[[Category:Modules that add a tracking category]]
 
}}</includeonly>
 
}}</includeonly>

Revision as of 00:58, 3 February 2018

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. For usage information, see Help:Convert.

Templates and modules

Templates that invoke this module are:

The following modules are required:

The following modules are optional and are used only if required and if the module exists:

For Wikidata support the following modules are required:

The following help pages are available:

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/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.

Module talk:Convert/show lists all unit links so they can be checked.

Sandbox

When making a change, copy the current modules to the sandbox pages, then edit the sandbox copies:

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.

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

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=0namespaces (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. For example, at enwiki the option |lk=on can be used to link each displayed unit to its article. The "lk" and "on" 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 translation guide for more information.

To do

Document the modules to access Wikidata!

Module version history