Documentation for this module may be created at ᱢᱳᱰᱩᱞ:Number converter/doc

--[=[ ᱮᱢ ᱟᱠᱟᱱ ᱥᱟᱱᱛᱟᱲᱤ ᱮᱞ ᱤᱝᱞᱤᱥ ᱟᱨ ᱤᱝᱞᱤᱥ ᱮᱞ ᱥᱟᱱᱛᱟᱲᱤ ᱨᱮ ᱵᱚᱫᱚᱞᱚᱜᱼᱟ
]=]

local p = {}

function p._translate2sat(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 == 'sat' then
		return p._translate2sat(text)
	end
	if lang == 'en' then
		return p._translate2en(text)
	end
	return text
end

function p.translate2sat(frame)
	local text = frame.args[1] or frame:getParent().args[1]
	return p._translate2sat(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