Module:mu-IPA

local export = {}

local lang = require("Module:languages").getByCode("mu") local sc = require("Module:scripts").getByCode("Latn") local m_translit = require("Module:mu-translit").tr local m_IPA = require("Module:IPA")

local gsub = mw.ustring.gsub local gmatch = mw.ustring.gmatch

local correspondences = { ["S"] = "ʃ", ["C"] = "tʃ", ["K"] = "kʷ", ["G"] = "gʷ", ["N"] = "ŋ͡ɡ", ["D"] = "n͜d", ["B"] = "m͜b", ["X"] = "nʒ", ["M"] = "nz", ["y"] = "j", ["a"] = "ʌ", ["e"] = "ɛ", ["i"] = "ɪ", ["o"] = "ʊ", ["u"] = "ə", ["A"] = "aː", ["E"] = "ɛː", ["I"] = "iː", ["O"] = "oː" }

function export.link(term) return require("Module:links").full_link{ term = term, lang = lang, sc = sc } end

function export.toIPA(text) local result = {}

local translit = m_translit(text, lang, sc, "IPA") if not translit then error('The term "' .. text .. '" could not be transliterated.') end

for character in gmatch(translit, ".") do		table.insert(result, correspondences[character] or character) end

result = table.concat(result)

return result end

function export.make(frame) local args = frame:getParent.args local pagetitle = mw.title.getCurrentTitle.text

local p, results = {}, {}

if args[1] then for index, item in ipairs(args) do			table.insert(p, (item ~= "") and item or nil) end else p = { pagetitle } end

for _, Val in ipairs(p) do table.insert(results, { pron = "/" .. export.toIPA(Val) .. "/" }) end

return '* ' .. m_IPA.format_IPA_full { lang = lang, items = results } end

return export