Module:lep-translit

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

This module will transliterate Lepcha 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:lep-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 conv = {
	 = "",
	 = "k", --U+1C00
	 = "kl", --U+1C01
	 = "kh", --U+1C02
	 = "g", --U+1C03
	 = "gl", --U+1C04
	 = "ng", --U+1C05
	 = "c", --U+1C06
	 = "ch", --U+1C07
	 = "j", --U+1C08
	 = "ny", --U+1C09
	 = "t", --U+1C0A
	 = "th", --U+1C0B
	 = "d", --U+1C0C
	 = "n", --U+1C0D
	 = "p", --U+1C0E
	 = "pl", --U+1C0F
	 = "ph", --U+1C10
	 = "f", --U+1C11
	 = "fl", --U+1C12
	 = "b", --U+1C13
	 = "bl", --U+1C14
	 = "m", --U+1C15
	 = "ml", --U+1C16
	 = "ts", --U+1C17
	 = "tsh", --U+1C18
	 = "dz", --U+1C19
	 = "y", --U+1C1A
	 = "r", --U+1C1B
	 = "l", --U+1C1C
	 = "h", --U+1C1D
	 = "hl", --U+1C1E
	 = "v", --U+1C1F
	 = "s", --U+1C20
	 = "sh", --U+1C21
	 = "w", --U+1C22
	 = "", --U+1C23
	 = "y", --U+1C24
	 = "r", --U+1C25
	 = "á", --U+1C26
	 = "i", --U+1C27
	 = "o", --U+1C28
	 = "ó", --U+1C29
	 = "u", --U+1C2A
	 = "ú", --U+1C2B
	 = "e", --U+1C2C
	 = "k", --U+1C2D
	 = "m", --U+1C2E
	 = "l", --U+1C2F
	 = "n", --U+1C30
	 = "p", --U+1C31
	 = "r", --U+1C32
	 = "t", --U+1C33
	 = "ng", --U+1C34
	 = "ng", --U+1C35
	 = "^", --U+1C36
	 = "", --U+1C37
	 = "", --U+1C38
	 = "", --U+1C39
	 = "", --U+1C3A
	 = "", --U+1C3B
	 = "", --U+1C3C
	 = "0", --U+1C3D
	 = "1", --U+1C3E
	 = "2", --U+1C3F
	 = "3", --U+1C40
	 = "4", --U+1C41
	 = "5", --U+1C42
	 = "6", --U+1C43
	 = "7", --U+1C44
	 = "8", --U+1C45
	 = "9", --U+1C46
	 = "tt", --U+1C4D
	 = "tth", --U+1C4E
	 = "dd", --U+1C4F
}

function export.tr(text, lang, sc)
	local nukta = "\225\176\183"
	
	local initials = "()"
	local medials = "(?)"
	local vowels_after = "()"
	local finals_after = "(?)"
	local others = ""
	
	local im = initials..medials
	local imf = initials..medials..finals_after
	
	local imvf = initials..medials..vowels_after..finals_after
	
	text = mw.ustring.gsub(text, nukta, "")
	
	text = mw.ustring.gsub(text, imvf, function(i,m,v,f)
		return conv .. conv .. conv .. conv
	end)
	
	text = mw.ustring.gsub(text, imf, function(i,m,f)
		return conv .. conv .. "a" .. conv
	end)
	
	text = mw.ustring.gsub(text, im, function(i,m)
		return conv .. conv .. "a"
	end)
	
	text = mw.ustring.gsub(text, others, conv)
	
	return text
end

return export