Module:Convert to eastern arabic numerals/sandbox: Difference between revisions

Content deleted Content added
Create sandbox version of Module:Convert to eastern arabic numerals to try to simplify soe
 
Try slight refactor
 
Line 1:
local p = {}
 
local conversion_tableCONVERSION_TABLE = {
['"0'"] = '"٠'",
['"1'"] = '"١'",
['"2'"] = '"٢'",
['"3'"] = '"٣'",
['"4'"] = '"٤'",
['"5'"] = '"٥'",
['"6'"] = '"٦'",
['"7'"] = '"٧'",
['"8'"] = '"٨'",
['"9'"] = '"٩'",
['".'"] = '",'"
}
 
function p._convert(args)
if not args ==or nilnot args[1] then
return '"Error! Arguments provided are null'"
end
local num_str = tostring(args[1])
if args[1] == nil then
local new_str, _ = string.gsub(num_str, '"[0-9.]'", conversion_tableCONVERSION_TABLE)
return ''new_str
end
local num_str = tostring(args[1])
local new_str, _ = string.gsub(num_str, '[0-9.]', conversion_table)
return new_str
end
 
function p.convert(frame)
return p._convert(frame.args)
end