Jump to content

မေႃႇၵျူး:te-translit

လုၵ်ႉတီႈ ဝိၵ်ႇသျိၼ်ႇၼရီႇ မႃး

Documentation for this module may be created at မေႃႇၵျူး:te-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' , 
	['య']='y' , ['ర']='r' , ['ల']='l' , ['వ']='v' ,  ['ళ']='ḷ' ,
	['శ']='ś' , ['ష']='ṣ' , ['స']='s' , ['హ']='h' , ['ఱ']='ṟ' ,
	['ఴ']='ḻ' , ['ౘ']='ĉ' , ['ౙ']='ẑ' , ['ౚ']='ṟ̄' ,
	['క఼']='q' , ['ఖ఼']='x' , ['గ఼']='ġ' , ['జ఼']='z', ['ఝ఼']='ź', ['ఫ఼']='f', ['డ఼']='ṛ', ['ఢ఼']='ṛh', ['న఼']='ṉ', 
}

local diacritics = {
	['ా']= 'ā' , ['ి']='i' , ['ీ']='ī' , ['ు']='u' , ['ూ']='ū' , ['ృ']='r̥' , ['ౄ']='r̥̄' ,
	['ౢ']='l̥' , ['ౣ']='l̥̄' , ['ె']='e' , ['ే']='ē' , ['ై']='ai' , ['ొ']='o' , ['ో']='ō' ,
	['ౌ']='au'  , ['్']='' ,
}
local tt = {
	-- vowels
	['అ']='a' , ['ఆ']='ā' , ['ఇ']='i' , ['ఈ']='ī' , ['ఉ']='u' , ['ఊ']='ū' , 
	['ఋ']='r̥' , ['ౠ']='r̥̄' , ['ఌ']='l̥' , ['ౡ']='l̥̄', ['ఎ']='e' , ['ఏ']='ē' ,
	['ఐ']='ai' , ['ఒ']='o' , ['ఓ']='ō' , ['ఔ']='au' , ['అం']='aṁ' , ['అఁ']='an̆' , ['అః']='aḥ' , 
	-- other symbols
	['ం']='ṁ',-- anusvara
	['ః']='ḥ' ,  -- visarga
	['ఁ']='n̆' , -- candrabindu/arthanusvāra/aranusa
	['ఀ']='m̐' , -- combining candrabindu
	['ఽ']='’' , -- avagraha
-- digits
	['౦'] = '0', ['౧'] = '1', ['౨'] = '2', ['౩'] = '3', ['౪'] = '4',
	['౫'] = '5', ['౬'] = '6', ['౭'] = '7', ['౮'] = '8', ['౯']= '9',
	['౸']='0⁄4', ['౹']='¼', ['౺']='2⁄4', ['౻']='¾', 
	['౦']='0⁄16', ['౼']='1⁄16', ['౽']='2⁄16', ['౾']='3⁄16' ,
}

-- translit any words or phrases
function export.tr(text, lang, sc)
	text = mw.ustring.gsub(
		text,
		'([కఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరలవళశషసహఱఴౘౙౚ])'..
		'([ాిీుూృ̥ౄ̥̄ెేైొోౌ్]?)',
		function(c, d)
			if d == "" then        
				return consonants[c] .. 'a'
			else
				return consonants[c] .. diacritics[d]
			end
		end)
	
	text = mw.ustring.gsub(text, '.', tt)
	
	-- anusvara
	text = mw.ustring.gsub(text, 'ṁ([kqxgġṅ])', 'ṅ%1')
	text = mw.ustring.gsub(text, 'ṁ([cjźñ])', 'ñ%1')
	text = mw.ustring.gsub(text, 'ṁ([ṭḍṇ])', 'ṇ%1')
	text = mw.ustring.gsub(text, 'ṁ([tdnĉẑz])', 'n%1')
	text = mw.ustring.gsub(text, 'ṁ([pfbm])', 'm%1')
	
	return text
end