Module:Ikiusu

Revision as of 10:40, 26 September 2025 by Raven (talk | contribs)

Documentation for this module may be created at Module:Ikiusu/doc

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	local word = args[1]
	local options = {}
	for i = 2, #args do
		options[args[i]] = true
	end
	options.image = args.image
	
	local langs = {}
	local lang_list = {}
	for k, v in pairs(args) do
		if type(k) == "string" then
			local lang, param = k:match "([^-]*)-(.*)"
			if lang then
				if not langs[lang] then
					table.insert(lang_list, lang)
					langs[lang] = {}	
				end
				if tonumber(param) then
					langs[lang][tonumber(param)] = v
				else
					langs[lang][param] = v
				end
			end
		end
	end
	local result = {}
	table.concat(result, "{{langs|")
	for _, lang in ipairs(lang_list) do
		table.concat(result, "{{langs/in|"..lang.."")
		if options.image then
			local caption = langs[lang].caption or ""
			table.concat(result,
				"[["..options.image.."|200px|thumb|"..caption.."]]"
			)
		end
		table.concat(result, "'''"..word.."'''")
		for _, defn in ipairs(langs[lang]) do
			table.concat(result, defn)
		end
		if options.inflect then
			table.concat(result, "{{inflect senra|"..lang.."|"..word.."}}")
		end
		table.concat(result, "}}")
	end
	table.concat(result, "}}")
	return --[[frame:preprocess(]] table.concat(result, "\n") --[[)]]
end

return p