پودمان:Numeral converter
پرش به ناوبری
پرش به جستجو
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 == "fa" or lang == "ur" or lang == "mzn" or lang == "glk" then -- برای فارسی، اردو، مازندرانی، گیلکی
text = mw.ustring.gsub(text, "[00]", "0")
text = mw.ustring.gsub(text, "[11]", "1")
text = mw.ustring.gsub(text, "[22]", "2")
text = mw.ustring.gsub(text, "[33]", "3")
text = mw.ustring.gsub(text, "[44]", "4")
text = mw.ustring.gsub(text, "[55]", "5")
text = mw.ustring.gsub(text, "[66]", "6")
text = mw.ustring.gsub(text, "[77]", "7")
text = mw.ustring.gsub(text, "[88]", "8")
text = mw.ustring.gsub(text, "[99]", "9")
if type(signs) ~= "nil" then
text = mw.ustring.gsub(text, "%.", "٫")
end
elseif lang == "ar" or lang == "ckb" or lang == "ks" then -- برای عربی، کردی سورانی، کشمیری
text = mw.ustring.gsub(text, "[00]", "0")
text = mw.ustring.gsub(text, "[11]", "1")
text = mw.ustring.gsub(text, "[22]", "2")
text = mw.ustring.gsub(text, "[33]", "3")
text = mw.ustring.gsub(text, "[44]", "4")
text = mw.ustring.gsub(text, "[55]", "5")
text = mw.ustring.gsub(text, "[66]", "6")
text = mw.ustring.gsub(text, "[77]", "7")
text = mw.ustring.gsub(text, "[88]", "8")
text = mw.ustring.gsub(text, "[99]", "9")
elseif lang and lang ~= "" then -- برای همهٔ زبانهای دیگر
text = mw.ustring.gsub(text, "[00]", "0")
text = mw.ustring.gsub(text, "[11]", "1")
text = mw.ustring.gsub(text, "[22]", "2")
text = mw.ustring.gsub(text, "[33]", "3")
text = mw.ustring.gsub(text, "[44]", "4")
text = mw.ustring.gsub(text, "[55]", "5")
text = mw.ustring.gsub(text, "[66]", "6")
text = mw.ustring.gsub(text, "[77]", "7")
text = mw.ustring.gsub(text, "[88]", "8")
text = mw.ustring.gsub(text, "[99]", "9")
text = mw.ustring.gsub(text, "٫", ".")
if type(virgule) ~= "nil" then
text = mw.ustring.gsub(text, "،", ",")
end
end
return text
end
return p