Module:Label

Revision as of 13:29, 13 July 2022 by Bayugoon (talk | contribs) (Simple module for getting an item or property's label)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Label/doc

local p = {}

function p.getLabel(frame)
	local id = frame.args.id;
	local label = mw.wikibase.getLabel(id);
	
	local entity_type = mw.ustring.sub(id, 1, 1)
	
	local link
	
	if entity_type == "Q" then
		link = "Item:"..id
	elseif entity_type == "P" then
		link = "Property:"..id
	else
		link = "Special:EntityData/"..id
	end
	
	return "[["..link.."|"..label.." ".."("..id..")".."]]"
end

return p