Module:Gender and number/basic

< Module:Gender and number
Revision as of 02:05, 10 June 2024 by Maltropia (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Gender and number/basic/doc

local export = {}

--[=[
	This is a simplified version of [[Module:gender and number]] that handles the most common
	cases without loading the full module.
]=]--

function export.format_list(specs, lang, pos_for_cat, sort_key)
	local gender, spec
	if not pos_for_cat and not sort_key and #specs == 1 and type(specs[1]) == "string" then
		spec = specs[1]
		if spec == "m" then
			gender = "masculine"
		elseif spec == "f" then
			gender = "feminine"
		elseif spec == "n" then
			gender = "neuter"
		elseif spec == "c" then
			gender = "common"
		end
	end

	if gender then
		return '<span class="gender"><abbr title="' .. gender .. ' gender">' .. spec .. '</abbr></span>'
	end

	return require("Module:gender and number").format_list(specs, lang, pos_for_cat, sort_key)
end

return export