Module:gd-m1-datpl

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

local export = {}

function export._getParameters(frame_args, arg_list)
	local new_args = {};
	local index = 1;
	local value;
	
	for _, arg in ipairs(arg_list) do
		value = frame_args[arg]
		if value == nil then
			value = frame_args[index];
			index = index + 1;
		end
		new_args[arg] = value;
	end
	
	return new_args;
end

function export.show(frame)
	local new_args = export._getParameters(frame.args, { 'nomsg', 'gensg', 'pl', 'broad' });
	local nom_sg = new_args['nomsg'] or '';
	local gen_sg = new_args['gensg'] or '';
	local pl = new_args['pl'] or '';
	local broad = tonumber(new_args['broad']) or 0;

	if pl == '' then
		return nom_sg .. 'aibh';
	end
	
	if pl == 'an' and broad == 1 then
		return nom_sg .. 'aibh';
	end
	
	if pl == 'an' and broad == 0 then
		return gen_sg .. 'ibh';
	end
	
	if pl == 'aichean' then
		return nom_sg .. 'aichibh';
	end
	
	return nom_sg .. 'aibh';
end

return export