Module:kn-translit

Hello, you have come here looking for the meaning of the word Module:kn-translit. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:kn-translit, but we will also tell you about its etymology, its characteristics and you will know how to say Module:kn-translit in singular and plural. Everything you need to know about the word Module:kn-translit you have here. The definition of the word Module:kn-translit will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:kn-translit, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module will transliterate Kannada language text per WT:KN TR. It is also used to transliterate Badaga, Bellari, Beary, Middle Kannada, Old Kannada, Kodava, Korra Koraga, Konkani, Sholaga, Tulu, Alu Kurumba, Betta Kurumba, Jennu Kurumba, and Ravula. 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:kn-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', ='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', ='ḷ', ='ḻ', 
	='f', ='z', ='ḻ', 
}

local diacritics = {
	= 'ā' , ='i' , ='ī' , ='u' , ='ū' , ='ṛ' , ='r̥̄' ,
	='e' , ='ē' , ='ai' , ='o' , ='ō' , ='au', = 'è',
	= 'l̥', ='l̥̄'
}

local nonconsonants = {
	-- vowels
	='a' , ='ā' , ='i' , ='ī' , ='u' , ='ū' , 
	='ṛ' , ='r̥̄' , ='l̥' , ='l̥̄', ='e' , ='ē' ,
	='ai' , ='o' , ='ō' , ='au' , ='aṃ' , ='ah' , 
	-- other symbols
	='ṃ', -- anusvara
	='ḥ',  -- visarga
	--halant, supresses the inherent vowel "a"
	='',
	-- digits
	 = '0',  = '1',  = '2',  = '3',  = '4',
	 = '5',  = '6',  = '7',  = '8',  = '9',
}

-- translit any words or phrases
function export.tr(text, lang, sc)
	local VIRAMA = '್'
	
	-- final virama rules
	if lang == "tcy" or lang == "kfa" or lang == "kfd" or lang == "dra-bry" then
		text = mw.ustring.gsub(text, VIRAMA .. "(?)$", VIRAMA .. "ŭ%1")
		text = mw.ustring.gsub(text, VIRAMA .. "(?) ", VIRAMA .. "ŭ%1 ")
	end

	text = mw.ustring.gsub(
		text,
		'(?)'..
		'(?)',
		function(c, d)
			-- mw.log('match', c, d)
			c = consonants or c
			if d == "" then        
				return c .. 'a'
			else
				return c .. (diacritics or d)
			end
		end)
	
	text = mw.ustring.gsub(text, '.', nonconsonants)
	
	-- anusvara
	text = mw.ustring.gsub(text, 'ṃ()', 'ṅ%1')
	text = mw.ustring.gsub(text, 'ṃ()', 'ñ%1')
	text = mw.ustring.gsub(text, 'ṃ()', 'ṇ%1')
	text = mw.ustring.gsub(text, 'ṃ()', 'n%1')
	text = mw.ustring.gsub(text, 'ṃ()', 'm%1')
	
	return text
end
 
return export