模組:WikidataDescription
外观
-- Simple wrapper for mw.wikibase.description
local p = {}
function p._fromQID(qid, prefix)
if qid == nil then
return ''
end
local prefix = prefix or ''
local result, lang = mw.wikibase.getDescriptionWithLang(qid)
-- don't get english fallback results
if result and string.sub(lang,0,2) == 'zh' then
return prefix .. result
else
return ''
end
end
function p.fromQID(frame)
return p._fromQID(frame.args[1], frame.args[2])
end
-- {{#Invoke:WikidataDescription|fromTitle|络丝蛋白}} => "人类大脑糖蛋白"
-- {{#Invoke:WikidataDescription|fromTitle|络丝蛋白|,}} => ",人类大脑糖蛋白"
function p.fromTitle(frame)
local redirect = require('Module:Redirect')
t = frame.args[1]
if redirect.luaIsRedirect(frame.args[1]) then
t = redirect.getTarget(frame.args[1])
end
return p._fromQID(mw.wikibase.getEntityIdForTitle(t), frame.args[2])
end
return p