Module:Endangered Languages Project: Difference between revisions
Appearance
Content deleted Content added
rm pseudo-reference per Template_talk:Infobox_language#ELP_and_Glottopedia_links |
reworked module to fix error and simplify |
||
Line 1: | Line 1: | ||
--[[ |
|||
Module:Endangered Languages Project |
|||
--]] |
|||
local p = {} |
local p = {} |
||
local elpf = "http://www.endangeredlanguages.com/lang/" -- or get P1630 |
local elpf = "http://www.endangeredlanguages.com/lang/" -- or get P1630 |
||
⚫ | |||
⚫ | |||
⚫ | |||
local tidy_param = function(param) |
local tidy_param = function(param) |
||
Line 17: | Line 9: | ||
p.make_entry = function(frame) |
p.make_entry = function(frame) |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
local elpname = tidy_param(frame.args.elpname) |
local elpname = tidy_param(frame.args.elpname) |
||
local elpcode = tidy_param(frame.args.elpcode) |
local elpcode = tidy_param(frame.args.elpcode) |
||
local qid = tidy_param((frame.args.qid or ""):upper()) or mw.wikibase.getEntityIdForCurrentPage() |
local qid = tidy_param((frame.args.qid or ""):upper()) or mw.wikibase.getEntityIdForCurrentPage() |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
if elpcode and elpname then |
|||
⚫ | |||
⚫ | |||
⚫ | |||
else |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
|||
end |
|||
⚫ | |||
⚫ | |||
⚫ | |||
else |
|||
if elpcode or elpname then |
|||
return (elpcode or "") .. (elpname or "") .. "[[Category:Language articles with missing ELP parameters]]" |
|||
end |
end |
||
end |
end |
||
end |
end |
||
local ret = "" |
local ret = "" |
||
if #out > 1 then |
if #out > 1 then |
||
return frame:expandTemplate{title = "ubl", args = out} |
|||
elseif #out==1 then |
|||
else |
|||
return out[1] |
|||
end |
end |
||
return ret |
|||
end |
end |
||
Revision as of 10:19, 6 March 2024
local p = {}
local elpf = "http://www.endangeredlanguages.com/lang/" -- or get P1630
local tidy_param = function(param)
if param == "" then param = nil end
return param
end
p.make_entry = function(frame)
local out = {}
local make_display = function(elpc, elpn)
if elpc and elpn then
table.insert(out, "[" .. elpf .. elpc .. " " .. elpn .. "]")
elseif elpc or elpn then
table.insert(out, (elpc or "") .. (elpn or "") .. "[[Category:Language articles with missing ELP parameters]]")
end
end
local elpname = tidy_param(frame.args.elpname)
local elpcode = tidy_param(frame.args.elpcode)
local qid = tidy_param((frame.args.qid or ""):upper()) or mw.wikibase.getEntityIdForCurrentPage()
make_display(elpcode, elpname)
if qid then
local props = mw.wikibase.getBestStatements(qid, "P2192")
if props[1] then
for _, v in ipairs(props) do
local elpc = v.mainsnak.datavalue and v.mainsnak.datavalue.value
local elpn = v.qualifiers and v.qualifiers.P1810 and v.qualifiers.P1810[1].datavalue and v.qualifiers.P1810[1].datavalue.value
make_display(elpc, elpn)
end
end
end
local ret = ""
if #out > 1 then
return frame:expandTemplate{title = "ubl", args = out}
elseif #out==1 then
return out[1]
end
end
return p