Module:ta-translit: difference between revisions

From Wiktionary, the free dictionary
Jump to navigation Jump to search
Content deleted Content added
ah. this time it recognise visarga for what it is
No edit summary
Line 5: Line 5:
['ந']='n' , ['ப']='p', ['ம']='m' , ['ய']='y' , ['ர']='r' , ['ல']='l' , ['வ']='v' ,
['ந']='n' , ['ப']='p', ['ம']='m' , ['ய']='y' , ['ர']='r' , ['ல']='l' , ['வ']='v' ,
['ழ']='ḻ' , ['ள']='ḷ' , ['ற']='ṟ' , ['ன']='ṉ' , ['ஶ']='ś' , ['ஜ']='j' , ['ஷ']='ṣ' ,
['ழ']='ḻ' , ['ள']='ḷ' , ['ற']='ṟ' , ['ன']='ṉ' , ['ஶ']='ś' , ['ஜ']='j' , ['ஷ']='ṣ' ,
['ஸ']='s' , ['ஹ']='h' , ['ஃப']='f' , ['ஃஜ']='z' , ['ஃஸ']='x' ,
['ஸ']='s' , ['ஹ']='h' , ['ஃப']='f' , ['ஃஜ']='z' , ['ஃஸ']='x' ,
['ஃ']='ḥ' ,
}
}



Revision as of 01:22, 20 January 2015

This module will transliterate Tamil language text. It is also used to transliterate Irula, Kota (India), Mannan, and Betta Kurumba. 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:ta-translit/testcases.

Functions

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

local export = {}
 
local consonants = {
	['க']='k' , ['ங']='ṅ' , ['ச']='c' , ['ஞ']='ñ' , ['ட']='ṭ' , ['ண']='ṇ' , ['த']='t' ,
	['ந']='n' , ['ப']='p', ['ம']='m' , ['ய']='y' , ['ர']='r' , ['ல']='l' , ['வ']='v' ,
	['ழ']='ḻ' , ['ள']='ḷ' , ['ற']='ṟ' , ['ன']='ṉ' , ['ஶ']='ś' , ['ஜ']='j' , ['ஷ']='ṣ' , 
	['ஸ']='s' , ['ஹ']='h' , ['ஃப']='f' , ['ஃஜ']='z' , ['ஃஸ']='x' ,
	['ஃ']='ḥ' ,
}

local diacritics = {
	['ா']= 'ā' , ['ி']='i' , ['ீ']='ī' , ['ு']='u' , ['ூ']='ū' ,  ['ெ']='e' ,
	['ே']='ē' , ['ை']='ai' , ['ொ']='o' , ['ோ']='ō' , ['ௌ']='au'  ,
	['்']='',	--halant, supresses the inherent vowel "a"
	-- no diacritic
	[''] = 'a'
}

local nonconsonants = {
	-- vowels
	['அ']='a' , ['ஆ']='ā' , ['இ']='i' , ['ஈ']='ī' , ['உ']='u' , ['ஊ']='ū' , 
	['எ']='e' , ['ஏ']='ē' , ['ஐ']='ai' , ['ஒ']='o' , ['ஓ']='ō' , ['ஔ']='au' , 
	-- other symbols
--	['ஃ']='' ,
}

-- translit any words or phrases
function export.tr(text, lang, sc)
	text = mw.ustring.gsub(
		text,
		'(ஃ?[கஙசஞடணதநபமயரலவழளறனஶஜஷஸஹ])'..
		'([ாிீுூெேைொோௌ்]?)',
		function(c, d)
			return (consonants[c] or c) .. diacritics[d]
		end)
	
	text = mw.ustring.gsub(text, '.', nonconsonants)
	
	return text
end
 
return export