local export = {}
local PAGENAME = mw.title.getCurrentTitle().text
local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("ce")
local scripts_IPA_single = {
= "a", = "b", = "u̯", = "ɡ", = "d", = "e", = "jo", = "ʒ",
= "z", = "i", = "i̯", = "k", = "l", = "m", = "n", = "o",
= "p", = "r", = "s", = "t", = "u", = "f", = "x", = "t͡s",
= "t͡ʃ", = "ʃ", = "ʃt͡ʃ", = "ʔ", = "ɨ", = "ʲ", = "e", = "ju",
= "ja", = "ʕ", = "eː", = "aː", = "oː", = "oː", = "ː",
}
local scripts_IPA_double = {
= "ʁ", = "q͡x", = "q͡xʼ", = "kʼ", = "pʼ", = "tʼ", = "ħ",
= "h", = "t͡sʼ", = "t͡ʃʼ", = "tː", = "pː", = "kː", = "sː",
= "iː", = "uː", = "u̯o", = "uːo̯", = "i̯e", = "iːe̯", = "æ",
}
local scripts_IPA_triple = {
= "q͡xː", = "r̥", = "yː",
}
local scripts_IPA_diphthongs = {
= "eu̯", = "ou̯", = "oi̯", = "ai̯",
}
function export.to_IPA(word)
word = mw.ustring.lower(word)
for pat, repl in pairs(scripts_IPA_triple) do
word = mw.ustring.gsub(word, pat, repl)
end
for pat, repl in pairs(scripts_IPA_double) do
word = mw.ustring.gsub(word, pat, repl)
end
for pat, repl in pairs(scripts_IPA_diphthongs) do
word = mw.ustring.gsub(word, pat, repl)
end
local consonants = ""
word = mw.ustring.gsub(word, "о̄(" .. consonants .. consonants .. ")", function(post)
return "ɔ̯a" .. post
end)
word = "ˈ" .. word
word = mw.ustring.gsub(word, ".", function(char)
return scripts_IPA_single or char
end)
return "/" .. word .. "/"
end
function export.pronunciation(frame)
local args = frame:getParent().args
local word = args or args or mw.title.getCurrentTitle().text
local ipa = export.to_IPA(word)
local items = { { pron = ipa, note = nil } }
return m_IPA.format_IPA_full { lang = lang, items = items }
end
return export