Module:jdt-IPA

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


local export = {}

local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("jdt")
local rsubn = mw.ustring.gsub

local tt_ipa = {
	["a"] = "a",
	["b"] = "b",
	["c"] = "t͡ʃ",
	["ç"] = "d͡ʒ",
	["d"] = "d",
	["e"] = "ɛ",
	["ə"] = "æ",
	["f"] = "f",
	["g"] = "ɡ",
	["h"] = "h",
	["ⱨ"] = "ʕ",
	["ħ"] = "ħ",
	["i"] = "ɪ",
	["j"] = "j",
	["k"] = "k",
	["l"] = "l",
	["m"] = "m",
	["n"] = "n",
	["o"] = "o",
	["p"] = "p",
	["q"] = "ɢ",
	["r"] = "ɾ",
	["s"] = "s",
	["ş"] = "ʃ",
	["t"] = "t",
	["u"] = "u",
	["v"] = "v",
	["x"] = "χ",
	["y"] = "y",
	["z"] = "z"
}

function export.show(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 _, word in ipairs(p) do
        table.insert(results, {pron = "/" .. rsubn(word, ".", tt_ipa) .. "/"})
    end

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

return export