User:Happy-melon/Convert

This is a rough manual for the new

on enwiki is a behemoth of a construction that just about manages to do this sort of conversion, taking  and outputting "5 miles (8 km)", etc. To port this to another wiki requires copying over three and a half thousand subtemplates. The additional load produced by including numerous copies of this template is measurable on large pages on enwiki, and it eats voraciously into the template limits.

This revision introduces, outputting "8 kilometres". We take advantage of the availability of regular expressions to allow the unit to be included in the input string, which should improve usability. There are options for the unit to be linked, and/or abbreviated:


 * &rarr; "5 km"
 * &rarr; "5 kilometres" if MediaWiki:pfunc-convert-unit-kilometre-link contains "Foo"

It is also possible to specify that the output unit should be the same as the input unit, but maybe linked and/or abbreviated:


 * &rarr; "5 miles"

Between these options, it should be very easy to reconstruct the functionality of as a simple wrapper template: indeed something like this is a crude but effective start: