local export = {}
local lang = require("Module:languages").getByCode("kxv")
local sc = require("Module:scripts").getByCode("Orya")
local m_IPA = require("Module:IPA")
local u = mw.ustring.char
local gsub = mw.ustring.gsub
local consonants = {
--common
="k", ="k", ="ɡ", ="ɡ", ="ŋ",
="t͡ʃ", ="t͡ʃ", ="d͡ʒ", ="d͡ʒ", ="n̪",
="ʈ", ="ʈ", ="ɖ", ="ɖ", ="ɳ",
="t̪", ="t̪", ="d̪", ="d̪", ="n̪",
="p", ="p", ="b", ="b", ="m",
="d͡ʒ", ="j", ="ɾ", ="l", ="ɭ",
="ʋ", ="w", ="s", ="s", ="s", ="h",
--nuktas
="q", ="x", ="ɣ", ="z", ="ʒ",
="ɽ", ="ɽ", ="f",
}
local vowel_diacritics = {
="a", ="aː", ="i", ="iː", ="u", ="uː",
="e", ="eː", ="ɔi̯", ="o", ="oː", ="ɔu̯",
="ɾu", ="ɾu", ="lu", ="lu",
="", = "o",
}
local other = {
="o", ="oː", ="a", ="aː", ="i", ="iː", ="u", ="uː",
="e", ="eː", ="ɔi̯", ="o", ="oː", ="ɔu̯",
="ɾu", ="ɾu", ="lu", ="lu",
-- Other symbols
='m̃', ='ʔ',
}
local adjust1 = {
-- Assimilate the anusvara
)']='ŋ%1',
͡)']='n̪%1', ='n̪%1',
)']='ɳ%1',
̪)']='n̪%1', ='n̪%1',
)']='m%1',
)']='m%1', ='m',
)୕']='%1ː',
}
local adjust2 = {
='n̠ʲd͡ʒ', ='n̠ʲt͡ʃ',
}
function export.link(term)
return require("Module:links").full_link{ term = term, lang = lang, sc = sc }
end
function export.to_IPA(text)
text = gsub(
text,
"(଼?)(?)(?)",
function(c, d, a)
return consonants .. vowel_diacritics .. (a ~= "" and u(0x0303) or "")
end)
text = gsub(
text,
"()(?)",
function(n, a)
return other .. (a ~= "" and u(0x0303) or "")
end)
for k, v in pairs(adjust1) do
text = gsub(text, k, v)
end
-- If an independent vowel is after another vowel, assume diphthong
text = gsub(text, "(ː?)•", "%1")
text = gsub(text, '.', other)
-- Phonetic transcription
text2 = text
for k, v in pairs(adjust2) do
text2 = gsub(text2, k, v)
end
return (text == text2 and { text } or { text, text2 })
end
function export.show(frame)
local args = frame:getParent().args
local page_title = mw.title.getCurrentTitle().text
local text = args or page_title
local qualifier = args or nil
local transcriptions = export.to_IPA(text)
local IPA_text
if not transcriptions then
IPA_text = m_IPA.format_IPA_full {
lang = lang,
items = {{ pron = "/" .. transcriptions .. "/" }},
}
else
IPA_text = m_IPA.format_IPA_full {
lang = lang,
items = {{ pron = "/" .. transcriptions .. "/" }, { pron = " .. "]" }},
}
end
return "* " .. (qualifier and require("Module:qualifier").format_qualifier{qualifier} .. " " or "")
.. IPA_text
end
return export