Module:category tree/poscatboiler/data/families

local raw_categories = {} local raw_handlers = {}

- --                                                                        -- --                              RAW CATEGORIES                             -- --                                                                        -- -

raw_categories["All language families"] = { topright = "\n", description = "This category lists all language families.", parents = {"Fundamental"}, }

raw_categories["Languages by family"] = { topright = "\n", description = "This category contains all languages categorized hierarchically according to the language family they belong to.", additional = "Only top-level language families are shown here. For a full list of all language families, see Category:All language families or List of families.", parents = { {name = "All languages", sort = " "}, {name = "All language families", sort = " "}, }, }

- --                                                                        -- --                                RAW HANDLERS                             -- --                                                                        -- -

local function family_is_not_a_family(fam) local famcode = fam:getCode if famcode == "paa" then return false -- Papuan languages are not a family but have a category elseif famcode == "qfa-iso" or famcode == "qfa-not" then return true else local parfam = fam:getFamily if parfam and parfam:getCode == "qfa-not" then -- Constructed languages, sign languages, etc.; no category for them return true end end return false end

local function infobox(fam) local ret = {} table.insert(ret, " \n \n") table.insert(ret, " \n Common ancestor ") local protoLanguage = fam:getProtoLanguage if protoLanguage then table.insert(ret, "" .. protoLanguage:getCanonicalName .. "") else table.insert(ret, "none") end table.insert(ret, " \n") table.insert(ret, "\n \n") local parent = fam:getFamily if not parent then table.insert(ret, " \n Parent family \n ") table.insert(ret, "unclassified") elseif parent:getCode == "qfa-not" then table.insert(ret, " \n Parent family \n ") table.insert(ret, "not a family") else local chain = {} while parent do			if family_is_not_a_family(parent) then break end table.insert(chain, "" .. parent:getCanonicalName .. "") parent = parent:getFamily end if #chain == 0 then table.insert(ret, " \n Parent family \n ") table.insert(ret, "no parents") else table.insert(ret, " \n Parent famil"				.. (#chain == 1 and "y" or "ies") .. " \n ") for i = #chain, 1, -1 do table.insert(ret, "" .. chain[i]) end table.insert(ret, string.rep("", #chain)) end end table.insert(ret, " \n \n") if fam:getWikidataItem and mw.wikibase then local link = '[' .. mw.wikibase.getEntityUrl(fam:getWikidataItem) .. ' ' .. fam:getWikidataItem .. ']'		table.insert(ret, " Wikidata  " .. link .. "  ") end table.insert(ret, " ") return table.concat(ret) end

table.insert(raw_handlers, function(data)	local family_name = data.category:match("^(.+) languages$")	if not family_name then		family_name = data.category:match("^(.+ Languages)$")	end	if not family_name then		return nil	end	local family = require("Module:families").getByCanonicalName(family_name) or		require("Module:families").getByCanonicalName(mw.ustring.lower(family_name))	if not family then		return nil	end

local parent_fam = family:getFamily local first_parent if not parent_fam or family_is_not_a_family(parent_fam) then first_parent = "Languages by family" else first_parent = parent_fam:getCategoryName end

local topright, description, additional = "", "", "" if not data.called_from_inside then local wikipedia_art = family:getWikipediaArticle topright = "\n" description = "This is the main category of the '''" .. family:getDisplayForm .. "'''."		additional = "Information about " .. family:getCanonicalName .. ":\n\n" .. infobox(family) end

local parents = { first_parent, "All language families", }	if parent_fam and parent_fam:getCode == "sgn" then table.insert(parents, "All sign languages") end return { topright = topright, description = description, additional = additional, parents = parents, breadcrumb = family:getCanonicalName, can_be_empty = true, } end)

return {RAW_CATEGORIES = raw_categories, RAW_HANDLERS = raw_handlers}