پودمان:Numeral converter: تفاوت میان نسخه‌ها

۹۷۴ بایت اضافه‌شده ،  ‏۱۷ اکتبر ۲۰۱۸
+convert to fa
(صفحه‌ای تازه حاوی «local p = {} -- Use this function from templates. function p.convert_template(frame) -- Third argument is optional; If true given, signs...» ایجاد کرد)
 
(+convert to fa)
خط ۸: خط ۸:
end
end


-- Use this function directly in modules.
-- Use these function directly in modules.
 
function p.convert_cordination_template(frame)
  return p.convert('en',p.convert_cordination(frame.args[1]))
end
 
function p.convert_cordination(text)
  text = tostring(text)
  text = mw.ustring.gsub(text, "شمالی", "N")
  text = mw.ustring.gsub(text, "شرقی", "E")
  text = mw.ustring.gsub(text, "جنوبی", "S")
  text = mw.ustring.gsub(text, "غربی", "W")
  return text
end
 
function p.convert_Fa_cordination(text)
  text = tostring(text)
  text = mw.ustring.gsub(text,"N", "شمالی")
  text = mw.ustring.gsub(text,"E", "شرقی")
  text = mw.ustring.gsub(text,  "S","جنوبی")
  text = mw.ustring.gsub(text, "W","غربی")
  return text
end
 
function p.convert(lang, text, signs, virgule)
function p.convert(lang, text, signs, virgule)
   text = tostring(text)
   text = tostring(text)
خط ۱۵: خط ۳۸:


   if lang == "fa" or lang == "ur" or lang == "mzn" or lang == "glk" then -- برای فارسی، اردو، مازندرانی، گیلکی
   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, "[]", "۰")
     text = mw.ustring.gsub(text, "[11]", "1")
     text = mw.ustring.gsub(text, "[]", "۱")
     text = mw.ustring.gsub(text, "[22]", "2")
     text = mw.ustring.gsub(text, "[]", "۲")
     text = mw.ustring.gsub(text, "[33]", "3")
     text = mw.ustring.gsub(text, "[]", "۳")
     text = mw.ustring.gsub(text, "[44]", "4")
     text = mw.ustring.gsub(text, "[]", "۴")
     text = mw.ustring.gsub(text, "[55]", "5")
     text = mw.ustring.gsub(text, "[]", "۵")
     text = mw.ustring.gsub(text, "[66]", "6")
     text = mw.ustring.gsub(text, "[]", "۶")
     text = mw.ustring.gsub(text, "[77]", "7")
     text = mw.ustring.gsub(text, "[]", "۷")
     text = mw.ustring.gsub(text, "[88]", "8")
     text = mw.ustring.gsub(text, "[]", "۸")
     text = mw.ustring.gsub(text, "[99]", "9")
     text = mw.ustring.gsub(text, "[]", "۹")
    text = mw.ustring.gsub(text, "[.]", "٫")
     if type(signs) ~= "nil" then
     if type(signs) ~= "nil" then
       text = mw.ustring.gsub(text, "%.", "٫")
       text = mw.ustring.gsub(text, "%.", "٫")
      --تبدیل % به درصد فارسی ٪ را نگذاشتم چون ممکن است کدهای درصدی وارد شده به پودمان را خراب کند.
     end
     end
   elseif lang == "ar" or lang == "ckb" or lang == "ks" then -- برای عربی، کردی سورانی، کشمیری
   elseif lang == "ar" or lang == "ckb" or lang == "ks" then -- برای عربی، کردی سورانی، کشمیری
     text = mw.ustring.gsub(text, "[00]", "0")
     text = mw.ustring.gsub(text, "[۰0]", "٠")
     text = mw.ustring.gsub(text, "[11]", "1")
     text = mw.ustring.gsub(text, "[۱1]", "١")
     text = mw.ustring.gsub(text, "[22]", "2")
     text = mw.ustring.gsub(text, "[۲2]", "٢")
     text = mw.ustring.gsub(text, "[33]", "3")
     text = mw.ustring.gsub(text, "[۳3]", "٣")
     text = mw.ustring.gsub(text, "[44]", "4")
     text = mw.ustring.gsub(text, "[۴4]", "٤")
     text = mw.ustring.gsub(text, "[55]", "5")
     text = mw.ustring.gsub(text, "[۵5]", "٥")
     text = mw.ustring.gsub(text, "[66]", "6")
     text = mw.ustring.gsub(text, "[۶6]", "٦")
     text = mw.ustring.gsub(text, "[77]", "7")
     text = mw.ustring.gsub(text, "[۷7]", "٧")
     text = mw.ustring.gsub(text, "[88]", "8")
     text = mw.ustring.gsub(text, "[۸8]", "٨")
     text = mw.ustring.gsub(text, "[99]", "9")
     text = mw.ustring.gsub(text, "[۹9]", "٩")
   elseif lang and lang ~= "" then -- برای همهٔ زبان‌های دیگر
   elseif lang and lang ~= "" then -- برای همهٔ زبان‌های دیگر
     text = mw.ustring.gsub(text, "[00]", "0")
     text = mw.ustring.gsub(text, "[۰٠]", "0")
     text = mw.ustring.gsub(text, "[11]", "1")
     text = mw.ustring.gsub(text, "[۱١]", "1")
     text = mw.ustring.gsub(text, "[22]", "2")
     text = mw.ustring.gsub(text, "[۲٢]", "2")
     text = mw.ustring.gsub(text, "[33]", "3")
     text = mw.ustring.gsub(text, "[۳٣]", "3")
     text = mw.ustring.gsub(text, "[44]", "4")
     text = mw.ustring.gsub(text, "[۴٤]", "4")
     text = mw.ustring.gsub(text, "[55]", "5")
     text = mw.ustring.gsub(text, "[۵٥]", "5")
     text = mw.ustring.gsub(text, "[66]", "6")
     text = mw.ustring.gsub(text, "[۶٦]", "6")
     text = mw.ustring.gsub(text, "[77]", "7")
     text = mw.ustring.gsub(text, "[۷٧]", "7")
     text = mw.ustring.gsub(text, "[88]", "8")
     text = mw.ustring.gsub(text, "[۸٨]", "8")
     text = mw.ustring.gsub(text, "[99]", "9")
     text = mw.ustring.gsub(text, "[۹٩]", "9")
     text = mw.ustring.gsub(text, "٫", ".")
     text = mw.ustring.gsub(text, "٫", ".")
    text = mw.ustring.gsub(text, "٪", "%")
     if type(virgule) ~= "nil" then
     if type(virgule) ~= "nil" then
       text = mw.ustring.gsub(text, "،", ",")
       text = mw.ustring.gsub(text, "،", ",")
      text = mw.ustring.gsub(text, "٪", "%")
     end
     end
   end
   end
کاربر ناشناس