Pergi ke kandungan

Modul:mfa-ae hujung

Daripada Wikikamus
(Dilencongkan daripada Modul:mfa-e hujung)

local p = {}

function p.main(frame)
	local parent = frame:getParent()
	local input = mw.text.trim(parent.args[1] or "")

	-- Detect and split if the word ends with "ae"
	local base, rest = input:match("^(.-)ae(%s.*)$")
	if not base then
		base = input:match("^(.-)ae$")
		rest = ""
	end

	-- If input doesn’t end with "ae", just return a single alt link
	if not base then
		return frame:preprocess('{{alt|mfa|' .. input .. '}}')
	end

	local endings = { "e", "ea", "ei", "ey" }
	local results = {}

	for _, ending in ipairs(endings) do
		local form = base .. ending .. rest
		local altWikitext = '{{alt|mfa|' .. form .. '}}'
		table.insert(results, frame:preprocess(altWikitext))
	end

	return table.concat(results, ", ")
end

return p