Module:User:Awesomemeeos/farsiIPA

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This is a private module sandbox of Awesomemeeos, for their own experimentation. Items in this module may be added and removed at Awesomemeeos's discretion; do not rely on this module's stability.


local export = {}
 
local singlechar = {
	["y"]='j', ["č"]='C', ["j"]='J', ["r"]='ɾ', ["ʀ"]='r', ["w"]='u̯',
	["ž"]='ʒ', ["š"]='ʃ', ["ğ"]='ʔ', ["’"]='ɢ', ["q"]='ɢ', ["g"]='ɡ', ["-"]='ˌ',
	["a"]='æ', ["â"]='ɒː', ["i"]='e̞', ["î"]='iː', ["e"]='iː', ["u"]='o', ["û"]='uː', ["o"]='uː',
};
 
function export.pronunciation(text, lang, sc)
	if type(text) == "table" then
		text, lang, sc = text.args[1], text.args[2], text.args[3]
	end

	text = mw.ustring.gsub(text, '([ptCk])', "%1ʰ")
	text = mw.ustring.gsub(text, 'n([kg])', "ŋ%1")
	text = mw.ustring.gsub(text, 'n([pb])', "m%1")
	text = mw.ustring.gsub(text, 'f([mnŋbdg’qvzJrl])', "v%1") -- see if we can make a set instead of repeating it like this
	text = mw.ustring.gsub(text, 'k([mnŋbdg’qvzJrl])', "g%1")
	text = mw.ustring.gsub(text, 's([mnŋbdg’qvzJrl])', "z%1")
	text = mw.ustring.gsub(text, 'š([mnŋbdg’qvzJrl])', "ž%1")
	text = mw.ustring.gsub(text, 'x([mnŋbdg’qvzJrl])', "ɣ%1")
	text = mw.ustring.gsub(text, '([^aâeiouy’bdfghJklmnpqrstvyxzCğšž])r', "%1ʀ") -- also alternates with /ɾ/
	text = mw.ustring.gsub(text, '^r', "ʀ") -- also alternates with /ɾ/
	text = mw.ustring.gsub(text, 'r([tdszšlž])', "ɹ(ː)%1") -- also alternates with /ɾ/
	text = mw.ustring.gsub(text, '.', singlechar)
	text = mw.ustring.gsub(text, 'kʰ([^ɒɔouɵ])', "kʲʰ%1") -- see if we can make a set instead of repeating it like below
	text = mw.ustring.gsub(text, 'kʰ$', "kʲʰ")
	text = mw.ustring.gsub(text, 'ɡ([^ɒɔouɵ])', "ɡʲ%1")
	text = mw.ustring.gsub(text, 'ɡ$', "ɡʲ")
	text = mw.ustring.gsub(text, '([td])', "%1̺") -- should also be ◌̻
	text = mw.ustring.gsub(text, 'C', "t͡ʃ")
	text = mw.ustring.gsub(text, 'J', "d͡ʒ")
	text = mw.ustring.gsub(text, 'aj', "ei̯")
	text = mw.ustring.gsub(text, 'au', "ou̯")

	return text
end
 
return export