Module:urj-koo-translit

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This module will transliterate Old Komi 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:urj-koo-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 = {
	-- Anbur
	["𐍐"]="a", ["𐍑"]="b", ["𐍒"]="g", ["𐍓"]="d", ["𐍔"]="e",
	["𐍕"]="ž", ["𐍖"]="ǯ", ["𐍗"]="z", ["𐍘"]="ʒ́", ["𐍙"]="j",
	["𐍚"]="k", ["𐍛"]="l", ["𐍜"]="m", ["𐍝"]="n",
	["𐍞"]="ô", ["𐍟"]="p", ["𐍠"]="r", ["𐍡"]="s", ["𐍢"]="t",
	["𐍣"]="v", ["𐍤"]="č", ["𐍥"]="š", ["𐍦"]="č",
	["𐍧"]="ju", ["𐍨"]="y", ["𐍩"]="o", ["𐍪"]="o", ["𐍫"]="f", ["𐍬"]="x",
	["𐍭"]="ʒ́", ["𐍮"]="v", ["𐍯"]="y", ["𐍰"]="je", ["𐍱"]="ê", ["𐍲"]="jê",
	["𐍳"]="ju", ["𐍴"]="ja", ["𐍵"]="ja", ["𐍶"]="a", ["𐍷"]="d", ["𐍸"]="z",
	["𐍹"]="n", ["𐍺"]="s", ["̀"]="",
	-- capital Cyrillic
	["А"]="A", ["Б"]="B", ["В"]="V", ["Г"]="G", ["Д"]="D", ["Е"]="E", ["Ж"]="Ž",
	["З"]="Z", ["Ѕ"]="Ʒ́", ["И"]="I", ["І"]="I", ["К"]="K", ["Л"]="L", ["М"]="M",
	["Н"]="N", ["О"]="O", ["Ѡ"]="O", ["П"]="P", ["Р"]="R", ["С"]="S", ["Т"]="T",
	["Ꙋ"]="U", ["У"]="U", ["Ф"]="F", ["Х"]="X", ["Ц"]="C", ["Ч"]="Č", ["Ш"]="Š",
	["Щ"]="Št", ["Ъ"]="", ["Ꙑ"]="Y", ["Ы"]="Y", ["Ь"]="ʹ", ["Ѣ"]="E", ["Ю"]="Ju",
	["Ꙗ"]="Ja", ["Я"]="Ja", ["Ѧ"]="Ja",
	-- lowercase Cyrillic
	["а"]="a", ["б"]="b", ["в"]="v", ["г"]="g", ["д"]="d", ["е"]="e", ["ж"]="ž",
	["з"]="z", ["ѕ"]="ʒ́", ["и"]="i", ["і"]="i", ["к"]="k", ["л"]="l", ["м"]="m",
	["н"]="n", ["о"]="o", ["ѡ"]="o", ["п"]="p", ["р"]="r", ["с"]="s", ["т"]="t", 
	["ꙋ"]="u", ["у"]="u", ["ф"]="f", ["х"]="x", ["ц"]="c", ["ч"]="č", ["ш"]="š",
	["щ"]="št", ["ъ"]="", ["ꙑ"]="y", ["ы"]="y", ["ь"]="ʹ", ["ѣ"]="e", ["ю"]="ju",
	["ꙗ"]="ja", ["я"]="ja", ["ѧ"]="ja"
}

function export.tr(text, lang, sc)
    local language = lang

    -- palatalisation
    text = mw.ustring.gsub(text, "𐍓̀", "ď")
    text = mw.ustring.gsub(text, "𐍕̀", "ź")
    text = mw.ustring.gsub(text, "𐍛̀", "ľ")
    text = mw.ustring.gsub(text, "𐍝̀", "ň")
    text = mw.ustring.gsub(text, "𐍥̀", "ś")
    text = mw.ustring.gsub(text, "𐍢̀", "ť")
    text = mw.ustring.gsub(text, "𐍤̀", "ć")

    text = mw.ustring.gsub(text, "𐍙̈", "i")
    text = mw.ustring.gsub(text, "𐍣̈", "u")

    return (mw.ustring.gsub(text,'.',tab))
end

return export