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(lang, text, signs, virgule)
  text = tostring(text)
  signs = signs or nil
  virgule= virgule or nil

  if lang == "my" 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 == "my" 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