Documentation for this module may be created at Module:Mahj-translit/doc

local export = {}
 
local consonants = {
	['๐‘…•']='k', ['๐‘…–']='kh', ['๐‘…—']='g', ['๐‘…˜']='gh', 
	['๐‘…™']='c', ['๐‘…š']='ch', ['๐‘…›']='j', ['๐‘…œ']='jh', ['๐‘…']='รฑ', 
	['๐‘…ž']='แนญ', ['๐‘…Ÿ']='แนญh', ['๐‘… ']='แธ', ['๐‘…ก']='แธh', ['๐‘…ข']='แน‡', 
	['๐‘…ฃ']='t', ['๐‘…ค']='th', ['๐‘…ฅ']='d', ['๐‘…ฆ']='dh', ['๐‘…ง']='n', 
	['๐‘…จ']='p', ['๐‘…ฉ']='ph', ['๐‘…ช']='b', ['๐‘…ซ']='bh', ['๐‘…ฌ']='m', 
	['๐‘…ญ']='r', ['๐‘…ฎ']='l', ['๐‘…ฏ']='v',
	['๐‘…ฐ']='s', ['๐‘…ฑ']='h', ['๐‘…ฒ'] = 'แน›',
}

local nonconsonants = {
	-- vowels
	['๐‘…']='a', ['๐‘…‘']='i', ['๐‘…’']='u', ['๐‘…“']='e', ['๐‘…”']='o',

	-- other symbols
	['๐‘…ดโ€Ž']='.', -- abbreviation mark
	['๐‘…ต']='ยง', -- section mark
	['๐‘…ถ']='Shri', -- ligature [[เคถเฅเคฐเฅ€]]
}

-- translit any words or phrases
function export.tr(text, lang, sc)
	text = mw.ustring.gsub(
		text,
		'([๐‘…•๐‘…–๐‘…—๐‘…˜๐‘…™๐‘…š๐‘…›๐‘…œ๐‘…๐‘…ž๐‘…Ÿ๐‘… ๐‘…ก๐‘…ข๐‘…ฃ๐‘…ค๐‘…ฅ๐‘…ฆ๐‘…ง๐‘…จ๐‘…ฉ๐‘…ช๐‘…ซ๐‘…ฌ๐‘…ญ๐‘…ฎ๐‘…ฏ๐‘…ฐ๐‘…ฑ๐‘…ฒ])'..
		'([๐‘…ณ]?)',
		function(c, d)
			-- mw.log('match', c, d)
			return (consonants[c] or c)
		end)
	
	text = mw.ustring.gsub(text, '.', nonconsonants)
	
	return text
end
 
return export