‌‌‌‌
 
m 2 revisions imported
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}
local converter = require("Module:Numeral converter")


-- Use this function from templates.
function createItem(colorModifier, iconModifier, catName, subText)
function p.convert_template(frame)
    local s1 = '<div class="content-improvement-item ' .. colorModifier .. ' ' .. iconModifier .. '">'
  -- Third argument is optional; If true given, signs like dot (.) will be replaced.
    local s2 = '[[:رده:' .. catName .. '|<span class="content-improvement-item__subtext-big">'
  frame.args[3] = frame.args[3] or nil
    local s3 = subText .. '</span> <small><span class="content-improvement-item__number-smal">'
  return p.convert(frame.args[1], frame.args[2], frame.args[3])
    local s4 = converter.convert("fa", mw.site.stats.pagesInCategory(catName, pages))
    local s5 = ' مورد</span></small></span>]]</div>'
    return s1 .. s2 .. s3 .. s4 .. s5
end
end


-- 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)
local data = {
  text = tostring(text)
    createItem('-color-golden', '-icon-searchCaseSensitive', 'مقالات منتشر شده در نشریات', 'مقالات حقوقی منتشره در نشریات'),
  text = mw.ustring.gsub(text,"N", "شمالی")
    createItem('-color-golden', '-icon-editUndo', 'کتاب های حقوقی', 'کتاب‌های حقوقی'),
  text = mw.ustring.gsub(text,"E", "شرقی")
        createItem('-color-golden', '-icon-searchCaseSensitive', 'پایان نامه های حقوقی', 'پایان‌نامه‌های حقوقی'),
  text = mw.ustring.gsub(text, "S","جنوبی")
    createItem('-color-golden', '-icon-editUndo', 'رساله های حقوقی', 'رساله‌های حقوقی'),
  text = mw.ustring.gsub(text, "W","غربی")
    createItem('-color-golden', '-icon-tableMergeCells', 'رشته های حقوقی', 'رشته‌های حقوقی'),
  return text
end


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 -- برای فارسی، اردو، مازندرانی، گیلکی
function p.main(frame)
    text = mw.ustring.gsub(text, "[0٠]", "۰")
     local result = ""
     text = mw.ustring.gsub(text, "[1١]", "۱")
     for i = 1, #data, 1 do
     text = mw.ustring.gsub(text, "[2٢]", "۲")
        result = result .. data[i]
    text = mw.ustring.gsub(text, "[3٣]", "۳")
    text = mw.ustring.gsub(text, "[4٤]", "۴")
    text = mw.ustring.gsub(text, "[]", "۵")
    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(signs) ~= "nil" then
      text = mw.ustring.gsub(text, "%.", "٫")
      --تبدیل % به درصد فارسی ٪ را نگذاشتم چون ممکن است کدهای درصدی وارد شده به پودمان را خراب کند.
     end
     end
  elseif lang == "ar" or lang == "ckb" or lang == "ks" then -- برای عربی، کردی سورانی، کشمیری
     return result
     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, "٫", ".")
    text = mw.ustring.gsub(text, "٪", "%")
    if type(virgule) ~= "nil" then
      text = mw.ustring.gsub(text, "،", ",")
      text = mw.ustring.gsub(text, "٪", "%")
    end
  end
 
  return text
end
end


return p
return p