Module:User:Surjection/audio

Definition from Wiktionary, the free dictionary
Jump to navigation Jump to search

This is a private module sandbox of Surjection, for their own experimentation. Items in this module may be added and removed at Surjection's discretion; do not rely on this module's stability.


local export = {}
local m_audio = require("Module:audio")

function export.show(frame)
	local params = {
		[1] = {required = true, default = "und"},
		[2] = {list = true, required = true},
		["q"] = {list = true, allow_holes = true},
		["caption"] = {},
		["nocaption"] = {type = "boolean"},
	}
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local lang = require("Module:languages").getByCode(args[1], 1)

	local data = {
		lang = lang,
		audios = {},
		caption = not args.nocaption and (args.caption or "Audio") or nil
	}
	for i=1, #args[2] do
		local audiofile = { file = args[2][i] }
		if args["q"][i] then
			audiofile.qualifiers = { args["q"][i] }
		end
		table.insert(data.audios, audiofile)
	end

	return m_audio.format_audios(data)
end

return export