Definition from Wiktionary, the free dictionary
Jump to: navigation, search
This module is used for French headword-line templates.

The module is always invoked the same way, by passing a single parameter to the "show" function. This parameter is the name of the part of speech, but in plural (examples given are for nouns, and for adjective forms respectively):

{{#invoke:fr-headword|show|adjective forms}}

The template will, by default, accept the following parameters (specific parts of speech may accept or require others):

  • head= - Override the headword display, used to add links to individual words in a multi-word term.

There is no parameter for the sort key, because this is not necessary. The sort key is automatically generated according to the normal alphabetical ordering in French.

local export = {}
local pos_functions = {}
local lang = require("Module:languages").getByCode("fr")
-- The main entry point.
-- This is the only function that can be invoked from a template.
	local args = frame:getParent().args
	PAGENAME = mw.title.getCurrentTitle().text
	local head = args["head"]; if head == "" then head = nil end
	-- The part of speech. This is also the name of the category that
	-- entries go in. However, the two are separate (the "cat" parameter)
	-- because you sometimes want something to behave as an adjective without
	-- putting it in the adjectives category.
	local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
	local genders = {}
	local inflections = {}
	local categories = {"French " .. poscat}
	if pos_functions[poscat] then
		pos_functions[poscat](args, genders, inflections, categories)
	return require("Module:headword").full_headword(lang, nil, head, nil, genders, inflections, categories, nil)
pos_functions["nouns"] = function(args, genders, inflections, categories)
	-- Gather genders
	local gender = args[1]; if gender == "" then gender = nil end
	local gender2 = args["g2"]; if gender2 == "" then gender2 = nil end
	if gender == "mf" then
		table.insert(genders, "m")
		table.insert(genders, "f")
		table.insert(genders, gender)
		table.insert(genders, gender2)
	-- Gather all the plural parameters from the numbered parameters.
	local plurals = {label = "plural", accel = "plural-form-of", request = true}
	local p = args[2]; if p == "" then p = nil end
	local i = 3
	while p do
		table.insert(plurals, p)
		p = args[i]; if p == "" then p = nil end
		i = i + 1
	-- Gather all the feminine parameters
	local feminines = {label = "feminine"}
	local p = args["f"]; if p == "" then p = nil end
	local i = 2
	while p do
		table.insert(feminines, p)
		p = args["f" .. i]; if p == "" then p = nil end
		i = i + 1
	-- Gather all the masculine parameters
	local masculines = {label = "masculine"}
	local p = args["m"]; if p == "" then p = nil end
	local i = 2
	while p do
		table.insert(masculines, p)
		p = args["m" .. i]; if p == "" then p = nil end
		i = i + 1
	-- Add categories for genders
	if #genders == 0 then
		table.insert(genders, "?")
	local mode = nil
	for _, g in ipairs(genders) do
		if g == "m-p" or g == "f-p" then
			mode = "p"
		if g == "m" then
			table.insert(categories, "French masculine nouns")
		elseif g == "f" then
			table.insert(categories, "French feminine nouns")
	-- Decide how to show the plurals
	mode = mode or plurals[1]
	-- Plural is not attested
	if mode == "!" then
		table.insert(inflections, {label = "plural not attested"})
		table.insert(categories, "French nouns with unattested plurals")
	-- Plural-only noun, doesn't have a plural
	elseif mode == "p" then
		table.insert(inflections, {label = "plural only"})
		table.insert(categories, "French pluralia tantum")
		-- Plural is unknown
		if mode == "?" then
			table.remove(plurals, 1)  -- Remove the mode parameter
		-- Uncountable noun; may occasionally have a plural
		elseif mode == "-" then
			table.remove(plurals, 1)  -- Remove the mode parameter
			table.insert(categories, "French uncountable nouns")
			-- If plural forms were given explicitly, then show "countable" as well
			if #plurals > 0 then
				table.insert(inflections, {label = "countable or [[Appendix:Glossary#uncountable|uncountable]]"})
				table.insert(categories, "French countable nouns")
				table.insert(inflections, {label = "[[Appendix:Glossary#uncountable|uncountable]]"})
		-- The default, always has a plural
			table.insert(categories, "French countable nouns")
			-- If no plural was given, add a default one now
			if #plurals == 0 then
				if mw.ustring.find(PAGENAME,'s$') then
					table.insert(plurals, PAGENAME)
				elseif mw.ustring.find(PAGENAME,'[ae]u$') then
					table.insert(plurals, "x")
				elseif mw.ustring.find(PAGENAME,'al$') then
					table.insert(plurals, mw.ustring.sub(PAGENAME, 1, -3) .. 'aux')
					table.insert(plurals, "s")
		-- Process the plural forms
		for i, pl in ipairs(plurals) do
			if pl == "s" then
				plurals[i] = PAGENAME .. "s"
			elseif pl == "x" then
				plurals[i] = PAGENAME .. "x"
			if not then
				table.insert(categories, "French nouns with missing plurals")
		-- Add the plural forms
		if mode ~= "-" or #plurals > 0 then
			table.insert(inflections, plurals)
	-- Add the feminine forms
	if #feminines > 0 then
		table.insert(inflections, feminines)
		for _, f in ipairs(feminines) do
			if not then
				table.insert(categories, "French adjectives with missing forms")
	-- Add the masculine forms
	if #masculines > 0 then
		table.insert(inflections, masculines)
		for _, m in ipairs(masculines) do
			if not then
				table.insert(categories, "French adjectives with missing forms")
return export