Module:User:AleksiB 1945/dv-IPA

local export = {}

local lang = require("Module:languages").getByCode("dv") local sc = require("Module:scripts").getByCode("Thaa") local m_IPA = require("Module:IPA") local gsub = mw.ustring.gsub

local consonants = { ['ހ'] = 'h', ['ށ'] = 'ʂ', ['ނ'] = 'n', ['ރ'] = 'r', ['ބ'] = 'b', ['ޅ'] = 'ɭ', ['ކ'] = 'k', ['އ'] = '', ['ވ'] = 'v', ['މ'] = 'm', ['ފ'] = 'f', ['ދ'] = 'd', ['ތ'] = 't', ['ލ'] = 'l', ['ގ'] = 'g', ['ޏ'] = 'ɲ', ['ސ'] = 's', ['ޑ'] = 'ɖ', ['ޒ'] = 'z', ['ޓ'] = 'ʈ', ['ޔ'] = 'j', ['ޕ'] = 'p', ['ޖ'] = 'd͡ʒ', ['ޗ'] = 't͡ʃ', ['ޱ'] = 'ɳ', ['ޘ'] = 's', ['ޙ'] = 'h', ['ޚ'] = 'x', ['ޛ'] = 'z', ['ޜ'] = 'z', ['ޝ'] = 'ʃ', ['ޞ'] = 's', ['ޟ'] = 'd', ['ޠ'] = 't', ['ޡ'] = 'z', ['ޢ'] = '', ['ޣ'] = 'g', ['ޤ'] = 'k', ['ޥ'] = 'ʋ', }

-- this controls prenasalized stop digraphs consisting of ނ and a voiced stop local prenasal = { ['ބ'] = 'ᵐ', ['ދ'] = 'ⁿ', ['ގ'] = 'ⁿ', ['ޑ'] = 'ⁿ', }

local vowel_diacritics = { ['ަ'] = 'a', ['ާ'] = 'aː', ['ި'] = 'i', ['ީ'] = 'iː',  ['ު'] = 'u',  ['ޫ'] = 'uː', ['ެ'] = 'e', ['ޭ'] = 'eː', ['ޮ'] = 'o', ['ޯ'] = 'oː', ['ް'] = ''		-- virama }

local other = { }

local adjust1 = { }

local adjust2 = { ['t͡ʃt͡ʃ']='t̚t͡ʃ', ['d͡ʒd͡ʒ']='d̚d͡ʒ', ['ɲd͡ʒ']='n̠ʲd͡ʒ', }

function export.link(term) return require("Module:links").full_link{ term = term, lang = lang, sc = sc } end

function export.to_IPA(text) text = gsub(		text,	  "([ක-ෆ])([ා-්]?)",		function(c, d)			return consonants[c] .. vowel_diacritics[d]		end)

for k, v in pairs(adjust1) do		text = gsub(text, k, v)	end

-- If an independent vowel is after another vowel, assume diphthong text = gsub(text, "([ɐaeiou]ː?)•", "%1") text = gsub(text, '.', other)

-- Phonetic transcription text2 = text for k, v in pairs(adjust2) do		text2 = gsub(text2, k, v)	end

return (text == text2 and { text } or { text, text2 })

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 transcriptions = export.to_IPA(text) local IPA_text if not transcriptions[2] then IPA_text = m_IPA.format_IPA_full { lang = lang, items = , }	else IPA_text = m_IPA.format_IPA_full { lang = lang, items = {{ pron = "/" .. transcriptions[1] .. "/" }, { pron = "[" .. transcriptions[2] .. "]" }},		}	end

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

return export