Module:lif-translit

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

This module will transliterate Limbu language text. 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:lif-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 gsub = mw.ustring.gsub
local consonants = {
	='k', ='kh', ='g', ='gh', ='ṅ', 
	='c', ='ch', ='j', ='jh', ='ñ',
	='t', ='th', ='d', ='dh', ='n', 
	='p', ='ph', ='b', ='bh', ='m', 
	='y', ='r', ='l', ='w', 
	='ś', ='ṣ', ='s', ='h', 
	='gy', ='tr', ='',
}
local diacritics = {
	='a' , ='i' , ='u' , ='e' , ='ai' , ='o' , ='au' , ='ê' , ='ô'
}

local special = {
	-- idk what to call these
	='’', --mukphreng (glottalizer)
	 = '̃', --anusvara (now obsolete)
}

local subjoined = {
	='r', ='w', ='y',
}

local finals = {
	='k', ='ṅ', ='t', ='n', ='p', ='m', ='r', ='l',
}

local nonconsonants = { 
	
	-- digits
	 = '0',  = '1',  = '2',  = '3',  = '4',
	 = '5',  = '6',  = '7',  = '8',  = '9',
	='.', ='!', ='?',
	='lo'
}

-- translit any words or phrases
function export.tr(text, lang, sc)
	text = mw.ustring.gsub(text, '()᤻', '᤺%1⌫') -- treat underscore as kemphreng
	text = mw.ustring.gsub(
		text,
		'()'..
		'(?)'..
		'(?)'..
		'(?)'..
		'(?)',
		function(c, d, e, f, g)
			-- mw.log('match', c, d)
			return (consonants or c) ..
					(subjoined or d) ..
					(diacritics or (e ~= "") and e or 'ô') ..
					(special or f) ..
					(finals or g)
		end)
	
text = gsub(text, "", "")
text = mw.ustring.gsub(text, '.', nonconsonants)	
text = mw.ustring.gsub(text, '(.)⌫', '')
text = gsub(text, 'aᤣ', 'o')
text = gsub(text, 'ᤣᤣ', 'ai')
text = gsub(text, 'aᤣᤣ', 'au')
text = mw.ustring.gsub(text, '᤺', '̄')
text = mw.ustring.gsub(text, 'ᤰ', 'k')
text = mw.ustring.gsub(text, 'ᤱ', 'ṅ')
text = mw.ustring.gsub(text, 'ᤳ', 't')
text = mw.ustring.gsub(text, 'ᤴ', 'n')
text = mw.ustring.gsub(text, 'ᤵ', 'p')
text = mw.ustring.gsub(text, 'ᤶ', 'm')
text = mw.ustring.gsub(text, 'ᤷ', 'r')
text = mw.ustring.gsub(text, 'ᤸ', 'l')
text = gsub(text,  '̄ᤣ', 'ō')
text = mw.ustring.gsub(text, 'aō', 'ō')
	return mw.ustring.toNFC(text)
end
 
return export