মডিউল:রূপান্তর
অবয়ব
এই মডিউলের জন্য মডিউল:রূপান্তর/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে
-- মডিউল:রূপান্তর
local p = {}
-- English → Bengali digit map
local bn_digits = {
['0']='০',['1']='১',['2']='২',['3']='৩',['4']='৪',
['5']='৫',['6']='৬',['7']='৭',['8']='৮',['9']='৯'
}
-- Bengali → English digit map
local en_digits = {
['০']='0',['১']='1',['২']='2',['৩']='3',['৪']='4',
['৫']='5',['৬']='6',['৭']='7',['৮']='8',['৯']='9'
}
-- Convert ASCII digits to Bengali digits
local function to_bengali(s)
s = tostring(s)
local result = mw.ustring.gsub(s, "%d", function(d) return bn_digits[d] end)
return result
end
-- Convert Bengali digits to ASCII digits
local function to_ascii(s)
s = tostring(s)
local result = mw.ustring.gsub(s, "[০১২৩৪৫৬৭৮৯]", function(d) return en_digits[d] end)
return result
end
-- Function to convert ft² → m² with Bengali units
function p.squarefeet(frame)
local val = frame.args[1] or frame:getParent().args[1] or "0"
-- Call existing Module:Convert
local convert = frame:expandTemplate{
title = 'convert',
args = { val, 'ft2', 'm2', 'abbr=on' }
}
-- Replace "sq ft" or "ft²" with Bengali "বর্গফুট"
convert = mw.ustring.gsub(convert, "sq%.?%s?ft", "বর্গফুট")
convert = mw.ustring.gsub(convert, "ft²", "বর্গফুট")
-- Replace "m2" or "m²" with Bengali "বর্গমিটার"
convert = mw.ustring.gsub(convert, "m2", "বর্গমিটার")
convert = mw.ustring.gsub(convert, "m²", "বর্গমিটার")
-- Convert digits to Bengali
convert = to_bengali(convert)
return convert
end
-- Function: convert Bengali-date input to ASCII so #time works
function p.ascii_date(frame)
local input = frame.args[1] or frame:getParent().args[1] or ""
if input == "" then
return ""
end
local ascii = to_ascii(input)
return ascii
end
return p