မဝ်ဂျူ:zgh-pronunciation

နူ ဝိက်ရှေန်နရဳ
ထာမ်ပလိက်တဏအ်ဒးနွံကဵုလိက်စၟတ်သမ္တီမချူလဝ်သာဓက။
သ္ပဂုန်တုဲထာမ်ပလိက်တဏအ်ဒးစၟတ်သမ္တီကဵုလိက်မချူလဝ်နူကဵုဓမံက်ထ္ၜးကဵုဗီုပြၚ်ကိစ္စမရန်တၟအ်လဝ် ကဵု ပရေၚ်မရပ်စပ်လ္တူမုက်လိက်နကဵုလိက်စၟတ်သမ္တီမချူလဝ်သာဓက

local export = {}

-- single characters that map to IPA sounds   
local phonetic_chars_map = {
	["ⴰ"]="a", ["ⴱ"]="b", ["ⴳ"]="ɡ", ["ⴷ"]="d", ["ⴹ"]="dˤ", ["ⴻ"]="ə", 
    ["ⴼ"]="f", ["ⴽ"]="k", ["ⵀ"]="h", ["ⵃ"]="ħ", ["ⵄ"]="ʕ",["ⵅ"]="χ", 
    ["ⵇ"]="q", ["ⵉ"]="i", ["ⵊ"]="ʒ", ["ⵍ"]="l", ["ⵎ"]="m", ["ⵏ"]="n", 
    ["ⵓ"]="u", ["ⵔ"]="r", ["ⵕ"]="rˤ", ["ⵖ"]="ɣ", ["ⵙ"]="s", ["ⵚ"]="sˤ", 
    ["ⵛ"]="ʃ", ["ⵜ"]="t", ["ⵟ"]="tˤ", ["ⵡ"]="w", ["ⵢ"]="j", ["ⵣ"]="z", 
    ["ⵥ"]="zˤ", ["ⵯ"]="ʷ"
}

function export.pronunciation(word)

	if type(word) == "table" then
		word = word.args[1] or word:getParent().args[1]
	end
	if not word or (word == "") then
		error("Please put the word as the first positional parameter!")
	end

	local phonetic = word

	-- then long consonants that are orthographically geminated.
	phonetic = mw.ustring.gsub(phonetic, "(.)%1", "%1ː")

	phonetic = mw.ustring.gsub(phonetic, '.', phonetic_chars_map)

	return phonetic
end
 
return export