Module:User:QFQ/listlang

-- This module generates python-readable language-code conversion data

local m_families = mw.loadData("Module:families/data")

local export = {}

function fmt(tb) local l = {} table.insert(l, '{') for k, v in pairs(tb) do table.insert(l, '"' .. k .. '": "' .. v .. '", ') end table.insert(l, '}\n') return table.concat(l) end

function export.show(frame) local args = frame.args local m_languages = mw.loadData("Module:languages/data/all") -- Select language codes to display. local data_tables = {} data_tables = m_languages -- Now go over each code, and create table rows for those that are selected local rows = {} local row_i = 1 local l1, l2, l3 = {}, {}, {} for code, data in require("Module:table").sortedPairs(data_tables) do		local canonicalName = data['canonicalName'] or data[1] l1[code] = canonicalName l2[canonicalName] = code local other = data.otherNames or data.aliases if other then if type(other) == "table" then for _, nm in ipairs(other) do					l2[nm] = code end else l2[other] = code end end end return frame:extensionTag('pre', fmt(l1) .. fmt(l2) .. fmt(l3)) end

return export