Module:Sandbox/Szqecs/New Taiwan dollar

-- Function allowing for consistent treatment of boolean-like wikitext input. local function yesno(val, default) val = type(val) == 'string' and val:lower or val if val == nil then return nil elseif val == true or val == 'yes' or val == 'y'		or val == 'true' or val == 't'		or val == 'on' or tonumber(val) == 1 then return true elseif val == false or val == 'no' or val == 'n'		or val == 'false' or val == 'f'		or val == 'off' or tonumber(val) == 0 then return false else return default end end

local p = {}

function p._main(args, data) if args.link == true then symbol = '\[\[New Taiwan dollar|NT$\]\]' else symbol = 'NT$' end local lang = mw.getContentLanguage local Min = lang:formatNum(args.Min) local Max = '–' .. lang:formatNum(args.Max) local magTable = { ['k'] = ' thousand' ,['m'] = ' million' ,['b'] = ' billion' ,['t'] = ' trillion' ,['q'] = ' quadrillion' }	local mag = ' ' .. magTable[args.mag] local MinC = args.Min / USDTWD if MaxC then MaxC = '–' .. args.Max / USDTWD end if args.showDate == false then year = '' else year = ' in ' .. year end if args.convert == true then conversion = table.concat({' (US$', MinC, MaxC, magC, today, ')'}) else conversion = '' end return table.concat({symbol, Min, Max, mag, year, conversion}) end

function p.main(frame) local _args = frame:getParent.args or frame.args local args = { Min = tonumber(_args[1]) ,Max = tonumber(_args[2]) ,link = yesno(_args.link) or yesno(_args.l) or true ,mag = _args.mag or _args.m or _args.o	,convert = yesno(_args.conv) or yesno(_args.c) or true ,year = _args.year ,showYear = yesno(_args.showYear) or yesno(_args.sy) or yesno(_args.sd) or false }	local data = { ['USDTWD'] = mw.loadData('Module:New Taiwan dollar/USDTWD annual') ,['CPI'] = mw.loadData('Module:New Taiwan dollar/CPI annual') }	return p._main(args, data) end