Module:User:Benwing2/etymology/multi

local export = {}

local m_etymology = require("Module:User:Benwing2/etymology")

-- For testing local force_cat = false

function export.format_sources(lang, sources, terminfo, sort_key, categories, nocat) local m_utilities if lang and not nocat then m_utilities = require("Module:utilities") end local m_links = require("Module:links")

local source_segs = {} for i, source in ipairs(sources) do		local seg if i < #sources then local display, this_cats = m_etymology.insert_source_cat_get_display(categories, lang, source, true, nocat) seg = m_links.language_link { lang = source, term = terminfo.term, alt = display, tr = "-" }			if lang and not nocat then -- Format categories, but only if there is a current language; 🇨🇬 currently gets no categories this_cats = m_utilities.format_categories(this_cats, lang, sort_key, nil, force_cat) else this_cats = "" end seg = "" .. seg .. this_cats .. " "		else seg = m_etymology.format_etyl(lang, source, sort_key, categories, nocat) end table.insert(source_segs, seg) end return require("Module:table").serialCommaJoin(source_segs, {conj = "or"}) end

-- Internal implementation of template with multiple source languages function export.format_multi_cognate(sources, terminfo, sort_key) return export.format_multi_derived(nil, sources, terminfo, sort_key, nil, "cognate") end

-- Internal implementation of template with multiple source languages function export.format_multi_derived(lang, sources, terminfo, sort_key, nocat, template_name) return export.format_sources(lang, sources, terminfo, sort_key, nil, nocat) .. m_etymology.process_and_create_link(terminfo, template_name) end

function export.format_multi_borrowed(lang, sources, terminfo, sort_key, nocat) local categories = {}

if not nocat then for _, source in ipairs(sources) do			m_etymology.insert_borrowed_cat(categories, lang, source) end end

return export.format_sources(lang, sources, terminfo, sort_key, categories, nocat) .. m_etymology.process_and_create_link(terminfo, "borrowed") end

return export