Modul:etymology-only languages, csv format
Penampilan
- Modul ini kekurangan sublaman pendokumenan. Sila mencipta laman pendokumenan berkaitan.
- Pautan berguna: senarai sublaman • pautan • transklusi • kes ujian • kotak pasir
local languages = require("Module:languages/data/all")
local families = require("Module:families/data")
local etym_data = require('Module:etymology_languages/data')
-- based on Module:list_of_languages
local export = {}
function export.show(frame)
local rows = {}
local codes_list = {}
local items = {}
for code, data in pairs(etym_data) do
if not codes_list[data] then
codes_list[data] = {}
table.insert(items, data)
end
table.insert(codes_list[data], code)
end
table.sort(items, function (apple, orange)
return apple[1] < orange[1]
end)
local function make_parent_link(code)
if languages[code] then
return (languages[code][1])
elseif families[code] then
return (families[code][1])
elseif etym_data[code] then
return (etym_data[code][1])
elseif code then
return '<code>' .. code .. '</code>'
else
return '[missing]'
end
end
local sep = ";"
local minor_sep = ","
local column_names = "line" ..sep.. "code" ..sep.. "canonical name" ..sep..
"parent" ..sep.. "other names"
for line, data in ipairs(items) do
local codes = codes_list[data]
table.sort(codes)
local row = {}
table.insert(row, line)
table.insert(row, table.concat(codes, minor_sep))
table.insert(row, data[1])
table.insert(row, make_parent_link(data[3]))
table.insert(row, data.otherNames and table.concat(data.otherNames, minor_sep) or "")
table.insert(rows, table.concat(row, sep))
end
return "<pre>\n" .. column_names .. "\n" .. table.concat(rows, "\n") .. "</pre>"
end
return export