Module:User:Erutuon/transliteration

local export = {}

local use_array = true

local m_data = mw.loadData("Module:User:Erutuon/transliteration/data")

local str_gsub = string.gsub local UTF8_char = "[%z\1-\127\194-\244][\128-\191]*"

function export.one_character_replace(text, mapping) text = str_gsub(text, UTF8_char, mapping) return text end

function export.cluster_replace(text, mapping) if mapping[1] then for _, replacement in ipairs(mapping) do			text = str_gsub(text, replacement[1], replacement[2]) end else for digraph, replacement in pairs(mapping) do			text = str_gsub(text, digraph, replacement) end end return text end

function export.ady(text) local data = m_data.ady data = use_array and data.array or data.map text = export.one_character_replace(text, data[1]) text = export.cluster_replace(text, data[3]) text = export.cluster_replace(text, data[2]) return text end

function export.show(frame) local func = frame.args[1] return export[func](frame.args[2]) end

return export