Module:User:ZxxZxxZ/Cyrl-translit

-- Transliteration for the Cyrillic.

local export = {} local tr_table_default = { ["а"]="a", ["б"]="b",  ["в"]="v",  ["г"]="g",  ["ғ"]="ğ",  ["д"]="d",  ["ж"]="ž",  ["ѕ"]="ẑ", ["и"]="i", ["і"]="i",  ["ї"]="ji", ["й"]="j",  ["ј"]="j",  ["к"]="k",  ["ќ"]="kj", ["қ"]="q", ["л"]="l", ["љ"]="lj", ["н"]="n",  ["њ"]="nj", ["о"]="o",  ["п"]="p",  ["р"]="r",  ["с"]="s", ["т"]="t", ["ћ"]="ć",  ["у"]="u",  ["ў"]="w",  ["ц"]="c",  ["ч"]="č",  ["џ"]="dž", ["ҷ"]="ç", ["ш"]="š", ["щ"]="šč", ["ф"]="f",  ["х"]="x",  ["џ"]="dž", ["ш"]="š",  ["щ"]="šč", ["ф"]="f", ["м"]="m", ["Ђ"]="đ",  ["э"]="e",  ["ё"]="jo", ["ю"]="ju", ["я"]="ja", ["э"]="e",  ["є"]="je", -- ... this table should contain all Cyrillic characters }

-- this table overrides the previous one local tr_table = { ["ady"] = { ["а"]="ā", ["г"]="γ", ["е"]="e", ["ё"]="ë", ["й"]="j", ["у"]="w", ["щ"]="š̍", ["ъ"]="”", ["ы"]="ə", ["ь"]="’", ["э"]="ă", ["я"]="jā" },   ["uk"] = { ["г"]='h', ["ґ"]='g', ["Е"]='E', ["е"]='e', ["Є"]='Je', ["є"]='je', ["и"]='y', ["'"]='ʺ', ["’"]='ʺ', ["ʼ"]= 'ʺ', },   -- ...    }

function export.tr(text, lang) if type(text) == 'table' then text = text.args[1] end

if lang ~= "ady" and lang ~= "uk" then -- not supported return false end

-- language-specific transliteration --

if lang == "ady" then text = mw.ustring.gsub(text, 'гъу', 'ġ°') text = mw.ustring.gsub(text, 'дзу', 'ʒ°') text = mw.ustring.gsub(text, 'жъу', 'ẑ°') -- and so forth end

text = mw.ustring.gsub(text, ".", tr_table[lang])

-- default Cyrillic transliteration --

text = mw.ustring.gsub(text, ".", tr_table_default) text = mw.ustring.toNFD(text) text = mw.ustring.gsub(text, ".", tr_table_default) text = mw.ustring.toNFC(text)

text = mw.ustring.gsub(text, "([АОУЕЯЁЮИӢЕЪЬаоуэяёюиӣеъь][́̀]?)е", "%1je") text = mw.ustring.gsub(text, "^Е", "Je") text = mw.ustring.gsub(text, "^е", "je")

return text end

return export