انتقل إلى المحتوى

وحدة:Wikidata/item/ملعب2

من ويكيبيديا، الموسوعة الحرة
local WDS = require('Module:WikidataSelectors')

local p = {}

local categoryLinksToEntitiesWithMissingLabel = '[[تصنيف:صفحات بها مهن بحاجة للتأنيث]]'; 

local function getGenderLabelForEntityId( entityId, map )

if not map then return 'No image.svg' end

local entity = mw.wikibase.getEntity( entityId );

if not entity.claims['P18'] then return 'No image.svg' end

local femLabels = entity.claims['P18'];

if femLabels ~= nil and

  femLabels[1] and

  femLabels[1].mainsnak and

  femLabels[1].mainsnak.datavalue and

  femLabels[1].mainsnak.datavalue.value then

return femLabels[1].mainsnak.datavalue.value;

end

return  entity:getLabel();	

end

   

local function formatGenderLabelForEntityId( entityId, map )

local la = getGenderLabelForEntityId( entityId, map );

-- получение ссылки по идентификатору
    local label = mw.wikibase.label( entityId );
    local link = mw.wikibase.sitelink( entityId );
    local doo = '[[File:' .. la .. '|40x30px|border]]';    

	if label then
        if link then
            return doo ..'[[' .. link .. '|' .. label .. ']]'
        else
            return doo ..'' .. label .. ''
         end 
   else return nil
end
    
end

function p.formatEntityWithGenderClaim( context, options, statement )

if ( not context ) then error( 'context not specified'); end;

if ( not options ) then error( 'options not specified'); end;

if ( not options.entity ) then error( 'options.entity is missing'); end;

if ( not statement ) then error( 'statement not specified'); end;

local map = options.entity.claims['P31']

local snak = statement.mainsnak;

if snak and snak.datavalue and snak.datavalue.value and snak.datavalue.value['numeric-id'] then

local entityId = 'Q' .. snak.datavalue.value['numeric-id'];

return formatGenderLabelForEntityId( entityId, map );

end
--References
	if ( options.references ) then
    	snak = snak .. context.formatRefs( options, statement );
    end
return context.formatSnak( options, snak )

end

 

return p