Definition from Wiktionary, the free dictionary
Jump to: navigation, search
The following documentation is located at Module:fr-headword/documentation. [edit]
Useful links: subpage listtransclusionstestcases

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 = {}
	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 = {}
	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 = {}
	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 unknown
	if mode == "?" then
		table.insert(inflections, "<small><sup>???</sup> please provide the plural!</small>")
		table.insert(categories, "French nouns needing inflection")
	-- Plural is not attested
	elseif 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")
		-- Uncountable noun; may occasionally have a plural
		if 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
					plurals = {PAGENAME}
				elseif mw.ustring.find(PAGENAME,'[ae]u$') then
					plurals = {"x"}
				elseif mw.ustring.find(PAGENAME,'al$') then
					plurals = {mw.ustring.sub(PAGENAME, 1, -3)..'aux'}
					plurals = {"s"}
		if #plurals > 0 then
			-- 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"
			-- Add the plural forms
			plurals.label = "plural"
			plurals.accel = "plural-form-of"
			table.insert(inflections, plurals)
	-- Add the feminine forms
	if #feminines > 0 then
		feminines.label = "feminine"
		table.insert(inflections, feminines)
	-- Add the masculine forms
	if #masculines > 0 then
		masculines.label = "masculine"
		table.insert(inflections, masculines)
return export