Module:gl-noun

Definition from Wiktionary, the free dictionary
Jump to: navigation, search
The following documentation is located at Module:gl-noun/documentation. [edit]
Useful links: subpage listtransclusionstestcases
Text-x-generic with pencil.svg This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local m_plural = require("Module:gl-plural")
 
local export = {}
 
local lang = require("Module:languages").getByCode("gl")
 
function export.show(frame)
	local args = frame:getParent().args
	PAGENAME = mw.title.getCurrentTitle().text
	NAMESPACE = mw.title.getCurrentTitle().nsText
 
	local head = args["head"]
	local categories = {lang:getCanonicalName() .. " nouns"}
 
	-- Genders
	local is_plural = false
	local g1 = args[1]; if g1 == "" then g1 = nil end
	local g2 = args["g2"]; if g2 == "" then g2 = nil end
 
	g1 = g1 or "?"
 
	if g1 == "morf" or g1 == "mf" or g1 == "c" then
		g1 = "m"
		g2 = "f"
	end
 
	if g2 == "morf" or g2 == "mf" or g2 == "c" then
		error("g2 can't be mf, morf or c!")
	end
 
	local genders = {g1}
 
	if g2 then
		table.insert(genders, g2)
		table.insert(categories, lang:getCanonicalName() .. " nouns with varying gender")
	end
 
	if g1:find("p") or (g2 and g2:find("p")) then
		table.insert(categories, lang:getCanonicalName() .. " pluralia tantum")
		is_plural = true
	end
 
	-- for compatibility with pt-noun
	if (args[2] == "s") then
		args[2] = PAGENAME .. "s"
	elseif (args[2] == "es") then
		args[2] = PAGENAME .. "es"
	end
 
	local inflections = {}
 
	if not is_plural then
		local par2 = args[2]; if par2 == "" then par2 = nil end
		local parpl = args["pl"]; if parpl == "" then parpl = nil end
		local unc = args["unc"] ~= nil
 
		if not par2 then
			par2 = parpl
		end
 
		if par2 == "-" then
			table.insert(inflections, {label = "uncountable"})
		elseif par2 == "?" then
			table.insert(inflections, please_add("plural", categories))
		else
			if unc then
				table.insert(inflections, {label = "usually uncountable"})
			end
 
			local plurals = {label = "plural", accel = "plural-form-of"}
 
			if not par2 then
				par2 = m_plural.get_plural(PAGENAME)
			end
 
			if par2 then
				table.insert(plurals, par2)
 
				local parpl2 = args["pl2"]; if parpl2 == "" then parpl2 = nil end
				local parpl3 = args["pl3"]; if parpl3 == "" then parpl3 = nil end
 
				if parpl2 then
					table.insert(categories, lang:getCanonicalName() .. " terms with multiple plurals")
					table.insert(plurals, parpl2)
				end
 
				if parpl3 then
					table.insert(categories, lang:getCanonicalName() .. " terms with multiple plurals")
					table.insert(plurals, parpl3)
				end
 
				table.insert(inflections, plurals)
			else
				table.insert(inflections, please_add("plural", categories))
			end
		end
	end
 
	local parf = args["f"]; if parf == "" then parf = nil end
	local parf2 = args["f2"]; if parf2 == "" then parf2 = nil end
	local parfpl = args["fpl"]; if parfpl == "" then parfpl = nil end
	local parfpl2 = args["fpl2"]; if parfpl2 == "" then parfpl2 = nil end
 
	local feminines = {label = "feminine"}
	local feminine_plurals = {label = "feminine plural"}
 
	if parf then
		table.insert(feminines, parf)
 
		if not is_plural then
			if not parfpl then
				parfpl = m_plural.get_plural(parf)
			end
 
			table.insert(feminine_plurals, parfpl)
		end
 
		if parf2 then
			table.insert(feminines, parf2)
 
			if not is_plural then
				if not parfpl2 then
					parfpl2 = m_plural.get_plural(parf2)
				end
 
				table.insert(feminine_plurals, parfpl)
			end
		end
 
		table.insert(inflections, feminines)
 
		if not is_plural then
			table.insert(inflections, feminine_plurals)
		end
	end
 
	if args["qual_g1"] or args["qual_g2"] or args["qual_pl"] or args["qual_pl2"] or args["qual_pl3"] or args["qual_f"] or args["qual_fpl"] or args["qual_f2"] or args["qual_fpl2"] then
		require("Module:debug").track("gl-noun with qualifier")
	end
 
	return require("Module:headword").full_headword(lang, nil, head, nil, genders, inflections, categories, nil)
end
 
 
function please_add(text, categories)
	table.insert(categories, lang:getCanonicalName() .. " nouns needing inflection")
	return "<sup><small><span style='color:#AAAAAA;'>please add " .. text .. "</span></small></sup>"
end
 
return export