Module:User:Saph/sandbox
Appearance
- This module sandbox lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox of
export = {}
--[=[
Dime pronunciation module.
Maybe integrable into a unified Aroid pronunciation module?
]=]--
local m_IPA = require("Module:IPA")
local dim = require("Module:languages").getByCode("dim")
local pagename = mw.loadData("Module:headword/data").pagename
local ulower = mw.ustring.lower
local RETRACT = "\204\160"
local function pron(text)
text = ulower(text)
text = text:gsub("dʒ", "j") -- Temporarily encode dʒ for geminate checking
if text:find("([^ptkbdgfsšzžčmnlwy])%1") then error("Invalid geminate.") end
text = text:gsub("([ptkbdgfsšzžčmnlwy]’?)%1", "%1ː")
:gsub("n([šžč])", "n" .. RETRACT .. "%1")
:gsub("[šžygj]", {["š"] = "ʃ", ["ž"] = "ʒ", ["y"] = "j", ["g"] = "ɡ", ["j"] = "dʒ"})
:gsub("p$|(.)p(.)", "%1ɸ%2")
:gsub("^([ptk])", "%1ʰ")
if text:find("[^ptksč]’") then error("Invalid ejective.") end
return text:gsub("č", "tʃ")
end
function export.make(frame)
local args = frame:getParent().args
args[1] = args[1] or pagename
return m_IPA.format_IPA_full{ lang = dim, items = {{ pron = "[" .. pron(args[1]) .. "]" }} }
end
return export