Module:Ikiusu

Revision as of 10:37, 26 September 2025 by Raven (talk | contribs) (Created page with "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) end langs[lang] = langs[lang] if tonumber(...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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)
				end
				langs[lang] = langs[lang]
				if tonumber(param) then
					langs[tonumber(param)] = v
				else
					langs[param] = v
				end
			end
		end
	end
	local result = {}
	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
	return frame:preprocess(table.concat(result, "\n"))
end

return p