मोड्युल:Numeral converter
Documentation for this module may be created at मोड्युल:Numeral converter/doc
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_cordination(text)
text = tostring(text)
text = mw.ustring.gsub(text, "उत्तर", "N")
text = mw.ustring.gsub(text, "उ॰", "N")
text = mw.ustring.gsub(text, "पूर्व", "E")
text = mw.ustring.gsub(text, "पू॰", "E")
text = mw.ustring.gsub(text, "दक्षिण", "S")
text = mw.ustring.gsub(text, "द॰", "S")
text = mw.ustring.gsub(text, "पश्चिम", "W")
text = mw.ustring.gsub(text, "प॰", "W")
return text
end
function p.convert(lang, text, signs, virgule)
text = tostring(text)
signs = signs or nil
virgule= virgule or nil
if lang == "ne" or lang == "mai" or lang == "bpy" or lang == "ne" 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 == "ne" or lang == "mai" 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