Module:tkl-IPA

local export = {}

local m_IPA = require("Module:IPA") local lang = require("Module:languages").getByCode("tkl") local rsub = mw.ustring.gsub local rlower = mw.ustring.lower

local function phonetic(text) text = rlower(text) text = rsub(text, "'", "ˈ") text = rsub(text, "[ptkfshvmngrl]", ".%1") text = rsub(text, "ˈ([āēīōūaeiou])", ".ˈ%1") text = rsub(text, "([āēīōūaeiou])([āēīōūaeiou])", "%1.%2") text = rsub(text, "ˈ%.", ".ˈ") text = rsub(text, "^%.", "") text = rsub(text, " %.", " ") text = rsub(text, "ā", "aː") text = rsub(text, "ē", "eː") text = rsub(text, "ī", "iː") text = rsub(text, "ō", "oː") text = rsub(text, "ū", "uː") text = rsub(text, "g", "ŋ") text = rsub(text, "f", "ɸ") text = rsub(text, "h([aou])", "hʲ%1") text = rsub(text, "ɸ([ou])", "hᵝ%1") text = rsub(text, "ɸa", "ha") text = rsub(text, "r", "ɹ") return text end

function export.IPA(frame) local words = {} for _, word in ipairs(frame:getParent.args) do		table.insert(words, word) end if #words == 0 then error("Have to put in the first parameter with stress!") end local IPA_results = {} for _, word in ipairs(words) do table.insert(IPA_results, { pron = "[" .. phonetic(word) .. "]" }) end return m_IPA.format_IPA_full { lang = lang, items = IPA_results } end

return export