ret = mw.getCurrentFrame:expandTemplate{title = "ubl", args = out}
else
ret = out[1]
end  
return ret
end  
---
-- getAllLabels fetches the set of labels and formats it for display as wikitext.
-- It takes a parameter 'qid' for arbitrary access, otherwise it uses the current page.
---
-- Dependencies:
---
p.getAllLabels = function
local args = .args or :getParent.args or {}  
local qid = args.qid or ""
if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage end
if not qid or not mw.wikibase.entityExists(qid) then return i18n["entity-not-found"] end  
local labels = mw.wikibase.getEntity(qid).labels
if not labels then return i18n["labels-not-found"] end  
local out = {}
for k, v in pairs(labels) do
out[#out+1] = v.value .. " (" .. v.language .. ")"
end  
return table.concat(out, "; ")
end  
---
-- getAllDescriptions fetches the set of descriptions and formats it for display as wikitext.
-- It takes a parameter 'qid' for arbitrary access, otherwise it uses the current page.
---
-- Dependencies:
---
p.getAllDescriptions = function
local args = .args or :getParent.args or {}  
local qid = args.qid or ""
if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage end
if not qid or not mw.wikibase.entityExists(qid) then return i18n["entity-not-found"] end  
local descriptions = mw.wikibase.getEntity(qid).descriptions
if not descriptions then return i18n["descriptions-not-found"] end  
local out = {}
for k, v in pairs(descriptions) do
out[#out+1] = v.value .. " (" .. v.language .. ")"
end  
return table.concat(out, "; ")
end  
---
-- getAllAliases fetches the set of aliases and formats it for display as wikitext.
-- It takes a parameter 'qid' for arbitrary access, otherwise it uses the current page.
---
-- Dependencies:
---
p.getAllAliases = function
local args = .args or :getParent.args or {}  
local qid = args.qid or ""
if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage end
if not qid or not mw.wikibase.entityExists(qid) then return i18n["entity-not-found"] end  
local aliases = mw.wikibase.getEntity(qid).aliases
if not aliases then return i18n["aliases-not-found"] end  
local out = {}
for k1, v1 in pairs(aliases) do
local lang = v1[1].language
local val = {}
for k1, v2 in ipairs(v1) do
val[#val+1] = v2.value
end
out[#out+1] = table.concat(val, ", ") .. " (" .. lang .. ")"
end  
return table.concat(out, "; ")
end  
---
-- showNoLinks displays the article titles that should not be linked.
---
-- Dependencies:
---
p.showNoLinks = function
local out = {}
for k, v in pairs(donotlink) do
out[#out+1] = k
end
table.sort( out )
return table.concat(out, "; ")
end  
---
-- checkValidity checks whether the first unnamed parameter represents a valid entity-id,
-- that is, something like Q1235 or P123.
-- It returns the strings "true" or "false".
-- Change false to nil to return "true" or "" (easier to test with #if:).
---
-- Dependencies:
---
function p.checkValidity
local id = mw.text.trim(.args[1] or "")
if mw.wikibase.isValidEntityId(id) then
return true
else
return false
end
end  
---
-- getEntityFromTitle returns the Entity-ID (Q-number) for a given title.
-- Modification of Module:ResolveEntityId
-- The title is the first unnamed parameter.
-- The site parameter determines the site/language for the title. Defaults to current wiki.
-- The showdab parameter determines whether dab pages should return the Q-number or nil. Defaults to true.
-- Returns the Q-number or nil if it does not exist.
---
-- Dependencies: parseParam
---
function p.getEntityFromTitle
local args=.args
if not args[1] then args=:getParent.args end
if not args[1] then return nil end
local title = mw.text.trim(args[1])
local site = args.site or ""
local showdab = parseParam(args.showdab, true)
local qid = mw.wikibase.getEntityIdForTitle(title, site)
if qid then
local prop31 = mw.wikibase.getBestStatements(qid, "P31")[1]
if not showdab and prop31 and prop31.mainsnak.datavalue.value.id == "Q4167410" then
return nil
else
return qid
end
end
end  
---
-- getDatePrecision returns the number representing the precision of the first best date value
-- for the given property.
-- It takes the qid and property ID
-- The meanings are given at https://www.mediawiki.org/wiki/Wikibase/DataModel#Dates_and_times
-- 0 = 1 billion years .. 6 = millennium, 7 = century, 8 = decade, 9 = year, 10 = month, 11 = day
-- Returns 0 (or the second unnamed parameter) if the Wikidata does not exist.
---
-- Dependencies: parseParam; sourced;
---
function p.getDatePrecision
local args=.args
if not args[1] then args=:getParent.args end
local default = tonumber(args[2] or args.default) or 0
local prop = mw.text.trim(args[1] or "")
if prop == "" then return default end
local qid = args.qid or ""
if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage end
if not qid then return default end
local onlysrc = parseParam(args.onlysourced or args.osd, true)
local stat = mw.wikibase.getBestStatements(qid, prop)
for i, v in ipairs(stat) do
local prec = (onlysrc == false or sourced(v))
and v.mainsnak.datavalue
and v.mainsnak.datavalue.value
and v.mainsnak.datavalue.value.precision
if prec then return prec end
end
return default
end  
return p  
---
-- List of exported functions
---
---
_getValue
getValue
getPreferredValue
getCoords
getQualifierValue
getSumOfParts
getValueByQual
getValueByLang
getValueByRefSource
getPropertyIDs
getQualifierIDs
getPropOfProp
getAwardCat
getIntersectCat
getGlobe
getCommonsLink
getSiteLink
getLink
getLabel
label
getAT
getDescription
getAliases
pageId
formatDate
location
checkBlacklist
emptyor
labelorid
getLang
getItemLangCode
findLanguage
getQID
followQid
globalSiteID
siteID
projID
formatNumber
examine
checkvalue
url2
getWebsite
getAllLabels
getAllDescriptions
getAllAliases
showNoLinks
checkValidity
getEntityFromTitle
getDatePrecision
---
---