Module:te-translit

Definition from Wiktionary, the free dictionary
Jump to: navigation, search
The following documentation is located at Module:te-translit/documentation. [edit]
See also: subpages of this module.

This module will transliterate Telugu language text per WT:TE TR.

The module should preferably not be called directly from templates or other modules. To use it from a template, use {{xlit}}. Within a module, use Module:languages#Language:transliterate.

For testcases, see Module:te-translit/testcases.

Functions[edit]

tr(text, lang, sc)
Transliterates a given piece of text written in the script specified by sc, and language specified by lang. When the transliteration fails, returns nil.

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' , ['ఱ']='ṛ'
}
 
local diacritics = {
	['ా']= 'ā' , ['ి']='i' , ['ీ']='ī' , ['ు']='u' , ['ూ']='ū' , ['ృ']='r̥' , ['ౄ']='r̥̄' ,
	['ె']='e' , ['ే']='ē' , ['ై']='ai' , ['ొ']='o' , ['ో']='ō' , ['ౌ']='au'  , ['్']=''
}
local tt = {
	-- vowels
	['అ']='a' , ['ఆ']='ā' , ['ఇ']='i' , ['ఈ']='ī' , ['ఉ']='u' , ['ఊ']='ū' , 
	['ఋ']='r̥' , ['ౠ']='r̥̄' , ['ఌ']='l̥' , ['ౡ']='l̥̄', ['ఎ']='e' , ['ఏ']='ē' ,
	['ఐ']='ai' , ['ఒ']='o' , ['ఓ']='ō' , ['ఔ']='au' , ['అం']='aṅ' , ['అఁ']='aṃ' , ['అః']='ah' , 
	-- other symbols
	['ం']='ṃ',-- anusvara
	['ః']='ḥ' ,  -- visarga
	['ఁ']='ṅ' , -- candrabindu
	['్']='' ,  --halant, supresses the inherent vowel "a"
}
 
-- 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)
 
	return text
end
 
return export