Module:pollasena-roots: Difference between revisions

No edit summary
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 14: Line 14:


local export = {}
local export = {}
local function lang_from_code(...)
return m_lang.getByCode(...)
end


local function ncategories(categories)
local function ncategories(categories)
Line 115: Line 119:
for k, v in pairs(args) do
for k, v in pairs(args) do
if type(v) == "table" and v.maxindex then
if type(v) == "table" and v.maxindex then
single[k] = v[index]
if v[index] ~= nil then
single[k] = v[index]
end
else
else
single[k] = v
single[k] = v
Line 139: Line 145:
list = true,
list = true,
allow_holes = true,
allow_holes = true,
default = lang_options.default,
}
}
else
else
params[termarg_index] = {
params[termarg_index] = {
required = not lang_options.optional,
required = not lang_options.optional,
default = lang_options.default,
}
}
end
end
Line 163: Line 167:
local lang_options = ancestor.options or {}
local lang_options = ancestor.options or {}
local ancestor_lang = m_lang.getByCode(code)
local ancestor_lang = m_lang.getByCode(code)
local terms
local terms
local separator = ""


if lang_options.roots then
if lang_options.roots then
Line 172: Line 178:
lang = ancestor_lang,
lang = ancestor_lang,
})
})
terms = items
terms = {}
local root_index = 1
for _, item in ipairs(items) do
if item.term == "-" or item.term == "+" then
separator = item.term
elseif item.term then
if root_index > 1 and separator == "-" then -- no asterisk after hyphen
if not item.alt then
item.alt = item.term:gsub("^%*", "")
else
item.alt = item.alt:gsub("^%*", "")
end
item.no_alt_ast = true
end
table.insert(terms, item)
root_index = root_index + 1
end
end
else
else
local single_args = get_single_args(args, termarg_index)
local single_args = get_single_args(args, termarg_index)
Line 183: Line 208:


terms = parsed.terms or {}
terms = parsed.terms or {}
-- ensure at least one term exists
if not terms[1] then
if not terms[1] then
if parsed.term then
if parsed.term then
Line 197: Line 221:
sources = { ancestor_lang },
sources = { ancestor_lang },
terms = terms,
terms = terms,
conj = lang_options.roots and separator or nil,
nocat = args.nocat,
nocat = args.nocat,
template_name = "derived",
template_name = "derived",
Line 217: Line 242:
local ancestor_codes = {
local ancestor_codes = {
{ code = "sekh", options = {default = "asʰilavən"} },
{ code = "sekh" },
{ code = "wasc", options = {optional = true, roots = true, default = "asł-ila"} }
{ code = "wasc", options = {optional = true, roots = true } }
}
}