Module:Sind-translit

Hello, you have come here looking for the meaning of the word Module:Sind-translit. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:Sind-translit, but we will also tell you about its etymology, its characteristics and you will know how to say Module:Sind-translit in singular and plural. Everything you need to know about the word Module:Sind-translit you have here. The definition of the word Module:Sind-translit will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:Sind-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 Khudabadi script. It is used to transliterate Kachchi and Sindhi. 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:Sind-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', ='g̠', ='gh', ='ṅ', 
	='c', ='ch', ='j', ='j̄', ='jh', ='ñ', 
	='ṭ', ='ṭh', ='ḍ', ='ḍ̠', ='ṛ',='ḍh', ='ṇ', 
	='t', ='th', ='d', ='dh', ='n', 
	='p', ='ph', ='b', ='ḇ', ='bh', ='m', 
	='y', ='r', ='l', ='v', ='ś', 
	='s', ='h', 

--consonants with nukta
	 = "q",
	 = "x",
	 = "ġ",
	 = "z",
	 = "ṛh",
	 = "f",
}

local diacritics = {
	= 'ā', ='i', ='ī', ='u', ='ū',
	='e', ='ai', ='o', ='au', ='', 
}

local nonconsonants = {
	-- vowels
	='a', ='ā', ='i', ='ī', ='u', ='ū', 
	='e', ='ai', ='o',='au',
	-- other symbols
	='ṁ', -- anusvara
	='.', -- nukta
	-- 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 nukta = "(𑋩)"
	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,nukta,consonants)
	text = mw.ustring.gsub(text, '.', nonconsonants)
	for key,val in pairs(nasal_assim) do
		text = mw.ustring.gsub(text,"ṁ("..key..")",val.."%1")
	end
	text = mw.ustring.gsub(text,"()ṁ ", "%1̃ ")
	text = mw.ustring.gsub(text,"(.?)ṁ", "%1̃")
	text = mw.ustring.gsub(text, 'a()̃', 'a͠%1')

	return mw.ustring.toNFC(text)
end
 
return export