Changes
Jump to navigation
Jump to search
Line 61:
Line 61:
− +
+
Line 67:
Line 68:
− +
− +
Line 96:
Line 97:
− +
− +
− +
− +
− +
Line 262:
Line 263:
− +
no edit summary
local langList = mw.language.getFallbacksFor(lang)
local langList = mw.language.getFallbacksFor(lang)
table.insert(langList, 1, lang)
table.insert(langList, 1, lang)
-- CAN T GET THE FALLBACKCHAIN TO WORK RIGHT NOW
local langList = {"en"}
-- get label (visible part of the link)
-- get label (visible part of the link)
for _, language in ipairs(langList) do -- loop over language fallback list looking for label in the specific language
for _, language in ipairs(langList) do -- loop over language fallback list looking for label in the specific language
label = entity:getLabel(language)
label = entity:getLabel(language)
else
else
label = mw.wikibase.getLabelByLang("Item:"..item, language)
label = mw.wikibase.getLabelByLang(item, language)
end
end
if label then break end -- label found and we are done
if label then break end -- label found and we are done
end
end
if not label then -- no labels found, so just show the q-code
if not label then -- no labels found, so just show the q-code
label = item..item
label = item
elseif show_id then -- add id
elseif show_id then -- add id
local yesno = require('Module:Yesno')
local yesno = require('Module:Yesno')
-- create URL part of the link
-- create URL part of the link
link_type = string.lower(link_type or '')
link_type = string.lower(link_type or '')
local dLink = 'd:'..item; -- create fallback wikidata link
local dLink = 'Item:'..item; -- create fallback wikidata link
if string.sub(item, 1, 1) == 'P' then
if string.sub(item, 1, 1) == 'P' then
dLink = 'd:Property:'.. item
dLink = 'Property:'.. item
end
end
if link_type=='-' then -- allow different link formats
if link_type=='-' then -- allow different link formats
link = '' -- no link
link = '' -- no link
elseif link_type=='wikidata' then
elseif link_type=='wikidata' then
link = "Item:"..item -- link to wikidata
link = dLink -- link to wikidata
elseif link_type=='wikidata talk' and string.sub(item, 1, 1)=='P' then
elseif link_type=='wikidata talk' and string.sub(item, 1, 1)=='P' then
link = 'd:Property talk:'.. item -- link to wikidata property talk page
link = 'Property talk:'.. item -- link to wikidata property talk page
elseif link_type=='wikidata talk' then
elseif link_type=='wikidata talk' then
link = 'd:Talk:'..item -- link to wikidata talk page
link = 'Talk:'..item -- link to wikidata talk page
elseif link_type=='commons' then
elseif link_type=='commons' then
link = getSitelink(item, entity, 'commons') -- look for sitelink to commons
link = getSitelink(item, entity, 'commons') -- look for sitelink to commons
local entity
local entity
if type(item)=='string' then -- "item" is a q-code
if type(item)=='string' then -- "item" is a q-code
entity = mw.wikibase.getEntity("Item:"..item);
entity = mw.wikibase.getEntity(item);
else
else
entity = item -- "item" is the entity
entity = item -- "item" is the entity