แม่แบบ:Infobox person/weight/doc

จากวิกิพีเดีย สารานุกรมเสรี

แม่แบบ:Infobox person/weight is one of three templates used to automatically add conversions of weight measurements displayed by Template:Infobox person and other infoboxes with a |weight= parameter.

  1. Template:Infobox person/weight changes text for units of weight to the abbreviations "kg", "lb", or "st", then passes the string to:
  2. Template:Infobox person/weight/locate which replaces any instances of   with a space, and determines the positions of "kg", "lb", or "st" within that string, all of which is passed to:
  3. Template:Infobox person/weight/switch which does the conversion

Usage[แก้]

kilograms[แก้]

  • {{Infobox person/weight|100 kg}} → 100 กิโลกรัม (220 ปอนด์)
  • {{Infobox person/weight|1 kilogram}} → 1 กิโลกรัม (2 ปอนด์)
  • {{Infobox person/weight|108 kgs}} → 108 กิโลกรัม (238 ปอนด์)
  • {{Infobox person/weight|111 kilograms}} → 111 กิโลกรัม (245 ปอนด์)

pounds[แก้]

  • {{Infobox person/weight|200 lb}} → 200 ปอนด์ (91 กิโลกรัม)
  • {{Infobox person/weight|1 pound}} → 1 ปอนด์ (0 กิโลกรัม)
  • {{Infobox person/weight|238 lbs}} → 238 ปอนด์ (108 กิโลกรัม)
  • {{Infobox person/weight|245 pounds}} → 245 ปอนด์ (111 กิโลกรัม)

stone[แก้]

  • {{Infobox person/weight|10 st}} → 10 สโตน (140 ปอนด์; 64 กิโลกรัม)
  • {{Infobox person/weight|1 stone}} → 1 สโตน (14 ปอนด์; 6 กิโลกรัม)
  • {{Infobox person/weight|17 sts}} → 17 สโตน (238 ปอนด์; 108 กิโลกรัม)

stone and pounds[แก้]

  • {{Infobox person/weight|17 st 7 lb}} → 17 สโตน 7 ปอนด์ (245 ปอนด์; 111 กิโลกรัม)
  • {{Infobox person/weight|17 sts 7 lbs}} → 17 สโตน 7 ปอนด์ (245 ปอนด์; 111 กิโลกรัม)
  • {{Infobox person/weight|17 stone 7 pounds}} → 17 สโตน 7 ปอนด์ (245 ปอนด์; 111 กิโลกรัม)

no space or  [แก้]

  • {{Infobox person/weight|108kilograms}} → 108 กิโลกรัม (238 ปอนด์)
  • {{Infobox person/weight|238 pounds}} → 238 ปอนด์ (108 กิโลกรัม)

year and reference[แก้]

  • {{Infobox person/weight|108 kgs (2012)}} → 108 กิโลกรัม (238 ปอนด์) (2012)
  • {{Infobox person/weight|238 lbs (2012)<ref>citation goes here</ref>}} → 238 ปอนด์ (108 กิโลกรัม) (2012)[1]
Example references
  1. citation goes here

weight ranges[แก้]

with input containing en dash (–):

  • {{Infobox person/weight|108111 kg}} → 108–111 กิโลกรัม (238–245 ปอนด์)
  • {{Infobox person/weight|238245 lb}} → 238–245 ปอนด์ (108–111 กิโลกรัม)
  • {{Infobox person/weight|1718 st}} → 17–18 สโตน (238–252 ปอนด์; 108–114 กิโลกรัม)

with input containing hyphen (-); output is changed to en dash by {{Convert}}:

  • {{Infobox person/weight|108-111 kg}} → 108–111 กิโลกรัม (238–245 ปอนด์)
  • {{Infobox person/weight|238-245 lb}} → 238–245 ปอนด์ (108–111 กิโลกรัม)
  • {{Infobox person/weight|17-18 st}} → 17–18 สโตน (238–252 ปอนด์; 108–114 กิโลกรัม)

optional stlb output[แก้]

with |kg-stlb=yes:

  • {{Infobox person/weight|kg-stlb=yes|100 kg}} → 100 กิโลกรัม (220 ปอนด์; 15 สโตน 10 ปอนด์)
  • {{Infobox person/weight|kg-stlb=yes|108–111 kg}} → 108–111 กิโลกรัม (238–245 ปอนด์; 17 สโตน 0 ปอนด์–17 สโตน 7 ปอนด์)

with |lb-stlb=yes:

  • {{Infobox person/weight|lb-stlb=yes|200 lb}} → 200 ปอนด์ (91 กิโลกรัม; 14 สโตน 4 ปอนด์)
  • {{Infobox person/weight|lb-stlb=yes|238-245 lb}} → 238–245 ปอนด์ (108–111 กิโลกรัม; 17 สโตน 0 ปอนด์–17 สโตน 7 ปอนด์)

Exceptions[แก้]

Does not replace numbers in hard-coded conversions (examples intentionally show incorrect conversions), but does replace units with abbreviations "kg", "lb", or "st":

  • {{Infobox person/weight|108 kilograms (229 pounds)}} → 108 kg (229 lb)
  • {{Infobox person/weight|238 pounds (119 kilograms)}} → 238 lb (119 kg)
  • {{Infobox person/weight|17 stone (229 pounds; 119 kilograms)}} → 17 st (229 lb; 119 kg)

Does not replace numeric output of conversion templates such as {{convert}} (examples have precision different than usual), but does replace units with abbreviations "kg", "lb", or "st":

  • {{Infobox person/weight|{{convert|108.1|kg|lb|1|abbr=off}}}} → 108.1 kg (238.3 lb)
    • compare to: {{convert|108.1|kg|lb|1|abbr=off}} → 108.1 กิโลกรัม (238.3 ปอนด์)
  • {{Infobox person/weight|{{convert|238.2|lb|kg|2|abbr=off}}}} → 238.2 lb (108.05 kg)
    • compare to: {{convert|238.2|lb|kg|2|abbr=off}} → 238.2 ปอนด์ (108.05 กิโลกรัม)
  • {{Infobox person/weight|{{convert|17.3|st|1|abbr=off}}}} → 17.3 st (242.2 lb; 109.9 kg)
    • compare to: {{convert|17.3|st|1|abbr=off}} → 17.3 สโตน (242.2 ปอนด์; 109.9 กิโลกรัม)

Period at end of abbreviation displays after the conversion:

  • {{Infobox person/weight|5 kg.}} → 5 กิโลกรัม (11 ปอนด์)
  • {{Infobox person/weight|5 lb.}} → 5 ปอนด์ (2 กิโลกรัม)
  • {{Infobox person/weight|5 st.}} → 5 สโตน (70 ปอนด์; 32 กิโลกรัม)

Multiple unit conversions won't work if input contains periods or commas:

  • {{Infobox person/weight|17 st. 5 lb}} → 17 สโตน 5 ปอนด์ (243 ปอนด์; 110 กิโลกรัม)
  • {{Infobox person/weight|17 st, 5 lb}} → 17 สโตน 5 ปอนด์ (243 ปอนด์; 110 กิโลกรัม)