Module:Sandbox/DaxServer explained

local p = local getArgs = require('Module:Arguments').getArgs

function p.main(frame) local args = getArgs(frame) return frame:expandTemplate -- return mw.dumpObject(args)end

function p._main(args) local value = args[1] or nil local cf = args[2] or nil local rd = args[3] or nil local lk = args['lk'] or nil local year = args['year'] or nil local to = args['to'] or nil local mode = args['mode'] or nil -- check_value(value, 'number') cf = check_cf(cf) lk = check_lk(lk) local paisaResult = paisa(value, cf, lk) if paisaResult[1] then return paisaResult[2] end return rupee(value, cf, lk)end

function check_value(value, typeString) assert(type(value)

typeString)end

function check_cf(cf) if cf

nil then return cf end assert(type(cf)

'string') cf = mw.ustring.lower(cf) assert(cf

'k' or cf

'm' or cf

'b' or cf

't' or cf

'l' or cf

'c' or cf

'lc' ) return cfend

-- ToDo Dedupfunction check_lk(cf) if cf

nil then return cf end assert(type(cf)

'string') cf = mw.ustring.lower(cf) assert(cf

'on' or cf

'r' or cf

'b' or cf

't' or cf

'l' or cf

'c' or cf

'lc' ) return cfend

function paisa(value, cf, lk) -- ToDo Support ranges value = tonumber(value) if value >= 1 or cf ~= nil then return end local paisa = value * 100 local word = 'pais' .. (paisa

1 and 'a' or 'e') if lk

'on' or lk

'r' then word = '' .. word .. '' end return end

function rupee(value, cf, lk) -- ToDo Support ranges value = tonumber(value) -- ToDo Incorrect, use frame:expandTemplate local word = (lk

'on' or lk

'r') and 'Indian Rupee' or 'Indian Rupee' word = '

' .. word local lang = mw.getContentLanguage local function formatnum(num) return lang:parseFormattedNumber(num) and lang:formatNum(lang:parseFormattedNumber(num)) or num end if cf

'k' then word = word .. formatnum(value * 1E3) elseif cf

'm' then word = word .. formatnum(value) .. ' million' elseif cf

'b' then local billion = (lk

'on' or lk

'b') and ' billion' or ' billion' word = word .. formatnum(value) .. billion elseif cf

't' then local trillion = (lk

'on' or lk

't') and ' trillion' or ' trillion' word = word .. formatnum(value) .. trillion elseif cf

'l' then local lakh = (lk

'on' or lk

'l') and ' lakh' or ' lakh' word = word .. formatnum(value) .. lakh elseif cf

'c' then local crore = (lk

'on' or lk

'c') and ' crore' or ' crore' word = word .. formatnum(value) .. crore elseif cf

'lc' then local lakh = (lk

'on' or lk

'l') and ' lakh' or ' lakh' local crore = (lk

'on' or lk

'c') and ' crore' or ' crore' word = word .. formatnum(value) .. lakh .. crore else word = word .. formatnum(value) end word = word .. '

' return wordend

return p