local p = {}
local i18n = 
	{
		["noentity"] = "[[category:صفحات دون عنصر ويكي بيانات]]",
		["nolabel"] = "[[category:صفحات بحاجة لتسمية في ويكي بيانات]]"
	}
	
function findlabelold(entity)
	if entity
	and entity.labels 
	and entity.labels['ar']
	and entity.labels['ar'].value 
	then
		local lang = entity.labels['ar']
		if lang['language'] == 'ar'
		then
			return ''
		else 
			return i18n.nolabel
		end
	end
end

function findlabel(id)
	local label = mw.wikibase.getLabelByLang( id , 'ar' ) or ''
	if label ~= '' then return '' end
	return i18n.nolabel
end

function p.find(frame)
	if not mw.wikibase then return '' end
	--local entity = mw.wikibase.getEntityObject()
	local EntityId = mw.wikibase.getEntityIdForCurrentPage()
	local er = i18n.noentity
	if frame.args[1] ~= nil then er = frame.args[1] end
	if EntityId then
		return findlabel(EntityId)
	else
	-- This is the place to insert a category for articles that don't have items in Wikidata.
	-- enwiki doesn't seem to have such a category, so in this case it is empty.
	-- For other wikis, just remove the two comment dashes and insert the correct category name.
		return er
	end
end

return p