মডিউল:labels/templates/show from

উইকিঅভিধান, মুক্ত অভিধান থেকে

এই মডিউলের জন্য মডিউল:labels/templates/show from/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে

local export = {}

--[[	temporary. intentionally undocumented.
		this function is only to be used in
		{{alternative spelling of}},
		{{eye dialect of}}
		and similar templates					]]
function export.show_from(frame)
	local froms = {}
	local categories = {}

	local iparams = {
		["lang"] = {},
		["limit"] = {type = "number"},
		["default"] = {},
	}
	
	local iargs = require("Module:parameters").process(frame.args, iparams)
	local parent_args = frame:getParent().args
	local compat = iargs["lang"] or parent_args["lang"]

	local params = {
		[compat and "lang" or 1] = {required = not iargs["lang"]},
		["from"] = {list = true},
		["nocat"] = {type = "boolean"},
	}

	-- This is called by various form-of templates. They accept several params,
	-- and some templates accept additional params. To avoid having to list all
	-- of them, we just ignore unrecognized params. The main processing for the
	-- form-of template will catch true unrecognized params.
	local args = require("Module:parameters").process(parent_args, params, "allow unrecognized params")
	local lang = args[compat and "lang" or 1] or iargs["lang"] or "und"
	local nocat = args["nocat"]
	local limit = iargs.limit or 99999
	
	local m_languages = require("Module:languages")
	lang = m_languages.getByCode(lang) or m_languages.err(lang, "lang")

	local already_seen = {}

	for i, k in ipairs(args["from"]) do
		if i > limit then
			break	
		end
		local ret = require("Module:labels").get_label_info(k, lang, already_seen)
		if ret.label ~= "" then
			table.insert(froms, ret.label)
		end
		if ret.categories ~= "" then
			table.insert(categories, ret.categories)
		end
	end
	
	if #froms == 0 then
		return iargs.default
	end

	return require("Module:table").serialCommaJoin(froms) .. table.concat(categories)
end

return export