मोड्युल:Numeral converter
लुआ त्रुटि मोड्युल:Documentation में पंक्ति 144 पर: message: type error in message cfg.container (string expected, got nil)।
local p = {}
-- Use this function from templates.
function p.convert_template(frame)
-- Third argument is optional; If true given, signs like dot (.) will be replaced.
frame.args[3] = frame.args[3] or nil
return p.convert(frame.args[1], frame.args[2], frame.args[3])
end
-- Use this function directly in modules.
function p.convert(lang, text, signs, virgule)
text = tostring(text)
signs = signs or nil
virgule= virgule or nil
if lang == "mai" or lang == "as" or lang == "bpy" or lang == "mai" then
text = mw.ustring.gsub(text, "[0०]", "०")
text = mw.ustring.gsub(text, "[1१]", "१")
text = mw.ustring.gsub(text, "[2२]", "२")
text = mw.ustring.gsub(text, "[3३]", "३")
text = mw.ustring.gsub(text, "[4४]", "४")
text = mw.ustring.gsub(text, "[5५]", "५")
text = mw.ustring.gsub(text, "[6६]", "६")
text = mw.ustring.gsub(text, "[7७]", "७")
text = mw.ustring.gsub(text, "[8८]", "८")
text = mw.ustring.gsub(text, "[9९]", "९")
if type(signs) ~= "nil" then
text = mw.ustring.gsub(text, "%.", "٫")
end
elseif lang == "mai" or lang == "ne" or lang == "bpy" then
text = mw.ustring.gsub(text, "[०0]", "०")
text = mw.ustring.gsub(text, "[१1]", "१")
text = mw.ustring.gsub(text, "[२2]", "२")
text = mw.ustring.gsub(text, "[३3]", "३")
text = mw.ustring.gsub(text, "[४4]", "४")
text = mw.ustring.gsub(text, "[५5]", "५")
text = mw.ustring.gsub(text, "[६6]", "६")
text = mw.ustring.gsub(text, "[७7]", "७")
text = mw.ustring.gsub(text, "[८8]", "८")
text = mw.ustring.gsub(text, "[९9]", "९")
elseif lang and lang ~= "" then -- برای همهٔ زبانهای دیگر
text = mw.ustring.gsub(text, "[००]", "0")
text = mw.ustring.gsub(text, "[११]", "1")
text = mw.ustring.gsub(text, "[२२]", "2")
text = mw.ustring.gsub(text, "[३३]", "3")
text = mw.ustring.gsub(text, "[४४]", "4")
text = mw.ustring.gsub(text, "[५५]", "5")
text = mw.ustring.gsub(text, "[६६]", "6")
text = mw.ustring.gsub(text, "[७७]", "7")
text = mw.ustring.gsub(text, "[८८]", "8")
text = mw.ustring.gsub(text, "[९९]", "9")
text = mw.ustring.gsub(text, "٫", ".")
if type(virgule) ~= "nil" then
text = mw.ustring.gsub(text, "،", ",")
end
end
return text
end
return p