local export = {}
local adjust1 = {
['ā'] = 'aː', ['ē'] = 'eː', ['ī'] = 'iː', ['ō'] = 'oː', ['ū'] = 'uː', ['ʻ'] = 'ʔ',
['á'] = 'ˈa', ['é'] = 'ˈe', ['í'] = 'ˈi', ['ó'] = 'ˈo', ['ú'] = 'ˈu',
}
function export.to_IPA(text)
text = mw.ustring.lower(text)
text = mw.ustring.gsub(text, '[aeiouāēīōūáéíóú]', '%0.')
text = mw.ustring.gsub(text, 'ng', 'ŋ')
text = mw.ustring.gsub(text, '[āēīōūʻáéíóú]', adjust1)
text = mw.ustring.gsub(text, '([%lŋʔ])(ˈ)', '%2%1')
text = mw.ustring.gsub(text, '[%s%-]', '')
text = mw.ustring.gsub(text, '%.$', '')
return text
end
function export.show(frame)
local args = frame:getParent().args
local page_title = mw.title.getCurrentTitle().text
local text = args[1] or page_title
local qualifier = args["q"] or nil
local transcription = export.to_IPA(text)
local IPA_text
if transcription then
IPA_text = require("Module:IPA").format_IPA_full {
lang = require("Module:languages").getByCode("to"),
items = {{ pron = "/" .. transcription .. "/" }},
}
end
return "* " .. (qualifier and require("Module:qualifier").format_qualifier{qualifier} .. " " or "")
.. IPA_text
end
return export