User:Wikid77/Template:Kmbot

From Wikipedia, the free encyclopedia
The Template:Kmbot simply compares the given distance to some common-sense levels of distance, and then auto-formats the distance in decimal miles xx.x, or rounded whole miles or tens of miles, based on number sense of the culture. Usage:
{{kmbot|xxx.x}}
{{kmbot|m=xxx.x}}
{{kmbot|1.2}} - for 1.2 kilometers.
{{kmbot|5,300}} - for 5,300 kilometers.
{{kmbot|5|abbr=off}} - show "miles".
Options include: abbr=off, sp=us, disp=/, disp=or, adj=on (explained below).

The distance levels for choosing format are based on kilometers (km):

km < .1: shows miles to 5 decimals, x.xxxxx
km < 50: shows miles to 1 decimal, xx.x
km < 1000: shows rounded to whole miles.
km > 1000: shows rounded to 10s of miles.

The parameter "km" defaults to the first unnamed parameter. For example:

{{kmbot|abbr=off|34}} - uses "34"

Parameters:

  • Parameter 1 is kilometers (or km=), can contain commas.
  • abbr=off - turns off abbreviation, shows "miles" (default: abbr=on).
  • sp=us - triggers U.S. spelling, shows "kilometers" else "kilometres" (default: sp=en).
  • disp=/   - displays slash between numbers (default: disp=b).
  • disp=or - displays "or" between numbers (default: parentheses).
  • adj=on - turns on adjective-mode, shows "-km" (default: adj=off).

Those parameters are the same as in template {{Convert}}.

NOTE: When translating articles from German Wikipedia, use template kmbot
to handle the German distance templates.