Module:Saz-translit是什么意思_Module:Saz-translit读音|解释_Module:Saz-translit同义词|反义词

Module:Saz-translit

这个模组会将索拉什特拉语未确定的文字拉丁化。

最好不要直接从模板或其他模组调用此模组。要从模板中使用它,请以{{xlit}}做为替代;若要在模组中使用,则以Module:languages#Language:transliterate替代。

关于测试用例,请参阅Module:Saz-translit/testcases。

函数

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', ['ꢳ']='ḷ',
}

local diacritics = {
	['ꢵ']= 'ā', ['ꢶ']='i', ['ꢷ']='ī', ['ꢸ']='u', ['ꢹ']='ū', ['ꢺ']='ṛ', ['ꢻ']='ṝ', ['ꢼ']='ḷ', ['ꢽ']='ḹ',
	['ꢾ']='e', ['ꢿ']='ē', ['ꣀ']='ai', ['ꣁ']='o', ['ꣂ']='ō', ['ꣃ']='au', ['꣄']='', ['ꢴ']='h',
}

local nonconsonants = {
	-- vowels
	['ꢂ']='a', ['ꢃ']='ā', ['ꢄ']='i', ['ꢅ']='ī', ['ꢆ']='u', ['ꢇ']='ū', 
	['ꢈ']='ṛ', ['ꢉ']='ṝ', ['ꢊ']='ḷ', ['ꢋ']='ḹ', ['ꢌ']='e', ['ꢍ']='ē',
	['ꢎ']='ai', ['ꢏ']='o', ['ꢐ']='ō', ['ꢑ']='au',
	-- other symbols
	['ꢀ']='ṃ', -- anusvara
	['ꢁ']='ḥ',  -- visarga
	['ꣅ']='◌̃', 
	['꣎']='.',
	-- digits
	['꣐'] = '0', ['꣑'] = '1', ['꣒'] = '2', ['꣓'] = '3', ['꣔'] = '4',
	['꣕'] = '5', ['꣖'] = '6', ['꣗'] = '7', ['꣘'] = '8', ['꣙'] = '9',
}

-- translit any words or phrases
function export.tr(text, lang, sc)
	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, '.', nonconsonants)
	
	return text
end
 
return export