Module:Labels

local p = {} local fb = require('Module:Fallback')

local function getLabelImpl(id, lang) local entity = mw.wikibase.getEntityObject(id) if entity then local label = entity:getLabel(lang) if label then return label end

for i, j in pairs (mw.language.getFallbacksFor(lang)) do           label = entity:getLabel(j) if label then return label end end end

return id end

function p.linkify(frame) local args = frame.args return p._linkify(args) end function p._linkify(args) local ids = mw.text.split(args.entities:gsub(" ", ""), ",") local lang = args.lang

local labels = {} for i = 1, #ids do       labels[i] = "" .. getLabelImpl(ids[i], lang) .. " (" .. ids[i] .. ") " end

return table.concat(labels, ", ") end

return p