মডিউল:তারিখ বাংলাকরণ

উইকিপিডিয়া, মুক্ত বিশ্বকোষ থেকে
মডিউল নথি[তৈরি করুন]
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 == "bn" or lang == "as" or lang == "bpy" or lang == "glk" 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, "[January]", "জানুয়ারি")
    text = mw.ustring.gsub(text, "[February]", "ফেব্রুয়ারি")
    text = mw.ustring.gsub(text, "[March]", "মার্চ")
    text = mw.ustring.gsub(text, "[April]", "এপ্রিল")
    text = mw.ustring.gsub(text, "[May]", "মে")
    text = mw.ustring.gsub(text, "[June]", "জুন")
    text = mw.ustring.gsub(text, "[July]", "জুলাই")
    text = mw.ustring.gsub(text, "[August]", "আগস্ট")
    text = mw.ustring.gsub(text, "[September]", "সেপ্টেম্বর")
    text = mw.ustring.gsub(text, "[October]", "অক্টোবর")
    text = mw.ustring.gsub(text, "[November]", "নভেম্বর")
    text = mw.ustring.gsub(text, "[December]", "ডিসেম্বর")
    text = mw.ustring.gsub(text, "[Jan]", "জানুয়ারি")
    text = mw.ustring.gsub(text, "[Feb]", "ফেব্রুয়ারি")
    text = mw.ustring.gsub(text, "[Mar]", "মার্চ")
    text = mw.ustring.gsub(text, "[Apr]", "এপ্রিল")
    text = mw.ustring.gsub(text, "[May]", "মে")
    text = mw.ustring.gsub(text, "[Jun]", "জুন")
    text = mw.ustring.gsub(text, "[Jul]", "জুলাই")
    text = mw.ustring.gsub(text, "[Aug]", "আগস্ট")
    text = mw.ustring.gsub(text, "[Sep]", "সেপ্টেম্বর")
    text = mw.ustring.gsub(text, "[Oct]", "অক্টোবর")
    text = mw.ustring.gsub(text, "[Nov]", "নভেম্বর")
    text = mw.ustring.gsub(text, "[Dec]", "ডিসেম্বর")
    text = mw.ustring.gsub(text, "[Jan]", "জানুয়ারি")
    text = mw.ustring.gsub(text, "[ফেব্রুয়ারিruary]", "ফেব্রুয়ারি")
    text = mw.ustring.gsub(text, "[Mar]", "মার্চ")
    text = mw.ustring.gsub(text, "[Apr]", "এপ্রিল")
    text = mw.ustring.gsub(text, "[May]", "মে")
    text = mw.ustring.gsub(text, "[Jun]", "জুন")
    text = mw.ustring.gsub(text, "[Jul]", "জুলাই")
    text = mw.ustring.gsub(text, "[Aug]", "আগস্ট")
    text = mw.ustring.gsub(text, "[Sep]", "সেপ্টেম্বর")
    text = mw.ustring.gsub(text, "[Oct]", "অক্টোবর")
    text = mw.ustring.gsub(text, "[Nov]", "নভেম্বর")
    text = mw.ustring.gsub(text, "[Dec]", "ডিসেম্বর")
    if type(signs) ~= "nil" then
      text = mw.ustring.gsub(text, "%.", "٫")
    end
  elseif lang == "bn" or lang == "as" 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