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 = {
[1] = {
[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[1].allow_holes = true
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 = 1,
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 dest_lang = m_lang.getByCode("qsc")
local ancestor_codes = {
local ancestor_codes = {
["sekh"] = {default = "asʰilavən"},
{ code = "sekh", options = {default = "asʰilavən"} },
["wasc"] = {optional = true, roots = true, default = "asł-ila"}
{ 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 = {
["lyti-mid"] = {optional = not parent_args.mid},
{ code = "lyti-mid", options = {optional = not parent_args.mid} },
["lyti-old"] = {optional = not parent_args.old},
{ code = "lyti-old", options = {optional = not parent_args.old} },
[source_code] = {},
{ code = source_code, options = {} },
}
}
local terms, args = parse_args(parent_args, "lyti", ancestor_codes)
local evolution = parse_args(parent_args, "lyti", ancestor_codes)
return concat_etymologies(parent_args, evolution)
end
end


return export
return export