وحدة:Wikidata2/link

يمكن إنشاء صفحة توثيق الوحدة في وحدة:Wikidata2/link/شرح

local p = {}
--local String = require('Module:String').match
function formatcharacters_(label, options)
	local formatc = options.formatcharacters
	--if options.FormatfirstCharacter and options.num == 1 then 
		--formatc = options.FormatfirstCharacter 
	--end
	if options.illwd2y and options.illwd2y ~= '' then
		ca = mw.ustring.match( label, "%d%d%d%d", 1 ) or label
		return ca
	end
	if not formatc or formatc == '' then
		return label
	end
	if formatc == 'lcfirst' then
		return mw.getCurrentFrame():preprocess("{{lcfirst: " .. label .. " }}")
	elseif formatc == 'ucfirst' then
		return mw.language.getContentLanguage():ucfirst( label )
	elseif formatc  == 'lc' then
		return mw.getCurrentFrame():preprocess("{{lc: " .. label .. " }}")
	elseif formatc == 'uc' then
		return mw.getCurrentFrame():preprocess("{{uc: " .. label .. " }}")
	end
	return label
end

function p.year( datavalue, datatype, options )
	local ret = ""
	if datatype == 'wikibase-item' then
        local id = getEntityIdFromValue( datavalue.value )
        local value = formatEntityId( id, options ).value
    	local label = options.label or mw.wikibase.label( id )
		if label == '' then
			label = mw.wikibase.label( id ) or nil
		end
	    local link = mw.wikibase.sitelink( id )
	    if link and (not options.nolink or options.nolink == '') then
	        if label and label ~= '' then
	            ret =  '[[:' .. link .. '|' .. formatcharacters_(label, options) .. ']]'.. catewikidatainfo(options)
	        else
	            ret = '[[:' .. link .. '|' .. formatcharacters_(link, options) .. ']]'.. catewikidatainfo(options) 
	        end
	    else
	    	if label and label ~= ''  then
	    		ret = Labelfunction( id, label,options.label, options) 
	    	end
	    end
	end
	return ret
end

return p