For faster navigation, this Iframe is preloading the Wikiwand page for Модуль:Wikidata/item.

Модуль:Wikidata/item

ХӀокху модулах лаьцна хааман Модуль:Wikidata/item/doc агӀо кхолла мега

local WDS = require( 'Module:WikidataSelectors' );
local p = {};

local categoryLinksToEntitiesWithMissingLabel = '[[Категори:Википеди:Викихаамаш чохь элементаш тӀе нохчийн куьг доцу хьажоргаш йолу йаззамаш]]';

local function getGenderLabelForEntityId( entityId, isFemale )
	if not isFemale then
		return mw.wikibase.label( entityId );
	end
	
	local entity = mw.wikibase.getEntity( entityId );
	
	if not entity.claims or not entity.claims.P2521 then
		return entity:getLabel();
	end
	
	local femLabels = WDS.filterByLanguage( WDS.filterByRank( entity.claims.P2521, 'deprecated', true ), 'ce' );
	
	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 then
		return femLabels[1].mainsnak.datavalue.value.text;
	end

	return 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 then
				link = mw.wikibase.sitelink( fooEntity[1].mainsnak.datavalue.value.id );
			end
		end
	end

	-- no article about occupation or field, link to wikidata
    if not link then
	    link = ':d:' .. entityId
	end

    if label then
        return '[[' .. link .. '|' .. label .. ']]'
    end
    
    -- сообщение об отсутвии локализованного названия
    -- not good, but better than nothing
    return '[[' .. link .. '|' .. entityId .. ']]<span style="border-bottom: 1px dotted; cursor: help; white-space: nowrap" title="Викихаамашкахь элементан нохчийн куьг дац. Хьуна гӀода лур ду иза яздина.">?</span>' .. categoryLinksToEntitiesWithMissingLabel;
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 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 then
		local entityId = snak.datavalue.value.id;
		local value = formatOccupationLinkForEntityId( entityId, isFemale )
		return context.wrapSnak( value, snak.hash )
	end
	
	return context.formatSnak( options, snak )
end

function p.applyDefaultTemplate( context, options, statement )
	local snak = context.formatSnak( options, statement.mainsnak )
    if ( statement.qualifiers and statement.qualifiers.P249) then
    	snak = statement.qualifiers.P249[1].datavalue.value
    	entityId = statement.mainsnak.datavalue.value.id
		wbStatus, entity = pcall( mw.wikibase.getEntity, entityId );
		if ( entity.claims and entity.claims.P1424 ) then
			wbStatus, template = pcall( mw.wikibase.getEntity, 
				entity.claims.P1424[1].mainsnak.datavalue.value.id )
			if template:getSitelink( ) then
				snak = g_frame:preprocess( string.gsub( template:getSitelink( ), 
					'Кеп:', '((' ) .. '|' .. 
					statement.qualifiers.P249[1].datavalue.value .. '))' )
			end
		end
    end

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

    return snak
end

function p.formatCategoryOnly( context, options, value )
	return context.extractCategory( options, value )
end
 
return p
{{bottomLinkPreText}} {{bottomLinkText}}
Модуль:Wikidata/item
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?