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

local export = {}
local gsub = mw.ustring.gsub
local u = mw.ustring.char
local letter_with_mark = '(.['..u(0x0300)..'-'..u(0x036F)..']?)'

local tt = {
	-- consonants
	['க'] = 'ក', ['ங'] = 'ង', ['ச'] = 'ច', ['ஜ'] = 'ជ', ['ஞ'] = 'ញ',
	['ட'] = 'ដ', ['ண'] = 'ណ', ['த'] = 'ត', ['ந'] = 'ន', ['ன'] = 'ន្ន',
	['ப'] = 'ប', ['ம'] = 'ម',
	['ய'] = 'យ', ['ர'] = 'រ', ['ற'] = 'រ្រ', ['ல'] = 'ล', ['ள'] = 'ឡ', ['ழ'] = 'ឡ្ល', ['வ'] = 'វ',
	['ஶ'] = 'ឝ', ['ஷ'] = 'ឞ', ['ஸ'] = 'ស', ['ஹ'] = 'ហ',
	-- independent vowels
	['அ'] = 'អ', ['ஆ'] = 'អា', ['இ'] = 'ឥ', ['ஈ'] = 'ឦ', ['உ'] = 'ឧ', ['ஊ'] = 'ឩ',
	['எ'] = 'ឯៈ', ['ஏ'] = 'ឯ', ['ஐ'] = 'ឰ', ['ஒ'] = 'ឱៈ', ['ஓ'] = 'ឱ', ['ஔ'] = 'ឳ',
	-- dependent vowels and diacritics (excluding front type)
	['ா'] = 'ា', ['ி'] = 'ិ', ['ீ'] = 'ី', ['ு'] = 'ុ', ['ூ'] = 'ូ',
	['ஂ'] = 'ំ', ['ஃ'] = 'ះ', ['்'] = '្', ['ெ'] = 'េៈ', ['ே'] = 'េ', ['ை'] = 'ៃ',
	['ொ'] = 'ោៈ', ['ோ'] = 'ោ', ['ௌ'] = 'ៅ',
	-- numerals
	['௦'] = '០', ['௧'] = '១', ['௨'] = '២', ['௩'] = '៣', ['௪'] = '៤',
	['௫'] = '៥', ['௬'] = '៦', ['௭'] = '៧', ['௮'] = '៨', ['௯'] = '៩',
	['௰'] = '[១០]', ['௱'] = '[១០០]', ['௲'] = '[១០០០]',
	-- zero-width space (display it if it hides in a word)
	[u(0x200B)] = '‼',
}

local adjust0 = {
	-- for convenience
	['ஒ'..'ௗ'] = 'ஔ',
	['ெ'..'ா'] = 'ொ', ['ே'..'ா'] = 'ோ', ['ெ'..'ௗ'] = 'ௌ',
	['ௐ'] = 'ஓம்',
}

function export.tr(text, lang, sc, debug_mode)

	if type(text) == 'table' then -- called directly from a template
		text = text.args[1]
	end

	for k, v in pairs(adjust0) do
		text = gsub(text, k, v)
	end
	text = gsub(text, '.', tt)
	
	return text

end

return export