模块:沙盒/1F616EMO/wikidataOP

维基百科,自由的百科全书
跳转到导航 跳转到搜索
local p = {}

function p._getLocalLinkFor(foreign_wiki, foreign_title, display_title)
	local entityID = mw.wikibase.getEntityIdForTitle(foreign_title, foreign_wiki)
	local entity = entityID and mw.wikibase.getEntity(entityID)
	local local_sitelink = entity and entity:getSitelink() or foreign_title

	return "[[" .. local_sitelink .. (local_sitelink == display_title and "" or ("|" .. display_title)) .. "]]"
end

function p.getLocalLinkFor(frame)
	local foreign_wiki = frame.args[1]
	local foreign_title = frame.args[2]
	local display_title = frame.args[3] or foreign_title

	return p._getLocalLinkFor(foreign_wiki, foreign_title, display_title)
end

return p