This module should NOT be used in its present state. It is unfinished and contains errors.


local export = {}

function export.sw_IPA(text)

	text = mw.ustring.lower(text)

	text = mw.ustring.gsub(text, 'mt', 'm̩t')
	text = mw.ustring.gsub(text, 'nch', 'n̩ch')	

	text = mw.ustring.gsub(text, 'ng\'', 'ŋ')

	text = mw.ustring.gsub(text, 'dh', 'ð')
	text = mw.ustring.gsub(text, 'gh', 'ɣ')
	text = mw.ustring.gsub(text, 'mb', 'ᵐb')
	text = mw.ustring.gsub(text, 'mv', 'ᶬv')
	text = mw.ustring.gsub(text, 'nd', 'ⁿd')
	text = mw.ustring.gsub(text, 'ng', 'ᵑɡ')
	text = mw.ustring.gsub(text, 'nj', 'ⁿdʒ')
	text = mw.ustring.gsub(text, 'nz', 'ⁿz')
	text = mw.ustring.gsub(text, 'ny', 'ɲ')
	text = mw.ustring.gsub(text, 'sh', 'ʃ')
	text = mw.ustring.gsub(text, 'ch', 'tʃ')
	text = mw.ustring.gsub(text, 'th', 'θ')
	text = mw.ustring.gsub(text, 'kh', 'x')

	text = mw.ustring.gsub(text, 'a', 'ɑ')
	text = mw.ustring.gsub(text, 'e', 'ɛ')
	text = mw.ustring.gsub(text, 'i', 'i')
	text = mw.ustring.gsub(text, 'o', 'ɔ')
	text = mw.ustring.gsub(text, 'u', 'u')

	text = mw.ustring.gsub(text, 'b', 'ɓ')
	text = mw.ustring.gsub(text, 'd', 'ɗ')
	text = mw.ustring.gsub(text, 'j', 'ʄ')
	text = mw.ustring.gsub(text, 'f', 'f')
	text = mw.ustring.gsub(text, 'g', 'ɠ')
	text = mw.ustring.gsub(text, 'h', 'h')
	text = mw.ustring.gsub(text, 'y', 'j')
	text = mw.ustring.gsub(text, 'k', 'k')
	text = mw.ustring.gsub(text, 'l', 'l')
	text = mw.ustring.gsub(text, 'm', 'm')
	text = mw.ustring.gsub(text, 'n', 'n')
	text = mw.ustring.gsub(text, 'p', 'p')
	text = mw.ustring.gsub(text, 'r', 'ɾ')
	text = mw.ustring.gsub(text, 's', 's')
	text = mw.ustring.gsub(text, 't', 't')
	text = mw.ustring.gsub(text, 'v', 'v')
	text = mw.ustring.gsub(text, 'w', 'w')
	text = mw.ustring.gsub(text, 'x', 'x')
	text = mw.ustring.gsub(text, 'z', 'z')

	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.sw_IPA(text)
	local IPA_text
	if transcription then
		IPA_text = require('Module:IPA').format_IPA_full(
			require('Module:languages').getByCode('sw'),
			{ { pron = '/' .. transcription .. '/' } })
	end

	return '* ' .. (qualifier and require("Module:qualifier").format_qualifier{qualifier} .. ' ' or '')
		.. IPA_text

end
 
return export