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 = {
"行號", "代碼", "名稱", "類型", "語族代碼",
"語族", "排序鍵?", "自動檢測?", "特殊?", "文字代碼",
"其他名稱", "標準字元"
}
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] .. (data[1]:find("[Ll]anguage$") and "" or " language"))
table.insert(row, data.type or "")
table.insert(row, data[3] or "")
table.insert(row, (data['family'] or data[3]) and (families[data['family'] or data[3]] and families[data['family'] or data[3]].canonicalName or "未知"))
table.insert(row, data.sort_key and "排序鍵" or "")
table.insert(row, data.entry_name and "自動檢測" or "")
table.insert(row, code:find("-") and "特殊" 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 "標準字元" 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