Module:IPA
Documentation for this module may be created at Module:IPA/doc
-- Converts the various languages' romanization into (broad-transcribed IPA)
local function table_replacer(t, to_lower)
return function(roman_word)
local ipa = roman_word
if to_lower then
ipa = mw.ustring.lower(ipa)
end
for _,subs in ipairs(t) do
ipa = mw.ustring.gsub(ipa, subs[1], subs[2])
end
return ipa
end
end
local langauge_pronouncers = {
ts = table_replacer({
{"^ts","c"},
{"^dz","ż"},
{"c","t͡s"},
{"ż","d͡z"},
{"ł","ɬ"},
{"ğ","ɣ"},
{"q","k͡x"},
{"š","ʃ"},
{"ž","ʒ"},
{"č","t͡ʃ"},
{"j","d͡ʒ"},
{"y","j"},
{"ř","r̥"},
{"ā","aː"},
{"ē","eː"},
{"ī","iː"},
{"ō","oː"},
{"ū","uː"}
}, true)
}
local p = {}
function p.to_ipa(frame)
local function pronounce_word(language)
local f = langauge_pronouncers[language]
if f then
return f
else
return function(x)
return x
end
end
end
local lang = frame.args[1]
local target = frame.args[2]
out, _ = mw.ustring.gsub(target,"(%w+)", pronounce_word(lang))
return "/" .. out .. "/"
end
return p;