Module:pollasena-roots: Difference between revisions
No edit summary |
No edit summary |
||
| Line 118: | Line 118: | ||
local param_mods = m_param_utils.construct_param_mods({{group = {"link", "q", "l"}}}) | local param_mods = m_param_utils.construct_param_mods({{group = {"link", "q", "l"}}}) | ||
local dest_lang = lang_from_code(dest_code) | local dest_lang = lang_from_code(dest_code) | ||
local etymologies = {} | local etymologies = {} | ||
termarg_index = 1 | local termarg_index = 1 | ||
for _, ancestor in ipairs(ancestor_codes) do | for _, ancestor in ipairs(ancestor_codes) do | ||
local code = ancestor.code | local code = ancestor.code | ||
local lang_options = ancestor.options or {} | local lang_options = ancestor.options or {} | ||
local ancestor_lang = lang_from_code(code) | local ancestor_lang = lang_from_code(code) | ||
local terms | local terms | ||
if lang_options.roots then | if lang_options.roots then | ||
-- 1. Setup params specifically for this list argument | |||
local list_params = { | |||
[termarg_index] = { | |||
required = not lang_options.optional, | |||
list = true, | |||
allow_holes = true, | |||
default = lang_options.default, | |||
} | |||
} | |||
-- Let the utility re-parse the raw arguments for this specific list | |||
local items = m_param_utils.parse_list_with_inline_modifiers_and_separate_params({ | local items = m_param_utils.parse_list_with_inline_modifiers_and_separate_params({ | ||
raw_args = parent_args, | |||
params = list_params, | |||
param_mods = param_mods, | param_mods = param_mods, | ||
termarg = termarg_index, | termarg = termarg_index, | ||
lang = ancestor_lang, | lang = ancestor_lang, | ||
}) | }) | ||
terms = items | |||
-- Filter out any literal hyphens passed as terms | |||
terms = {} | |||
for _, item in ipairs(items) do | |||
if item.term and item.term ~= "-" then | |||
table.insert(terms, item) | |||
end | |||
end | |||
else | else | ||
-- 2. Setup params specifically for this single term argument | |||
local term_params = { | |||
[termarg_index] = { | |||
required = not lang_options.optional, | |||
default = lang_options.default, | |||
} | |||
} | |||
local parsed = m_param_utils.parse_term_with_inline_modifiers_and_separate_params({ | local parsed = m_param_utils.parse_term_with_inline_modifiers_and_separate_params({ | ||
raw_args = parent_args, | |||
params = term_params, | |||
param_mods = param_mods, | param_mods = param_mods, | ||
termarg = termarg_index, | termarg = termarg_index, | ||
| Line 170: | Line 174: | ||
terms = parsed.terms or {} | terms = parsed.terms or {} | ||
if not terms[1] then | if not terms[1] then | ||
if parsed.term then | if parsed.term then | ||
| Line 184: | Line 187: | ||
sources = { ancestor_lang }, | sources = { ancestor_lang }, | ||
terms = terms, | terms = terms, | ||
nocat = | conj = lang_options.roots and "-" or nil, -- Use our newly added hyphen conjunction! | ||
nocat = parent_args.nocat, | |||
template_name = "derived", | template_name = "derived", | ||
}) | }) | ||
| Line 192: | Line 196: | ||
end | end | ||
return etymologies | return etymologies | ||
end | end | ||
local function concat_etymologies( | local function concat_etymologies(parent_args, etymologies) | ||
local capital = | local capital = parent_args.nocap and "f" or "F" | ||
return capital .. "rom " .. table.concat(etymologies, ", from ") .. "." | return capital .. "rom " .. table.concat(etymologies, ", from ") .. "." | ||
end | end | ||
| Line 208: | Line 212: | ||
} | } | ||
local evolution | local evolution = parse_args(parent_args, "qsc", ancestor_codes) | ||
return concat_etymologies( | return concat_etymologies(parent_args, evolution) | ||
end | end | ||
| Line 223: | Line 227: | ||
} | } | ||
local evolution = parse_args(parent_args, "lyti", ancestor_codes) | |||
local evolution | |||
return concat_etymologies( | return concat_etymologies(parent_args, evolution) | ||
end | end | ||
return export | return export | ||