This module will transliterate text in the 多格拉文. 它被用於轉寫多格拉語。 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:Dogr-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', ['𑠍']='gh', ['𑠎']='ṅ', 
	['𑠏']='c', ['𑠐']='ch', ['𑠑']='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",
	["𑠟𑠺"] = "f",
	["𑠗𑠺"] = "ṛh",
	["𑠖𑠺"] = "ṛ",
}

local diacritics = {
	['𑠬']= 'ā', ['𑠭']='i', ['𑠮']='ī', ['𑠯']='u', ['𑠰']='ū',
	['𑠱']='r̥', ['𑠲']='r̥̄',  
	['𑠳']='e', ['𑠴']='ai', ['𑠵']='o', ['𑠶']='au', ['𑠹']='', 
}

local nonconsonants = {
	-- vowels
	['𑠀']='a', ['𑠁']='ā', ['𑠂']='i', ['𑠃']='ī', ['𑠄']='u', ['𑠅']='ū', 
	['𑠆']='e', ['𑠇']='ai', ['𑠈']='o',['𑠉']='au',
	-- other symbols
	['𑠷']='ṁ', -- anusvara
	['𑠸']='ḥ', -- visarga
	['𑠻']='.', -- abbreviation sign
	['।'] = '.', -- danda
	['॥'] = '.', -- double danda
	-- digits
	['०'] = '0', ['१'] = '1', ['२'] = '2', ['३'] = '3', ['४'] = '4',
	['५'] = '5', ['६'] = '6', ['७'] = '7', ['८'] = '8', ['९'] = '9',
}

local nasal_assim = {
	["[kg]h?"] = "ṅ",
	["[cj]h?"] = "ñ",
	["[ṭḍ]h?"] = "ṇ",
	["[td]h?"] = "n",
	["[pb]h?"] = "m",
	["n"] = "n",
	["m"] = "m",
    ["s"] = "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[c] or c
			if d == "" then        
				return c .. 'a'
			else
				return c .. (diacritics[d] 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,"([aiueēoāīū])ṁ ", "%1̃ ")
	text = mw.ustring.gsub(text,"(.?)ṁ", "%1̃")
	text = mw.ustring.gsub(text, 'a([iu])̃', 'a͠%1')

	return text
end
 
return export