Jump to content

Module:person

From Wiktionary, the free dictionary


local export = {}

function export.main(frame)
	local args = frame:getParent().args
	local QID = args[1]
	local person = args[2] or mw.wikibase.getLabel(QID)
	local wikilink = mw.wikibase.sitelink(QID, 'enwiki')

	local link = person
	if wikilink then
		link = "[[w:" .. wikilink .. "|" .. person .. "]]"
	end

	local person_info = mw.wikibase.getDescription(QID)
	if person_info then
		-- Adapted from [[Module:coinage]]
		person_info = mw.ustring.gsub(person_info, " %([%d-–]+%)$", "")
		person_info = string.gsub(person_info, ";.+$", "")
		
		if args.brackets then
			return link .. " (" .. person_info .. ")"
		else
			return person_info .. " " .. link
		end
	else
		return link
	end
end

return export