Module:Person weight: Difference between revisions

Content deleted Content added
Fix for when Convert template outputs [ [kilogram] ]s - module changed that to [ [kg] ]s - should be [ [Kilograms|kg] ] instead. Tested first with Module:Person weight/sandbox and Template:Infobox person/weight/testcases.
Remove periods or commas after unit names. Fixes trailing character after single unit conversion. Fixes no conversion when multiple units separated by either character. Tested first with /sandbox and test cases.
 
Line 4:
 
local function clean_weight(s)
 
s = mw.ustring.gsub(s, 'kilogram', 'kg')
s = mw.ustring.gsub(s, 'stone', 'st')
s = mw.ustring.gsub(s, 'pound', 'lb')
s = mw.ustring.gsub(s, 'kgs', 'kg')
s = mw.ustring.gsub(s, 'kg[%.,]', 'kg')
 
s = mw.ustring.gsub(s, 'pound', 'lb')
s = mw.ustring.gsub(s, 'lbs', 'lb')
s = mw.ustring.gsub(s, 'lb[%.,]', 'lb')
 
s = mw.ustring.gsub(s, 'stone', 'st')
s = mw.ustring.gsub(s, 'sts', 'st')
s = mw.ustring.gsub(s, 'st[%.,]', 'st')
 
s = mw.ustring.gsub(s, '%[%[kg%]%]s', '[[Kilogram|kg]]')