Module:Wikidata: Difference between revisions

Content deleted Content added
Partial revert: those functions take an entity ID, not a language
m update comment too
 
(4 intermediate revisions by 3 users not shown)
Line 1:
-- vim: set noexpandtab ft=lua ts=4 sw=4:
require('Module:No globalsstrict')
 
local p = {}
Line 504:
local id = frame.args[2]
-- return description of a Wikidata entity in the given language or the default language of this Wikipedia site
return mw.wikibase.getEntity(id).descriptions[:getDescription(langcode or wiki.langcode].value)
end
 
Line 511:
local id = frame.args[2]
-- return label of a Wikidata entity in the given language or the default language of this Wikipedia site
return mw.wikibase.getEntity(id).labels[:getLabel(langcode or wiki.langcode].value)
end
 
Line 606:
local qnumber = "Q" .. value.datavalue.value["numeric-id"]
if (mw.wikibase.getSitelink(qnumber)) then
return "[[" .. mw.wikibase.sitelinkgetSitelink(qnumber) .. "]]"
else
return "[[:d:" .. qnumber .. "|" ..qnumber .. "]]<abbr title='" .. i18n["errors"]["local-article-not-found"] .. "'>[*]</abbr>"
Line 740:
 
-- This is used to get the TA98 (Terminologia Anatomica first edition 1998) values like 'A01.1.00.005' (property P1323)
-- which are then linked to httphttps://wwwifaa.unifr.ch/ifaa/Public/EntryPage/TA98%20Tree/Entity%20TA98%20EN/01.1.00.005%20Entity%20TA98%20EN.htm
-- uses the newer mw.wikibase calls instead of directly using the snaks
-- formatPropertyValues returns a table with the P1323 values concatenated with ", " so we have to split them out into a table in order to construct the return string
Line 752:
t = mw.text.split( v, ", ")
for k2, v2 in pairs(t) do
out[#out + 1] = "[httphttps://wwwifaa.unifr.ch/ifaa/Public/EntryPage/TA98%20Tree/Entity%20TA98%20EN/" .. string.sub(v2, 2) .. "%20Entity%20TA98%20EN.htm " .. v2 .. "]"
end
end