Jump to content

Module:parameters/data

From Wiktionary
local shallowcopy = require("Module:table").shallowcopy

local function no_equals(t)
	local t_no_equals = {}
	for k, v in pairs(t) do
		if type(k) == "string" then
			t_no_equals[k:gsub("=", "")] = v
		else
			t_no_equals[k] = v
		end
	end
	return t_no_equals
end

local alias_of_4 = {alias_of = 4}
local allow_empty = {allow_empty = true}
local boolean = {type = "boolean"}
local boolean_default_false = {type = "boolean", default = false}
local boolean_list_allow_holes = {type = "boolean", list = true, allow_holes = true}
local list = {list = true}
local list_allow_holes = {list = true, allow_holes = true}
local plain = {}
local required = {required = true}
local required_default_ = {required = true, default = ""}
local required_default_und = {required = true, default = "und"}

local m = {}

m["anchor"] = {}

	m["anchor"].main = {
		[1] = {required = true, list = true},
		["anchor"] = {alias_of = 1}
	}
	
m["attention"] = {}

	m["attention"].show = {
		[1] = required,
		[2] = plain,
		["id"] = plain,
		["nocat"] = boolean,
		["sort"] = plain,
	}

m["headword/templates"] = {}

	m["headword/templates"].head_t = {
		[1] = required_default_und,
		["sc"] = plain,
		["sort"] = plain,
		
		[2] = {required = true, default = "nouns"},
		["sccat"] = boolean,
		["noposcat"] = boolean,
		["nomultiwordcat"] = boolean,
		["nogendercat"] = boolean,
		["nopalindromecat"] = boolean,
		["autotrinfl"] = boolean,
		["cat2"] = plain,
		["cat3"] = plain,
		["cat4"] = plain,
		
		["head"] = list_allow_holes,
		["id"] = plain,
		["tr"] = list_allow_holes,
		["ts"] = list_allow_holes,
		["g"] = list,
		["g=qual"] = list_allow_holes,
		
		[3] = list_allow_holes,
		
		["f=accel-form"] = list_allow_holes,
		["f=accel-translit"] = list_allow_holes,
		["f=accel-lemma"] = list_allow_holes,
		["f=accel-lemma-translit"] = list_allow_holes,
		["f=accel-gender"] = list_allow_holes,
		["f=accel-nostore"] = boolean_list_allow_holes,
		["f=request"] = list_allow_holes,
		["f=alt"] = list_allow_holes,
		["f=sc"] = list_allow_holes,
		["f=id"] = list_allow_holes,
		["f=tr"] = list_allow_holes,
		["f=ts"] = list_allow_holes,
		["f=g"] = list_allow_holes,
		["f=qual"] = list_allow_holes,
		["f=autotr"] = boolean_list_allow_holes,
		["f=nolink"] = boolean_list_allow_holes,
		["f=lang"] = list_allow_holes,
	}
	
	m["headword/templates"].head_t_no_equals = no_equals(m["headword/templates"].head_t)

m["links/templates"] = {}

	m["links/templates"].l_term_t = {
		[1] = required,
		[2] = plain,
		[3] = plain,
		[4] = plain,
		["g"] = list,
		["gloss"] = alias_of_4,
		["id"] = plain,
		["lit"] = plain,
		["pos"] = plain,
		["sc"] = plain,
		["t"] = alias_of_4,
		["tr"] = plain,
		["ts"] = plain,
		["accel-form"] = plain,
		["accel-translit"] = plain,
		["accel-lemma"] = plain,
		["accel-lemma-translit"] = plain,
		["accel-gender"] = plain,
		["accel-nostore"] = boolean,
	}
	
	m["links/templates"].l_term_t_compat = shallowcopy(m["links/templates"].l_term_t)
	m["links/templates"].l_term_t_compat.lang = plain
	table.remove(m["links/templates"].l_term_t_compat, 1)
	
	m["links/templates"].ll = {
		[1] = required,
		[2] = allow_empty,
		[3] = plain,
		["notself"] = boolean_default_false,
		["id"] = plain,
		["sc"] = plain,
	}
	
	m["links/templates"].def_t = {
		[1] = required_default_,
		["notlangcode"] = boolean_default_false
	}
	
	m["links/templates"].linkify_t = {
		[1] = required_default_,
	}
	
	m["links/templates"].section_link_t = {
		[1] = plain,
	}
	
	m["links/templates"].language_name_link_t = {
		[1] = required,
		[2] = plain,
		[3] = plain,
		[4] = plain,
		["g"] = list,
		["gloss"] = alias_of_4,
		["id"] = plain,
		["lit"] = plain,
		["pos"] = plain,
		["sc"] = plain,
		["t"] = alias_of_4,
		["tr"] = plain,
		["ts"] = plain,
		["w"] = boolean_default_false,
	}
	
	m["links/templates"].language_name_link_t_compat = shallowcopy(m["links/templates"].language_name_link_t)
	m["links/templates"].language_name_link_t_compat.lang = plain
	table.remove(m["links/templates"].language_name_link_t_compat, 1)

m["phrasebook"] = {}

	m["phrasebook"].show = {
		[1] = required,
		[2] = list,
	}

m["translations"] = {}

	m["translations"].show = {
		[1] = required_default_und,
		[2] = plain,
		[3] = list,
		["alt"] = plain,
		["id"] = plain,
		["sc"] = plain,
		["tr"] = plain,
		["ts"] = plain,
		["lit"] = plain,
	}
	
	m["translations"].top = {
		[1] = plain,
		["id"] = plain,
		["column-width"] = plain,
	}
	
	m["translations"].bottom = {}
	
	m["translations"].see = {
		[1] = required,
		[2] = list,
		["id"] = plain
	}

return m