Module:xas-translit

This module will transliterate Kamassian language 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:xas-translit/testcases.

Functions edit

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", ["а"]="a", ["Б"]="B", ["б"]="b", ["Г"]="G", ["г"]="g",
	["Д"]="D", ["д"]="d", ["Е"]="E", ["е"]="e", ["Ж"]="Ž", ["ж"]="ž", ["З"]="Z", ["з"]="z",
	["И"]="I", ["и"]="i", ["Й"]="J", ["й"]="j", ["К"]="K", ["к"]="k", ["Л"]="L", ["л"]="l",
	["М"]="M", ["м"]="m", ["Н"]="N", ["н"]="n", ["Ӈ"]="Ŋ", ["ӈ"]="ŋ", ["О"]="O", ["о"]="o",
	["Ӧ"]="Ö", ["ӧ"]="ö", ["Ө"]="Ə̂", ["ө"]="ə̂", ["П"]="P", ["п"]="p", ["Р"]="R", ["р"]="r",
	["С"]="S", ["с"]="s", ["Т"]="T", ["т"]="t", ["У"]="U", ["у"]="u", ["Ӱ"]="Ü", ["ӱ"]="ü",
	["Х"]="X", ["х"]="x", ["Ч"]="Ć", ["ч"]="ć", ["Ш"]="Š", ["ш"]="š", ["ь"]="", ["ʼ"]="ʔ",
	["Ы"]="I̭", ["ы"]="i̭", ["В"]="W", ["в"]="w", ["Ә"]="Ə", ["ә"]="ə",
	["Я"]="A", ["я"]="a", ["Ё"]="O", ["ё"]="o", ["Ю"]="U", ["ю"]="u",
}

function export.tr(text, lang, sc)
	local language = lang
    -- soft consonants 
    text = mw.ustring.gsub(text, "С([ь])", "Ś%1")
    text = mw.ustring.gsub(text, "с([ь])", "ś%1")
    text = mw.ustring.gsub(text, "З([ь])", "Ź%1")
	text = mw.ustring.gsub(text, "з([ь])", "ź%1")
	text = mw.ustring.gsub(text, "Н([ь])", "Ń%1")
	text = mw.ustring.gsub(text, "н([ь])", "ń%1")
	text = mw.ustring.gsub(text, "Л([ь])", "Ĺ%1")
	text = mw.ustring.gsub(text, "л([ь])", "ĺ%1")
	text = mw.ustring.gsub(text, "Дж", "Ʒ́")
	text = mw.ustring.gsub(text, "дж", "ʒ́")
	text = mw.ustring.gsub(text, "([ПпТтКк])х", "%1ʰ")
    
    return (mw.ustring.gsub(text,'.',tab))
end

return export