Jump to content

Module:st-common

From Wiktionary, the free dictionary


local export = {}

-- Does not function properly if the given string contains both kg and kh. Shouldn't be a difficult fix but I'm not sure if it's necessary for now.
function export.convert_ortho(frame)
	word = frame.args[1]
	
	local differences = { 
		["di"] = "li",
		["du"] = "lu",
		["kg"] = "kh",
		["kh"] = "kʼh",
		["tsh"] = "tš",
		["tjh"] = "ch",
		["([^n])y"] = "%1e",
		["w"] = "o",
		["fj"] = "fsh",
		["pjh"] = "psh",
		["^nn"] = "ʼn",
		["(%s)nn"] = "%1ʼn",
		["^mm"] = "ʼm",
		["(%s)mm"] = "%1ʼm"
	}
	
	local word2 = word
	for k, v in pairs(differences) do
		if mw.ustring.find(word, k) then -- Prevents iterative kg -> kh -> k'h.
			word2 = mw.ustring.gsub(word2, k, v)
		end
	end
	
	return word2
end

return export