Module:pollasena-roots: Difference between revisions
No edit summary Tag: Manual revert |
No edit summary |
||
| Line 116: | Line 116: | ||
local dest_lang = m_lang.getByCode(dest_code) | local dest_lang = m_lang.getByCode(dest_code) | ||
local etymologies = {} | local etymologies = {} | ||
local termarg_index = 1 -- Track which positional parameter we are parsing | |||
-- iterate in stable order | -- iterate in stable order | ||
| Line 125: | Line 126: | ||
local ancestor_params = { | local ancestor_params = { | ||
[ | [termarg_index] = { | ||
required = not lang_options.optional, | required = not lang_options.optional, | ||
list = lang_options.roots, | list = lang_options.roots, | ||
| Line 133: | Line 134: | ||
if lang_options.roots then | if lang_options.roots then | ||
ancestor_params[ | ancestor_params[termarg_index].allow_holes = true | ||
end | end | ||
| Line 140: | Line 141: | ||
param_mods = param_mods, | param_mods = param_mods, | ||
raw_args = parent_args, | raw_args = parent_args, | ||
termarg = | termarg = termarg_index, | ||
lang = ancestor_lang, | lang = ancestor_lang, | ||
}) | }) | ||
local terms = parsed.terms | -- Safely extract terms whether splitchar is used or not | ||
local terms = parsed.terms or {} | |||
-- ensure at least one term exists | -- ensure at least one term exists | ||
if not terms[1] then | if not terms[1] then | ||
terms[1] = { lang = ancestor_lang } | if parsed.term then | ||
terms[1] = parsed | |||
else | |||
terms[1] = { lang = ancestor_lang } | |||
end | |||
end | end | ||
| Line 160: | Line 166: | ||
table.insert(etymologies, etymology) | table.insert(etymologies, etymology) | ||
termarg_index = termarg_index + 1 -- Increment for the next ancestor in the chain | |||
end | end | ||
| Line 174: | Line 181: | ||
function export.qsc(frame) | function export.qsc(frame) | ||
local parent_args = frame:getParent().args | local parent_args = frame:getParent().args | ||
local ancestor_codes = { | local ancestor_codes = { | ||
{ code = "sekh", options = {default = "asʰilavən"} }, | |||
{ code = "wasc", options = {optional = true, roots = true, default = "asł-ila"} } | |||
} | } | ||
| Line 187: | Line 194: | ||
function export.lyti(frame) | function export.lyti(frame) | ||
local parent_args = frame:getParent().args | local parent_args = frame:getParent().args | ||
local source_code = parent_args.source | local source_code = parent_args.source or "und" -- Fallback to "und" if no source provided | ||
local ancestor_codes = { | local ancestor_codes = { | ||
{ code = "lyti-mid", options = {optional = not parent_args.mid} }, | |||
{ code = "lyti-old", options = {optional = not parent_args.old} }, | |||
{ code = source_code, options = {} }, | |||
} | } | ||
local | local evolution = parse_args(parent_args, "lyti", ancestor_codes) | ||
return concat_etymologies(parent_args, evolution) | |||
end | end | ||
return export | return export | ||