Documentation for this module may be created at Module:সংখ্যা ৰূপান্তৰক/doc

--[=[ দিয়া অসমীয়া সংখ্যা ইংৰাজীলৈ বা ইংৰাজী সংখ্যাক অসমীয়ালৈ ৰূপান্তৰ কৰে
]=]

local p = {}

function p._translate2bn(text)
	if type(text) == 'string' then
		text = text:gsub('%d', {
			['0'] = '০',
			['1'] = '১',
			['2'] = '২',
			['3'] = '৩',
			['4'] = '৪',
			['5'] = '৫',
			['6'] = '৬',
			['7'] = '৭',
			['8'] = '৮',
			['9'] = '৯',
		})
	end
	return text
end

function p._translate2en(text)
	if type(text) == 'string' then
		text = mw.ustring.gsub(text, '%d', {
			['০'] = '0',
			['১'] = '1',
			['২'] = '2',
			['৩'] = '3',
			['৪'] = '4',
			['৫'] = '5',
			['৬'] = '6',
			['৭'] = '7',
			['৮'] = '8',
			['৯'] = '9',
		})
	end
	return text
end

function p.convert(lang, text)
	if lang == 'bn' then
		return p._translate2bn(text)
	end
	if lang == 'en' then
		return p._translate2en(text)
	end
	return text
end

function p.translate2bn(frame)
	local text = frame.args[1] or frame:getParent().args[1]
	return p._translate2bn(text)
end

function p.translate2en(frame)
	local text = frame.args[1] or frame:getParent().args[1]
	return p._translate2en(text)
end

function p.convert_template(frame)
	local args = frame.args
	local pargs = frame:getParent().args
	local lang = args[1] or pargs[1]
	local text = args[2] or pargs[2]
	return p.convert(lang, text)
end

return p