Module:Sandbox/Xinbenlv/WikiLoop

-- Module:WikiLoop local p = {} local supported_languages = {'ru', 'fr', 'en'}

-- Returns the conflict table local function parseConflictValueObject(frame) local qid = frame.args.qid -- Qnum id    local conflict_value_object = {} -- out = '' for i, lang in ipairs(supported_languages) do       local prefix = "lang_" .. lang if frame.args["lang_" .. lang] ~= nil then local site_link = mw.wikibase.getSitelink(qid, lang.."wiki") local value = frame.args[prefix] conflict_value_object[lang] = { ["value"] = value, ["site_link"] = site_link }       end end return conflict_value_object end

local function conflictValueObjectToTableData(conflict_value_object) local headers = {"language", "title", "value"} local rows = {} for lang, value_pair in pairs(conflict_value_object) do       table.insert(rows ,{            lang, -- language            ""..lang..":"..value_pair.site_link.."", -- link to value            value_pair.value        }) end return {headers, rows} end

local function printTableHtml(table_data) local column_headers = table_data[1] local rows = table_data[2]

local output = " \n" return output end

function p.PrintConflictTable(frame) conflict_value_object = parseConflictValueObject(frame) table_data = conflictValueObjectToTableData(conflict_value_object) return printTableHtml(table_data) end

return p