Module:si-translit

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

This module will transliterate Sinhalese language text per WT:SI TR. It is also used to transliterate Pali and Sanskrit. 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:si-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.</noinclude>

local m_str_utils = require("Module:string utilities")

local gsub = m_str_utils.gsub
local u = m_str_utils.char

local export = {}

local consonants = {
	='k' , ='kh' , ='g' , ='gh' , ='ṅ' , ='ⁿg' , ='c' , ='ch' , ='j' , ='jh' , 
	='ñ' , ='gn' , ='ⁿj' , ='ṭ' , ='ṭh' , ='ḍ' , ='ḍh' , ='ṇ' , ='ⁿḍ' ,
	='t' ,  ='th' , ='d' , ='dh' , ='n' , ='ⁿd' , 
	='p' , ='f' , ='ph' , ='b' , ='bh' , ='m' , ='ᵐb' , ='y' , ='r' , ='l' , ='w' , 
	='ś' , ='ṣ' , ='s' , ='h' , ='ḷ' , ='f'
}

local diacritics = {
	 = 'ā',
	 = 'æ',
	 = 'ǣ',
	 = 'i',
	 = 'ī',
	 = 'u',
	 = 'ū',
	 = 'e',
	 = 'ē', 
	 = 'ai', 
	 = 'o', 
	 = 'ō', 
	 = 'au',
	 = 'r̥',
	 = 'l̥', 
	 = 'r̥̄', 
	 = 'l̥̄',
	 = ''
}
local tt = {
	-- vowels
	='a' ,  ='ā' ,  ='æ' ,   ='ǣ' ,  ='i' ,  ='ī' ,  ='u' ,  ='ū' , 
	='e' ,  ='ē' ,  ='ai' ,  ='o' ,  ='ō' ,  ='au' , 
	='r̥' ,  ='r̥̄' ,  ='l̥' ,  ='l̥̄' ,     
	-- other symbols
	='ṁ' , -- anusvara
	='ḥ' ,  -- visarga
	='' ,  --hal kirīma, suppresses the inherent vowel "a"
	-- punctuation
	='.' ,  -- kunddaliya (obsolete)    
}

-- translit any words or phrases
function export.tr(text, lang, sc)
	if type(text) == 'table' then
		text = text.args
		lang = text.args
		sc   = text.args
	end
	if (lang == 'sa' or lang == 'pi') then
		text=string.gsub(text, 'ඥ', 'ජ‍්ඤ')
	end
	text = gsub(text, -- Handle conjunct and touching clusters.
		'',
		{ = u(0x0dca),  = u(0x0dca)})
	text = gsub(
		text,
		'()'..
		'(?)',
		function(c, d)
			if d == "" then        
				return consonants .. 'a'
			else
				return consonants .. diacritics
			end
		end)
	
	text = gsub(text, '.', tt)
	if (lang == 'pi' or lang =='sa') then -- Convert to IAST.
		text = gsub(text, '.'..u(0x325)..'?'..u(0x304)..'?',
                   { = 'ṃ',  = 'v',  = 'ṛ', ='ṝ', ='ḷ', ='ḹ'})
	end
	return text
end
 
return export