--
local p =
-- This piece of html implements a collapsible container. Check the classes exist on your wiki.local collapsediv = '
'
-- All results appear as internal links (to avoid archive links)local illook = '
'
local sources = mw.loadData("Module:Sandbox/RexxS/Sources/data")
local function findLang(langcode) local langobj langcode = mw.text.trim(langcode or "") if mw.language.isKnownLanguageTag(langcode) then langobj = mw.language.new(langcode) else langcode = mw.getCurrentFrame:callParserFunction('int',) if mw.language.isKnownLanguageTag(langcode) then langobj = mw.language.new(langcode) else langobj = mw.language.getContentLanguage end end return langobjend
function p.testlist(frame) local out = "" -- output text for langcode, langdata in pairs(sources) do -- just the language codes out = out.."\n
" for idx, src in ipairs(langdata) do out = out.."\n"..src[1].."; WD="..src[2].."; loc="..src[3].."
\n" end out = out.."
\n" end return outend
--function p.demo(frame) local args = frame.args
local qid = args.qid or "" if qid
local langcode = findLang(args.lang).code
local out1 = for idx1, src in ipairs(sources[langcode]) do local statements = mw.wikibase.getBestStatements(qid, src[2]) for idx2, valtbl in ipairs(statements) do if valtbl.mainsnak.datatype
"value" then local idurl = valtbl.mainsnak.datavalue.value:gsub("%%", "%%%%") out1[#out1 + 1] = "[" .. src[3]:gsub("$1", idurl) .. " " .. src[1] .. "]" end end end
local locallang = "" if #out1 > 0 then locallang = illook .. frame:expandTemplate .. "
" end
local out2 = for srclangcode, langdata in pairs(sources) do if srclangcode ~= langcode then for idx1, src in ipairs(langdata) do local statements = mw.wikibase.getBestStatements(qid, src[2]) for idx2, valtbl in ipairs(statements) do if valtbl.mainsnak.datatype
"value" then local idurl = valtbl.mainsnak.datavalue.value:gsub("%%", "%%%%") out2[#out2 + 1] = "[" .. src[3]:gsub("$1", idurl) .. " " .. src[1] .. "]" end end end end end
local otherlang = "" if #out2 > 0 then if #out1 > 0 then otherlang = collapsediv .. frame:expandTemplate .. "
" else otherlang = illook .. frame:expandTemplate .. "
return locallang .. otherlangend
return p