![]() | This is the
module sandbox page for
Module:Convert to eastern arabic numerals (
diff). See also the companion subpage for test cases ( run). |
This module converts from Western Arabic numerals (i.e. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9) to Eastern Arabic numerals (i.e. ٩ ,٨ ,٧ ,٦ ,٥ ,٤ ,٣ ,٢ ,١ ,٠)
This should generally be invoked from the corresponding template {{ Eastern arabic numerals}}; however it make be directly invoked as well
{{#invoke:Convert to eastern arabic numerals|convert|3.1415}}
Load the module with the following code:
local mConvertNumerals = require('Module:Convert to eastern arabic numerals')
And then from there you can convert using the _convert
function.
mConvertNumerals._convert({"3.1415"})
local p = {}
local CONVERSION_TABLE = {
"0" = "٠",
"1" = "١",
"2" = "٢",
"3" = "٣",
"4" = "٤",
"5" = "٥",
"6" = "٦",
"7" = "٧",
"8" = "٨",
"9" = "٩",
"." = ","
}
function p._convert(args)
if not args or not args1 then
return "Error! Arguments provided are null"
end
local num_str = tostring(args1])
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
return p
![]() | This is the
module sandbox page for
Module:Convert to eastern arabic numerals (
diff). See also the companion subpage for test cases ( run). |
This module converts from Western Arabic numerals (i.e. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9) to Eastern Arabic numerals (i.e. ٩ ,٨ ,٧ ,٦ ,٥ ,٤ ,٣ ,٢ ,١ ,٠)
This should generally be invoked from the corresponding template {{ Eastern arabic numerals}}; however it make be directly invoked as well
{{#invoke:Convert to eastern arabic numerals|convert|3.1415}}
Load the module with the following code:
local mConvertNumerals = require('Module:Convert to eastern arabic numerals')
And then from there you can convert using the _convert
function.
mConvertNumerals._convert({"3.1415"})
local p = {}
local CONVERSION_TABLE = {
"0" = "٠",
"1" = "١",
"2" = "٢",
"3" = "٣",
"4" = "٤",
"5" = "٥",
"6" = "٦",
"7" = "٧",
"8" = "٨",
"9" = "٩",
"." = ","
}
function p._convert(args)
if not args or not args1 then
return "Error! Arguments provided are null"
end
local num_str = tostring(args1])
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
return p