This module will transliterate Southern Altai and Northern Altai text per WT:ALT TR and WT:ATV TR.

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:Altai-translit/testcases.

tr(text, lang, sc)
Transliterates a given piece of text written in the script specified by sc, and language specified by lang. When the transliteration fails, returns nil.

local export = {}

local tab = {
	["А"]="A", ["Б"]="B", ["В"]="V", ["Г"]="G", ["Д"]="D", ["Е"]="E", ["Ё"]="Yo", ["Ж"]="Ž", ["З"]="Z", ["И"]="I", ["Й"]="Y", ["Ј"]="J̌", ["J"]="J̌[[Category:Altai text with misused characters|J]]",
	["К"]="K", ["Л"]="L", ["М"]="M", ["Н"]="N", ["Ҥ"]="Ŋ", ["О"]="O", ["Ӧ"]="Ö", ["Ö"]="Ö[[Category:Altai text with misused characters|Ö]]", ["П"]="P", ["Р"]="R", ["С"]="S", ["Т"]="T",
	["У"]="U", ["Ӱ"]="Ü", ["Ф"]="F", ["Х"]="H", ["Ц"]="C", ["Ч"]="Č", ["Ш"]="Š", ["Щ"]="Šč", ["Ъ"]="ʺ", ["Ы"]="Ï", ["Ь"]="ʹ",
	["Э"]="E", ["Ю"]="Yu", ["Я"]="Ya",
	['а']='a', ['б']='b', ['в']='v', ['г']='g', ['д']='d', ['е']='e', ['ё']='yo', ['ж']='ž', ['з']='z', ['и']='i', ['й']='y', ["ј"]="ǰ", ["j"]="ǰ[[Category:Altai text with misused characters|j]]",
	['к']='k', ['л']='l', ['м']='m', ['н']='n', ['ҥ']='ŋ', ['о']='o', ['ӧ']='ö', ['ö']='ö[[Category:Altai text with misused characters|ö]]', ['п']='p', ['р']='r', ['с']='s', ['т']='t',
	['у']='u', ['ӱ']='ü', ['ф']='f',
	['х']='h', ['ц']='c', ['ч']='č', ['ш']='š', ['щ']='šč', ['ъ']='ʺ', ['ы']='ï', ['ь']='ʹ', ['э']='e', ['ю']='yu', ['я']='ya',
}

local iotated = {
	["Е"] = "Ye",
	["е"] = "ye",
}

function export.tr(text, lang, sc)
	local ugsub = mw.ustring.gsub
	
	-- Ё needs to be composed if is decomposed (e + combining diaeresis).
	-- However, this cannot happen in wikitext, only in Lua modules.
	text = mw.ustring.toNFC(text)
	
	-- е after a vowel or at the beginning of a word becomes ye
	-- Note that according to modern Altai orthography ее (instead of ээ) is occationally used for long r
	text = ugsub(text, "([АОӨУҮЫЯЁЮИЪЬаоөуүыяёюиъь%A][́̀]?)е", "%1ye")
	--text = mw.ustring.gsub(text, "([АОӨУҮЫЕЯЁЮИЕЪЬаоөуүыэяёюиеъь%A][́̀]?)е", "%1ye")
	text = ugsub(text, "^[Ее]", iotated)
	text = ugsub(text, "([^Ѐ-ӿ])([Ее])", function(a, b)
			return a .. iotated[b]
		end)
	
	return (ugsub(text, '.', tab))
end
 
return export
"https://si.wiktionary.org/w/index.php?title=Module:Altai-translit&oldid=35526" වෙතින් සම්ප්‍රවේශනය කෙරිණි