La documentation pour ce module peut être créée à Module:sgpron/doc

local p={}

function p.pron_mot(titre)
    
    local pron=string.lower(titre)
    pron="[."..string.gsub(pron,"['' %-’]",".")..".]"
    local t3={["tch"]="X", ["ngb"]="Q"}
    local t2={["qu"]="k", ["nz"]="C", ["ny"]="N", ["ng"]="G", ["nd"]="D", ["mv"]="V", ["mp"]="P", ["mb"]="B", ["gb"]="q", ["ch"]="X", ["sh"]="S"}
    local t1={["z"]="z", ["j"]="C", ["y"]="j", ["x"]="C", ["w"]="w", ["v"]="v", ["u"]="u1.", ["t"]="t", ["s"]="s", ["r"]="r", ["q"]="k", ["p"]="p", ["O"]="O1.", ["o"]="o1.", ["n"]="n", ["m"]="m", ["l"]="l", ["k"]="k", ["i"]="i1.", ["h"]="h", ["g"]="g", ["f"]="f", ["E"]="E1.", ["e"]="e1.", ["d"]="d", ["b"]="b", ["a"]="a1.", ["ü"]="u3.", ["ö"]="o3.", ["ï"]="i3.", ["ë"]="e3.", ["ä"]="a3.", ["û"]="u5.", ["ô"]="o5.", ["î"]="i5.", ["ê"]="e5.", ["â"]="a5."}
    for k,v in pairs(t3) do
       pron=string.gsub(pron,k,v)
    end       
    for k,v in pairs(t2) do
       pron=string.gsub(pron,k,v)
    end       
    for k,v in pairs(t1) do
       pron=string.gsub(pron,k,v)
    end       
    pron=string.gsub(pron,"%.%.+",".")
    -- les sons longs
    pron=string.gsub(pron,"([aeEioOu])([135])%.%1%2(n?)%.","%1%3ː%2.")
    pron=string.gsub(pron,"([^%.])wu([135])(n?)%.","%1uː%2%3.")
    pron=string.gsub(pron,"ji([135])(n?)%.","iː%1.")
    -- les sons modulés
    pron=string.gsub(pron,"([aeiouOE])([135])%.%1([135])(n?)%.","%1%4%2%3.")

    -- les diphtongues spéciales
    pron=string.gsub(pron,"w([aeEioO])([135])(n?)%.","u%1%3%2.")
    pron=string.gsub(pron,"j([aeEoOu])([135])(n?)%.","i%1%3%2.")
    -- les diphtongues tout court
    pron=string.gsub(pron,"([^aeEioOu])([aeEioOu])([135])%.([aeEioOu])([135])(n*)%.","%1%2%4%6%3%5.")
    -- les nasales
    pron=string.gsub(pron,"([aeEioOu])([135]+)%.?n%.","%1n%2.")
    pron=string.gsub(pron,"([aeEioOu])([135]+)%.?n([^aeEioOu])","%1n%2.%3")

    pron=string.gsub(pron,"i([aeEioO])","j%1")
    pron=string.gsub(pron,"u([aeEoOu])","w%1")
    
    pron=string.gsub(pron,"11+","1")
    pron=string.gsub(pron,"33+","3")
    pron=string.gsub(pron,"55+","5")
    local pron1=pron
    local t22={["on"]="ɔ̃", ["in"]="ĩ", ["un"]="ũ", ["an"]="ã", ["en"]="ɛ̃"}
    local t21={["X"]="t͡ʃ", ["Q"]="ⁿɡ͡b", ["C"]="ⁿd͡ʒ", ["N"]="ŋ", ["G"]="ŋ͡ɡ", ["D"]="n͡d", ["V"]="ɱ͡v", ["P"]="m͡p", ["B"]="m͡b", ["q"]="ɡ͡b", ["S"]="ʃ", ["z"]="z", ["C"]="ⁿd͡ʒ", ["w"]="w", ["v"]="v", ["u"]="u", ["t"]="t", ["s"]="s", ["r"]="r", ["k"]="", ["p"]="p", ["o"]="ɔ", ["O"]="o", ["n"]="n", ["m"]="m", ["l"]="l", ["k"]="k", ["j"]="j", ["i"]="i", ["h"]="h", ["g"]="ɡ", ["f"]="f", ["e"]="ɛ", ["E"]="e", ["d"]="d", ["b"]="b", ["a"]="a", ["1"]="˩", ["3"]="˧", ["5"]="˥"}
    for k,v in pairs(t22) do
       pron=string.gsub(pron,k,v)
    end     
    for k,v in pairs(t21) do
       pron=string.gsub(pron,k,v)
    end     
    pron=string.gsub(pron,"^%[%.(.*)%.%]$","%1")
    --return pron1.."/"..pron
    return pron
end

function p.pron(frame)
    local args = frame:getParent().args
    local titre = args[1] and mw.text.trim(args[1]) or ''
    return p.pron_mot(titre)
end

return p