Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Contributors: Difference between revisions

From Hacks Guide Wiki
No edit summary
No edit summary
(One intermediate revision by the same user not shown)
Line 40: Line 40:
local box = messageBox.main('fmbox', {
local box = messageBox.main('fmbox', {
image='[[File:OOjs UI icon logo-cc.svg|40px|link=]]',
image='[[File:OOjs UI icon logo-cc.svg|40px]]',
text=table.concat(finalText, '\n')
text=table.concat(finalText, '\n')
})
})

Revision as of 11:17, 12 June 2022

local messageBox = require('Module:Message box')

local p = {}

function p.argsToIndexedTable( args )
	local newtable = {}
	
	for k, v in pairs(args) do
		local num = tonumber(k)
		if num ~= nil then
			newtable[num] = v
		end
	end
	
	return newtable
end

function p.main( frame )
	local fp = frame:getParent()
	
	local contribs = p.argsToIndexedTable( fp.args )
	
	local lang = mw.language.getContentLanguage()
	
	local prefix = lang:convertPlural(
		#contribs,
		"The main author of this article is ",
		"The main authors of this article are "
	)
	
	local suffix = '.'
	
	local finalText = {
		prefix..mw.text.listToText(contribs)..suffix,
	}
	
	if fp.args.extra then
		table.insert(finalText, fp.args.extra)
	end
	
	local box = messageBox.main('fmbox', {
		image='[[File:OOjs UI icon logo-cc.svg|40px]]',
		text=table.concat(finalText, '\n')
	})
	
	return box
end

return p