Modul:Wikidata/item
Bu modulun sənədləşdirmə səhifəsi Modul:Wikidata/item/doc səhifəsində yaradıla bilər
local WDS = require( 'Module:WikidataSelectors' );local p = {};local categoryLinksToEntitiesWithMissingLabel = '[[Kateqoriya:Vikipediya:Vikiverilənlərdə Azərbaycan dilinə tərcümə olunmamış elementlər olan məqalələr]]';local function getGenderLabelForEntityId( entityId, isFemale )if not isFemale thenreturn mw.wikibase.getLabelByLang( entityId, 'az' )endlocal entity = mw.wikibase.getEntity( entityId );if not entity.claims or not entity.claims.P2521 thenreturn entity:getLabel();endlocal femLabels = WDS.filterByLanguage( WDS.filterByRank( entity.claims.P2521, 'deprecated', true ), 'az' );if femLabels ~= nil and femLabels[1] and femLabels[1].mainsnak and femLabels[1].mainsnak.datavalue and femLabels[1].mainsnak.datavalue.value and femLabels[1].mainsnak.datavalue.value.text thenreturn femLabels[1].mainsnak.datavalue.value.text;endreturn entity:getLabel();end local function formatOccupationLinkForEntityId( entityId, isFemale )local label = getGenderLabelForEntityId( entityId, isFemale );-- first try to link to occupation article local link = mw.wikibase.sitelink( entityId ) if link and not label then label = link end -- if we don't have article for occupation, try to link to field of occupation if not link then local fooEntity = mw.wikibase.getEntity( entityId ); if fooEntity and fooEntity.claims and fooEntity.claims.P425 then fooEntity = WDS.filterByRank( fooEntity.claims.P425, 'deprecated', true );if fooEntity ~= nil and fooEntity[1] and fooEntity[1].mainsnak and fooEntity[1].mainsnak.datavalue and fooEntity[1].mainsnak.datavalue.value and fooEntity[1].mainsnak.datavalue.value.id thenlink = mw.wikibase.sitelink( fooEntity[1].mainsnak.datavalue.value.id );endendend-- no article about occupation or field, link to wikidata if label and not link then return '<span class="plainlinks">' .. label .. '</span><sup>[[:d:' .. entityId .. '|[d]]]</sup>'end if label and link then return '[[' .. link .. '|' .. label .. ']]' end if not link and not label then return nil endendfunction 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 isFemale = options.entity.claims.P21 and options.entity.claims.P21[1] and options.entity.claims.P21[1].mainsnak and options.entity.claims.P21[1].mainsnak.datavalue and options.entity.claims.P21[1].mainsnak.datavalue.value and options.entity.claims.P21[1].mainsnak.datavalue.value.id == 'Q6581072'local snak = statement.mainsnak;if snak and snak.datavalue and snak.datavalue.value and snak.datavalue.value.id thenlocal entityId = snak.datavalue.value.id;return formatOccupationLinkForEntityId( entityId, isFemale );endreturn context.formatSnak( options, snak )endfunction p.applyDefaultTemplate( context, options, statement )local snak = context.formatSnak( options, statement.mainsnak ) if ( statement.qualifiers and statement.qualifiers.P249 and statement.qualifiers.P249[1].snaktype == 'value') then entityId = statement.mainsnak.datavalue.value.idwbStatus, entity = pcall( mw.wikibase.getEntity, entityId );if ( entity.claims and entity.claims.P1424 ) thenwbStatus, template = pcall( mw.wikibase.getEntity, entity.claims.P1424[1].mainsnak.datavalue.value.id )snak = g_frame:preprocess( string.gsub( template:getSitelink( ), 'Şablon:', '{{' ) .. '|' .. statement.qualifiers.P249[1].datavalue.value .. '}}' )elsereturn nilend end--Referencesif ( options.references and snak ) then snak = snak .. context.formatRefs( options, statement ); end return snakendfunction p.formatCategoryOnly( context, options, value )return context.extractCategory( options, value )end return p
🔥 Top keywords: Hadi RəcəbliNaftalanMəhəmməd FüzuliAna səhifəAytən SəfərovaGöygöl (göl)PlanetXarıbülbülAzərbaycanXüsusi:AxtarAbbasqulu ağa BakıxanovGöygölGünəş sistemiQız qalasıMaşın öyrənməsiGöyçə gölüAvtomobilin tarixiXüsusi:SonDəyişikliklərNurlana Əliyeva (filoloq, 1946)BağlayıcıAzərbaycan əlifbasıTəbii fəlakətHeydər ƏliyevXarıbülbül (simvol)Əkinçi (qəzet)Aprel döyüşləriUlduzAyZərf (qrammatika)Köməkçi nitq hissələriFacebookNizami Gəncəviİkinci Qarabağ müharibəsiAzərbaycandakı ən yüksək dağ zirvələriTəyyarəBakıQərbi AzərbaycanFeilƏdat