模組:Kdr-translit

維基詞典,自由的多語言詞典

這個模組會將卡拉伊姆語未確定的文字拉丁化。

最好不要直接從模板或其他模組調用此模組。要從模板中使用它,請以{{xlit}}做為替代;若要在模組中使用,則以Module:languages#Language:transliterate替代。

關於測試用例,請參閱Module:Kdr-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 tab =  
             {["А"] ="A" ,    ["Б"] ="B",   ["В"] ="V",   ["Г"] ="G",   ["Д"] ="D",   ["Е"] ="E",                                           ["Ё"] ="Yo", ["Ж"] ="J" ,    ["З"] ="Z",   ["И"] ="I",   ["Й"] ="Y",
	
     ["К"]="K",  ["Л"]="L", ["М"]="M", ["Н"]="N",  ["О"]="O",  ["Ӧ"]="Ö", ["П"]="P", ["Р"]="R", ["С"]="S",  ["Т"]="T",
["У"]="U",  ["Ӱ"]="Ü", ["Ф"]="F", ["Х"]="Kh", ["Һ"]="H", ["Ц"]="Ts",["Ч"]="Ç", ["Ш"]="Š",     ["Щ"]="Şç", ["Ъ"]="ʺ", ["Ы"]="İ",
["Ь"]="ʹ", ["Э"]="E", ["Ю"]="Yu", ["Я"]="Ya",
['а']='a', ['б']='b', ['в']='v', ['г']='g',  ['д']='d', ['е']='e',  ['ё']='yo', ['ж']='j', ['з']='z', ['и']='i', ['й']='y',
['к']='k', ['л']='l', ['м']='m', ['н']='n',  ['о']='o', ['ӧ']='ö',  ['п']='p',  ['р']='r', ['с']='s', ['т']='t',
['у']='u', ['ӱ']='ü', ['ф']='f', ['х']='kh',  ['ц']='ts', ['ч']='ç',  ['ш']='ş', ['щ']='şç',['ъ']='ʺ', ['ы']='ı',
['ь']='ʹ', ['э']='e', ['ю']='yu', ['я']='ya',
}
local mapping = { ['дж']= 'c' , ['Дж']= 'C', ['ң']='ñ' ,['Ң']='Ñ' ,
                  ['къ']='q',   ['Къ']='Q' , ['нъ']='ñ',['Нъ']='Ñ'

}
function export.tr(text, lang, sc)
	-- Ё needs converting if is decomposed
	text = text:gsub("ё","ё"):gsub("Ё","Ё")
 
	-- е after a vowel or at the beginning of a text becomes ye
	text = mw.ustring.gsub(text, "([АОӨУҮЫЕЯЁЮИЕЪЬаоөуүыэяёюиеъь%A][\204\129\204\128]?)е","%1yö")
	text = mw.ustring.gsub(text, "^Е","Yö")
	text = mw.ustring.gsub(text, "^е","yö")
	text = mw.ustring.gsub(text, "([^Ѐ-ӿ])Е","%1yö")
	text = mw.ustring.gsub(text, "([^Ѐ-ӿ])е","%1yö")
 
	return (mw.ustring.gsub(text,'.',tab))
end
 
return export