Module:OfficialName
ظٲہِریَتھ
"یَمہٕ ماڈیوٗلُک دَستاویز ییٚہِ Module:OfficialName/دَستاویز جاے بَناونہٕ"
local p = {}
function p.show(frame)
local qid = frame.args.qid
if not qid or qid == "" then
qid = mw.wikibase.getEntityIdForCurrentPage()
end
if not qid then
return "" -- no Wikidata item
end
-- Get the P1448 statement
local stmt = mw.wikibase.getBestStatements(qid, "P1448")[1]
if not stmt then
return ""
end
-- Official name text
local name = stmt.mainsnak.datavalue.value.text or ""
-- Find language qualifier P407
local langQid = nil
if stmt.qualifiers and stmt.qualifiers.P407 then
langQid = stmt.qualifiers.P407[1].datavalue.value.id
end
-- Get readable language label
local langLabel = ""
if langQid then
langLabel = mw.wikibase.getLabel(langQid) or langQid
end
-- Return formatted output
if langLabel ~= "" then
return name .. " (" .. langLabel .. ")"
else
return name
end
end
return p