模块:Editions

来自The Land of StarLight

可在模块:Editions/doc创建此模块的帮助文档

local p = {}

local fullName = mw.loadData([[Module:Editions/FullName]])
local shortName = mw.loadData([[Module:Editions/ShortName]])

function p.editions(args)
	local editionTable = {}
	local categories = {}
	local isShort = args.short
	local nocat = args.nocat
	local catTemplate = args.cat or '$'
	for _, v in ipairs(args) do
		if v ~= '' then
			local name = fullName[mw.ustring.lower(v)] or v .. '版'
			table.insert(editionTable, table.concat {
				'[[',
				name,
				'|',
				isShort and shortName[name] or name,
				']]'
			})
			if not nocat then
				table.insert(
					categories,
					'[[Category:' .. mw.ustring.gsub(catTemplate, '%$', name) .. ']]'
				)
			end
		end
	end
	return mw.text.listToText(editionTable) .. table.concat(categories)
end

function p.wrapper()
	local args = require([[Module:ProcessArgs]]).merge(true)
	return p.editions(args)
end

return p