Module:Wd: Difference between revisions

Content deleted Content added
mNo edit summary
No edit summary
Line 133:
end
 
function State:convertUnit(unit, addLinklink)
addLinklink = addLinklink or false
local itemID, label, target
Line 150:
target = nil
if addLinklink or label == nil then
target = mw.wikibase.sitelink(itemID)
end
if addLinklink then
if target then
return " " .. "[[" .. target .. "|" .. (label or target) .. "]]"
Line 193:
end
 
function State:getValue(snak, addUnitraw, addLinklink)
addUnitraw = addUnitraw or false
addLinklink = addLinklink or false
if snak.snaktype == 'value' then
Line 210:
local value = mw.ustring.gsub(snak.datavalue.value['amount'], "^\+(.+)$", "%1")
if addUnitnot raw then
local unit = self:convertUnit(snak.datavalue.value['unit'], addLinklink)
if unit then
value = value .. unit
Line 255:
yRound = math.ceil(yDiv)
if addUnitnot raw then
if precision == 6 then
suffix = " millennium"
Line 264:
suffix = self:getOrdinalSuffix(yRound) .. suffix
else
-- if nonot unit addedverbose, take the first year of the century/millennium
-- (e.g. 1901 for 20th century or 2001 for 3rd millennium)
yRound = (yRound - 1) * yFactor + 1
Line 273:
yRound = math.floor(yDiv) * yFactor
if addUnitnot raw then
suffix = "s"
end
end
if not addUnitraw and sign < 0 then
-- if BCE then compensate for "counting backwards"
-- (e.g. -2019 for 2010s BCE, -2000 for 20th century BCE or -3000 for 3rd millennium BCE)
Line 338:
end
if addUnitnot raw then
if precision == 3 then
suffix = " million years"
Line 364:
if calendarID and calendarID == aliasesQ.prolepticJulianCalendar then
if addUnitnot raw then
if addLinklink then
calendar = " ([[Julian calendar|Julian]])"
else
Line 376:
end
if addUnitnot raw then
local ce = nil
Line 386:
if ce then
if addLinklink then
ce = "[[Common Era|" .. ce .. "]]"
end
Line 430:
local partsGlue = ", "
if not addUnitraw then
degSymbol = "/"
minSymbol = "/"
Line 492:
value = latValue .. partsGlue .. lonValue
if addLinklink then
globe = self:parseWikidataURL(snak.datavalue.value['globe'])
Line 507:
elseif snak.datavalue.type == 'wikibase-entityid' then
local value = ""
local target = nil
local itemID = "Q" .. snak.datavalue.value['numeric-id']
if self.shortNamenot raw then
local target = nil
value = self:getShortName(itemID)
local itemID = "Q" .. snak.datavalue.value['numeric-id']
end
if value == ""self.shortName then
value = mw.wikibase.labelself:getShortName(itemID)
end
if addLink or value == nil"" then
target value = mw.wikibase.sitelinklabel(itemID)
end
if addLinklink or value == nil then
if target then= mw.wikibase.sitelink(itemID)
end
value = "[[" .. target .. "|" .. (value or target) .. "]]"
if link then
if target then
value = "[[" .. target .. "|" .. (value or target) .. "]]"
elseif not value then
value = "[[:d:" .. itemID .. "|" .. itemID .. "]]"
end
elseif not value then
value = "[[:d:"(target ..or itemID .. "|" .. itemID .. "]]")
end
else
elseif not value then
value = (target"Q" or.. itemID)snak.datavalue.value['numeric-id']
end
Line 547 ⟶ 552:
function State:getRawValue(snak)
if snak.snaktype == 'value' and snak.datavalue.type == 'wikibase-entityid' then
 
return "Q" .. snak.datavalue.value['numeric-id']
elseif snak.snaktype == 'somevalue' then
return " " -- single space represents 'somevalue'