Bu modul uchun Modul:EditAtWikidata/doc nomli hujjat sahifasini yaratishingiz mumkin

-- Foydalanish:
-- {{#invoke:EditAtWikidata|showMessage|local_parameter}}
-- {{#invoke:EditAtWikidata|showMessage|qid=<ArticleID>|local_parameter}}

local p = {}

local i18n =
{
	["message"] = "Buni Vikimaʼlumotlarda tahrirlash"
}

local function trimToNil(text)

	if type(text) == 'string' then
		return text:match('(%S.-)%s*$')
	end
end

function p._showMessage(args)
	local local_parm = trimToNil(args[1])
	if local_parm then return "" end
	
	local qid = trimToNil(args.qid) or mw.wikibase.getEntityIdForCurrentPage()
	if qid and mw.wikibase.entityExists(qid) then
	
		local anchor = trimToNil(args.pid)
	
		local space = trimToNil(args.nbsp) and "&nbsp;" or " "
		return
			space ..
			"[[Fayl:OOjs UI icon edit-ltr-progressive.svg|frameless|text-top|10px" ..
			"|alt=" .. i18n.message ..
			"|link=https://www.wikidata.org/wiki/" .. qid ..
			(anchor and ("#" .. anchor) or "") ..
			"|class=noprint" ..
			"|" .. i18n.message ..
			"]]"
	end
	return ""
end

function p.showMessage(frame)
	return p._showMessage(frame.args)
end

return p