模块:WikidataDescription

来自中文乐谱库

此模块的文档可以在模块:WikidataDescription/doc创建

脚本错误:Lua错误:无法创建进程:proc_open(/dev/null): failed to open stream: Operation not permitted

-- Simple wrapper for mw.wikibase.description
local p = {}

function p._fromQID(qid, prefix)
	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)
	return p._fromQID(mw.wikibase.getEntityIdForTitle(frame.args[1]), frame.args[2])
end

return p