Content deleted Content added
ensure f is always a string |
m update comment too |
||
(7 intermediate revisions by 5 users not shown) | |||
Line 1:
-- vim: set noexpandtab ft=lua ts=4 sw=4:
require('
local p = {}
Line 80:
}
if wiki.langcode ~= "en" then
--require("Module:i18n").loadI18n("Module:Wikidata/i18n", i18n)
-- got idea from [[:w:Module:Wd]]
local module_title; if ... == nil then▼
local module_title;
module_title = mw.getCurrentFrame():getTitle()
else
end
require('Module:i18n').loadI18n(module_title..'/i18n', i18n)▼
end
▲require('Module:i18n').loadI18n(module_title..'/i18n', i18n)
-- this function needs to be internationalised along with the above:
Line 319 ⟶ 321:
if parameter then
if parameter == "link" then
local linkTarget = mw.wikibase.
local linkName = mw.wikibase.
if linkTarget then
-- if there is a local Wikipedia article link to it using the label or the article title
Line 332 ⟶ 334:
end
else
return mw.wikibase.
end
end
Line 424 ⟶ 426:
if refparts then refparts = refparts .. ", " else refparts = "" end
-- output the label of the property of the reference part, e.g. "imported from" for P143
refparts = refparts .. tostring(mw.wikibase.
-- output all values of this reference part, e.g. "German Wikipedia" and "English Wikipedia" if the referenced claim was imported from both sites
for snakidx = 1, #snakval do
Line 444 ⟶ 446:
return false, input_parm, nil, nil
end
local entity = mw.wikibase.
local claims
if entity and entity.claims then
Line 469 ⟶ 471:
for k, v in pairs(claims) do
local qnumber = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
local sitelink = mw.wikibase.
local label = labelHook(qnumber) or mw.wikibase.
if sitelink then
out[#out + 1] = "[[" .. sitelink .. "|" .. label .. "]]"
Line 502 ⟶ 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.
end
Line 509 ⟶ 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.
end
Line 582 ⟶ 584:
local input_parm = mw.text.trim(frame.args[3] or "")
if input_parm == "FETCH_WIKIDATA" then
local entity = mw.wikibase.
if entity.claims[propertyID] ~= nil then
local out = {}
Line 603 ⟶ 605:
local function outputValue(value)
local qnumber = "Q" .. value.datavalue.value["numeric-id"]
if (mw.wikibase.
return "[[" .. mw.wikibase.
else
return "[[:d:" .. qnumber .. "|" ..qnumber .. "]]<abbr title='" .. i18n["errors"]["local-article-not-found"] .. "'>[*]</abbr>"
Line 662 ⟶ 664:
local function outputHook(value)
if value.datavalue.value["numeric-id"] then
return mw.wikibase.
else
return value.datavalue.value
Line 738 ⟶ 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
-- 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
p.getTAValue = function(frame)
local ent = mw.wikibase.
local props = ent:formatPropertyValues('P1323')
local out = {}
Line 750 ⟶ 752:
t = mw.text.split( v, ", ")
for k2, v2 in pairs(t) do
out[#out + 1] = "[
end
end
Line 796 ⟶ 798:
local input_parm = mw.text.trim(frame.args[1] or "")
if input_parm == "FETCH_WIKIDATA" then
local ent = mw.wikibase.
local imgs
if ent and ent.claims then
Line 861 ⟶ 863:
-- returns the page id (Q...) of the current page or nothing of the page is not connected to Wikidata
function p.pageId(frame)
end
Line 877 ⟶ 878:
-- get wikidata entity
local entity = mw.wikibase.
if not entity then
if showerrors then return printError("entity-not-found") else return default end
Line 934 ⟶ 935:
id = nil
end
local data = mw.wikibase.
if not data then
return nil
Line 978 ⟶ 979:
function p.Dump(frame)
local f = (frame.args[1] or frame.args.id) and frame or frame:getParent()
local data = mw.wikibase.
if not data then
return i18n.warnDump
|