Jump to content

Module:sia-translit

Wiktionary වෙතින්

This module will transliterate Akkala Sami භාෂාව text. 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:sia-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 U = mw.ustring.char
local rsubn = mw.ustring.gsub

local macron = U(0x0304)

local tt = {
	["А"]='A', ["а"]='a',
	["Ӓ"]="Ä", ["ӓ"]="ä",
	["А̊"]="Å", ["а̊"]="å",
	["Б"]='B', ["б"]='b',
	["В"]='V', ["в"]='v',
	["Ѵ"]='W', ["ѵ"]='w',
	["Г"]='G', ["г"]='g',
	["Д"]='D', ["д"]='d',
	["Е"]='Je', ["е"]='je',
	["Ё"]="Jo", ["ё"]="jo",
	["Ж"]='Ž', ["ж"]='ž',
	["З"]='Z', ["з"]='z',
	["Һ"]="H", ["һ"]="h", ["ʼ"]="h",
	["И"]='I', ["и"]='i',
	["Ӣ"]="Ī", ["ӣ"]="ī",
	["Й"]="J", ["й"]="j",
	["Ј"]="J̥", ["ј"]="j̥", ["Ҋ"]="J̥", ["ҋ"]="j̥",
	["К"]='K', ["к"]='k',
	["К̌"]='Ǩ', ["к̌"]='ǩ',
	["Л"]='L', ["л"]='l',
	["М"]='M', ["м"]='m',
	["Н"]='N', ["н"]='n',
	["Ӊ"]="N̥", ["ӊ"]="n̥",
	["Ӈ"]="Ŋ", ["ӈ"]="ŋ",
	["О"]='O', ["о"]='o',
	["П"]='P', ["п"]='p', 
	["Р"]='R', ["р"]='r',
	["С"]='S', ["с"]='s',
	["Т"]='T', ["т"]='t',
	["У"]='U', ["у"]='u', 
	["Ӯ"]="Ū", ["ӯ"]="ū",
	["Ф"]='F', ["ф"]='f',
	["Х"]='X', ["х"]='x',
	["Ц"]='C', ["ц"]='c',
	["Ч"]='Č', ["ч"]='č',
	["Ш"]='Š', ["ш"]='š',
	["Щ"]="Šč", ["щ"]="šč",
	["Ы"]="Y", ["ы"]="y",
	["Ӹ"]="Ï", ["ӹ"]="ï",
	["Ъ"]="", ["ъ"]="",
	["Ь"]="’", ["ь"]="’", ["Ҍ"]= "’", ["ҍ"]="’",
	["Э"]="E", ["э"]="e",
	["Ӭ"]="’E", ["ӭ"]="’e",
	["Ю"]="Ju", ["ю"]="ju",
	["Я"]="Ja", ["я"]="ja",
}

local vowel = "аӓеёиӣоуӯыӹэӭюяАӒЕЁИӢОУӮЫӸЭӬЮЯ"

function export.tr(text, lang, sc)
	text = rsubn(text, "^" .. "я" .. macron, "jā")
	text = rsubn(text, "^" .. "е" .. macron, "jē")
	text = rsubn(text, "^" .. "Я" .. macron, "Jā")
	text = rsubn(text, "^" .. "Е" .. macron, "Jē")

	text = rsubn(text, " " .. "я" .. macron, " jā")
	text = rsubn(text, " " .. "e" .. macron, " jē")
	text = rsubn(text, " " .. "Я" .. macron, " jā")
	text = rsubn(text, " " .. "E" .. macron, " jē")

	text = rsubn(text, "([^" .. vowel .. "НнЪъЬьҌҍ])е", "%1ьэ")
	text = rsubn(text, "([^" .. vowel .. "НнЪъЬьҌҍ])ё", "%1ьо")
	text = rsubn(text, "([^" .. vowel .. "НнЪъЬьҌҍ])ю", "%1ьу")
	text = rsubn(text, "([^" .. vowel .. "НнЪъЬьҌҍ])я", "%1ьа")
	
	text = rsubn(text, "([^" .. vowel .. "НнЪъЬьҌҍ])Е", "%1ЬЭ")
	text = rsubn(text, "([^" .. vowel .. "НнЪъЬьҌҍ])Ё", "%1ЬО")
	text = rsubn(text, "([^" .. vowel .. "НнЪъЬьҌҍ])Ю", "%1ЬУ")
	text = rsubn(text, "([^" .. vowel .. "НнЪъЬьҌҍ])Я", "%1ЬА")
	
	text = rsubn(text, "([нН])ь", "%1й")
	text = rsubn(text, "НЬ", "НЙ")
	
	text = rsubn(text, "([лЛ])ҍ", "%1й")
	text = rsubn(text, "Лҍ", "ЛЙ")

	text = rsubn(text, '.', tt)
	
	return text
end

return export
"https://si.wiktionary.org/w/index.php?title=Module:sia-translit&oldid=163846" වෙතින් සම්ප්‍රවේශනය කෙරිණි