Module:Guru-translit

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

This module will transliterate text in the Gurmukhi script. It is used to transliterate Punjabi and Pahari-Potwari. 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:Guru-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 = {
	--consonants without nukta
	 = "s",
	 = "h",
	 = "k",  = "kh",  = "g",  = "gh",  = "ṅ",
	 = "c",  = "ch",  = "j",  = "jh",  = "ñ",
	 = "ṭ",  = "ṭh",  = "ḍ",  = "ḍh",  = "ṇ",
	 = "t",  = "th",  = "d",  = "dh",  = "n",
	 = "p",  = "ph",  = "b",  = "bh",  = "m",
	 = "y",  = "r",  = "l", 	 = "v",  = "ṛ",
	
	--consonants with nukta
	 = "ś",
	 = "x",
	 = "ġ",
	 = "z",
	 = "f",
	 = "ḷ",
	 = "q",
	 = "ṛ",
	
	-- vowels
	 = "ā",
	 = "i",  = "ī",
	 = "u",  = "ū",
	 = "e",  = "ai",
	 = "o",  = "au",
	
	-- other diacritics
	 = "N", --ṭippi: nasalize
	 = "N", --bindi: nasalize
	 = "ː", --addak: geminate
	 = "", --halant, supresses the inherent vowel "a"
	 = "h", --voiceless "h" sound (tone raiser)
	
	-- independent vowels
	 = "a",  = "ā",
	 = "i",  = "ī",
	 = "u",  = "ū",
	 = "ē",  = "ai",
	 = "o",  = "au",
	
	-- digits
	 = "0",  = "1",  = "2",  = "3",  = "4",
	 = "5",  = "6",  = "7",  = "8",  = "9",
}

local nasal_assim = {
	h?"] = "ṅ",
	h?"] = "ñ",
	h?"] = "ṇ",
	h?"] = "n",
	h?"] = "m",
	 = "n",
	 = "m",
     = "n",
}

-- translit any words or phrases
function export.tr(text, lang, sc)
	local c = "(਼?)"
	local y = "ਯ"
	local v = "()"
	local virama = "੍"
	local n = "(?)"
	local nukta = "(਼)"
	
	local can_drop = mw.ustring.gsub(c,y,"")
	local no_virama = mw.ustring.gsub(v,virama,"")
	
	text = text .. " "
	
	text = mw.ustring.gsub(text,c,"%1a")
	text = mw.ustring.gsub(text,"a"..v,"%1")
	-- mw.log(text)
	text = mw.ustring.gsub(text,v..n..can_drop.."a ","%1%2%3 ") --ending
	-- mw.log(text)
	text = mw.ustring.gsub(text,v..n..can_drop.."a"..c..v,"%1%2%3%4%5")
	-- mw.log(text)
	
	text = mw.ustring.gsub(text,nukta,conv)
	text = mw.ustring.gsub(text,".",conv)
	
	for key,val in pairs(nasal_assim) do
		text = mw.ustring.gsub(text,"N("..key..")",val.."%1")
	end
	text = mw.ustring.gsub(text,"()N ", "%1̃ ")
	text = mw.ustring.gsub(text,"(.?)N", "%1̃")
	
	text = mw.ustring.gsub(text,"ː(.)","%1%1")
	
	text = mw.ustring.gsub(text," ?।",".")
	
	text = mw.ustring.gsub(text," $","")
	
	return mw.ustring.toNFC(text)
end
 
return export