local languages = require("Module:languages/data/all")
local families = require("Module:families/data")
-- based on Module:list_of_languages
local export = {}
local filters = {}
function export.show(frame)
local args = frame.args
local filter = filters[args[1]]
local ids = args["ids"]; if not ids or ids == "" then ids = false else ids = true end
local rows = {}
-- Get a list of all language codes
local codes = {}
for code, _ in pairs(languages) do
table.insert(codes, code)
end
-- Sort the list
table.sort(codes)
local sep = ";"
local minor_sep = ","
local function shallowcopy(array)
local new_array = {}
if type(array) == "string" then array = {array} end
for i, v in ipairs(array) do
new_array[i] = v
end
return new_array
end
-- Now go over each code, and create table rows for those that are selected
local column_names = {
"line", "code", "canonical name", "category", "type", "family code",
"family", "sortkey?", "autodetect?", "exceptional?", "script codes",
"other names", "standard characters"
}
for line, code in ipairs(codes) do
local data = languages[code]
local row = {}
local sc = data[4]
if type(sc) == "string" then sc = mw.text.split(sc, "%s*,%s*") end
-- data[1]: canonical name; data[3]: family code
table.insert(row, line)
table.insert(row, code)
table.insert(row, data[1])
table.insert(row, (data[1]:find("^ภาษา") and "" or "ภาษา") .. data[1])
table.insert(row, data.type or "")
table.insert(row, data[3] or "")
table.insert(row, data[3] and (families[data[3]] and families[data[3]][1] or error(data[3] .. " is not a valid family code (family of " .. code .. ")")))
table.insert(row, data.sort_key and "sortkey" or "")
table.insert(row, data.entry_name and "autodetect" or "")
table.insert(row, code:find("-") and "exceptional" or "")
table.insert(row, sc and table.concat(sc, minor_sep) or "")
table.insert(row, data.otherNames and table.concat(data.otherNames, minor_sep) or "")
table.insert(row, data.standardChars and "standard characters" or "")
table.insert(rows, table.concat(row, sep))
end
return "<pre>\n" .. table.concat(column_names, sep) .. "\n" .. table.concat(rows, "\n") .. "</pre>"
end
return export