local export = {}function export.show(frame)local country = frame.args[1] or ""local id = frame:expandTemplate{title = "Vikidatumoj-identigilo", args = {country:lower():gsub("-", " "):gsub("_", " ")}}local year = frame.args[2] or ""local name = frame.args[3] or ""local size = frame.args[4] or "20px"local flag = "Flag.svg" if size == "" then size = "20px"endif id == "" thenif name == "" thenreturn "[[Dosiero:Flag.svg|border|" .. size .. "|" .. country .. "|ligilo=]]"elsereturn "[[Dosiero:Flag.svg|border|" .. size .. "|" .. country .. "|ligilo=]] [[" .. country .. "]]"endelselocal link = mw.wikibase.sitelink(id)local label = mw.wikibase.label(id)local lucky, Wikidata = pcall( require, "Module:Wikidata" )if year ~= "" then--flag = frame:preprocess("{{#invoke:Wikidata|claim|P41|id=" .. id .. "|atdate=" .. year .. "}}")flag = Wikidata.claim( { args = { [ 1 ] = "P41", id = id, atdate = year } } )endif flag == "Flag.svg" then--flag = frame:preprocess("{{#invoke:Wikidata|claim|P41|id=" .. id .. "}}")-- flag = Wikidata.claim( { args = { [ 1 ] = "P41", -- id = id } } ) -- flag = mw.wikibase.getBestStatements(id, "P41")[1]["mainsnak"]["datavalue"]["value"] local flagTable = mw.wikibase.getBestStatements(id, "P41") if #flagTable == 1 and flagTable[1]["mainsnak"]["datavalue"] ~= nil then flag = flagTable[1]["mainsnak"]["datavalue"]["value"] -- aldono por ne internacie agnoskita lando, kies Vikidatuma ero ne enhavas flagon elseif country == "Abĥazio" then local c = mw.ustring.lower(country) local bildeto = frame:preprocess('{{#invoke:Portalo|image|' .. c .. '}}') if bildeto ~= nil and bildeto ~= "" then flag = bildeto end endendif label ~= nil and link ~= nil and flag ~= nil thenif name == "" thenreturn "[[Dosiero:" .. flag .. "|border|" .. size .. "|" .. label .. "|ligilo=" .. link .. "]]"elsereturn "[[Dosiero:" .. flag .. "|border|" .. size .. "|" .. label .. "|ligilo=" .. link .. "]] [[" .. link .. "|" .. label .. "]]"endendendendreturn export