မာတိကာသို့ ခုန်သွားရန်

မဝ်ဂျူ:or-IPA

နူ ဝိက်ရှေန်နရဳ

Documentation for this module may be created at မဝ်ဂျူ:or-IPA/doc

local export = {}

local u = mw.ustring.char
local gsub = mw.ustring.gsub

local consonants = {
	--common
	["କ"]="k", ["ଖ"]="kʰ", ["ଗ"]="ɡ", ["ଘ"]="ɡʱ", ["ଙ"]="ŋ",
	["ଚ"]="t͡ʃ", ["ଛ"]="t͡ʃʰ", ["ଜ"]="d͡ʒ", ["ଝ"]="d͡ʒʱ", ["ଞ"]="ɲ",
	["ଟ"]="ʈ", ["ଠ"]="ʈʰ", ["ଡ"]="ɖ", ["ଢ"]="ɖʱ", ["ଣ"]="ɳ",
	["ତ"]="t", ["ଥ"]="tʰ", ["ଦ"]="d", ["ଧ"]="dʱ", ["ନ"]="n",
	["ପ"]="p", ["ଫ"]="pʰ", ["ବ"]="b", ["ଭ"]="bʱ", ["ମ"]="m",
	["ଯ"]="d͡ʒ", ["ୟ"]="j", ["ର"]="ɾ", ["ଲ"]="l", ["ଳ"]="ɭ",
	["ଵ"]="ʋ", ["ୱ"]="w", ["ଶ"]="s", ["ଷ"]="s", ["ସ"]="s", ["ହ"]="h",
	--nuktas
	["କ଼"]="q", ["ଖ଼"]="x", ["ଗ଼"]="ɣ", ["ଜ଼"]="z", ["ଝ଼"]="ʒ",
	["ଡ଼"]="ɽ", ["ଢ଼"]="ɽʱ", ["ଫ଼"]="f",
}

local diacritics = {
	["ା"]="a", ["ି"]="i", ["ୀ"]="i", ["ୁ"]="u", ["ୂ"]="u",
	["େ"]="e", ["ୈ"]="ɔi̯", ["ୋ"]="o", ["ୌ"]="ɔu̯",
	["ୃ"]="ɾu", ["ୄ"]="ɾu", ["ୢ"]="lu", ["ୣ"]="lu",
	["୍"]="", [""] = "ɔ",
}

local nonconsonants = {
	["ଅ"]="ɔ", ["ଆ"]="a", ["ଇ"]="i", ["ଈ"]="i", ["ଉ"]="u", ["ଊ"]="u",
	["ଏ"]="e", ["ଐ"]="ɔi̯", ["ଓ"]="o", ["ଔ"]="ɔu̯", ["ଉ"]="u", ["ଊ"]="u",
	["ଋ"]="ɾu", ["ୠ"]="ɾu", ["ଌ"]="lu", ["ୡ"]="lu",
}


function export.to_IPA(text)

	text = gsub(
		text,
		"([କ-ହୟୱ]଼?)([ା-୍]?)([ଁଂ]?)",
		function(c, d, a)
			return consonants[c] .. diacritics[d] .. (a ~= "" and u(0x0303) or "")
		end)
	text = gsub(
		text,
		"([ଅ-ଔୠୡ])([ଁଂ]?)",
		function(n, a)
			return nonconsonants[n] .. (a ~= "" and u(0x0303) or "")
		end)

	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
	IPA_text = require("Module:IPA").format_IPA_full(
		require("Module:languages").getByCode("or"),
		{ { pron = "/" .. transcription .. "/" } })

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

end

return export