Module:Wd: Difference between revisions

Content deleted Content added
No edit summary
Undid revision 751878779 by Thayts (talk)
Line 133:
end
 
function State:convertUnit(unit, linkaddLink)
linkaddLink = linkaddLink or false
local itemID, label, target
Line 150:
target = nil
if linkaddLink or label == nil then
target = mw.wikibase.sitelink(itemID)
end
if linkaddLink then
if target then
return " " .. "[[" .. target .. "|" .. (label or target) .. "]]"
Line 193:
end
 
function State:getValue(snak, rawaddUnit, linkaddLink)
rawaddUnit = rawaddUnit or false
linkaddLink = linkaddLink or false
if snak.snaktype == 'value' then
Line 210:
local value = mw.ustring.gsub(snak.datavalue.value['amount'], "^\+(.+)$", "%1")
if not rawaddUnit then
local unit = self:convertUnit(snak.datavalue.value['unit'], linkaddLink)
if unit then
value = value .. unit
Line 255:
yRound = math.ceil(yDiv)
if not rawaddUnit then
if precision == 6 then
suffix = " millennium"
Line 264:
suffix = self:getOrdinalSuffix(yRound) .. suffix
else
-- if notno verboseunit added, 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 not rawaddUnit then
suffix = "s"
end
end
if rawnot addUnit 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 not rawaddUnit then
if precision == 3 then
suffix = " million years"
Line 364:
if calendarID and calendarID == aliasesQ.prolepticJulianCalendar then
if not rawaddUnit then
if linkaddLink then
calendar = " ([[Julian calendar|Julian]])"
else
Line 376:
end
if not rawaddUnit then
local ce = nil
Line 386:
if ce then
if linkaddLink then
ce = "[[Common Era|" .. ce .. "]]"
end
Line 430:
local partsGlue = ", "
if rawnot addUnit then
degSymbol = "/"
minSymbol = "/"
Line 492:
value = latValue .. partsGlue .. lonValue
if linkaddLink 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 not rawself.shortName then
value = self:getShortName(itemID)
local target = nil
end
local itemID = "Q" .. snak.datavalue.value['numeric-id']
if self.shortNamevalue == "" then
value = self:getShortNamemw.wikibase.label(itemID)
end
if addLink or value == ""nil then
valuetarget = mw.wikibase.labelsitelink(itemID)
end
if link or value == niladdLink then
if target then
target = mw.wikibase.sitelink(itemID)
value = "[[" .. target .. "|" .. (value or target) .. "]]"
end
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 = (target"[[:d:" or.. itemID) .. "|" .. itemID .. "]]"
end
elseif not value then
else
value = "Q"(target ..or snak.datavalue.value['numeric-id']itemID)
end
Line 552 ⟶ 547:
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'