跳转到内容

模組:Vgr/sandbox

维基百科,自由的百科全书

这是本页的一个历史版本,由D2F0F5留言 | 贡献2014年8月8日 (五) 12:02编辑。这可能和当前版本存在着巨大的差异。

local p = {}

local arealist = {
	
	{'KR', '[[韩国|-{zh-cn:韩国; zh-tw:南韓;}-]]'};
	{'JP', '[[日本]]'};
	{'INT', '[[国际化与本地化|国际]]'};
	{'WW', '[[国际]]'};
	{'NA', '[[北美]]'};
	{'PAL', '[[PAL区]]'};
	{'EU', '[[欧洲]]'};
	{'AU', '[[澳洲]]'}; -- 兼容{{Vgrelease new}}的使用参数
	{'AUS', '[[澳洲]]'}; -- 兼容{{Vgrelease}}的使用参数
	{'CN', '[[中国大陆|大陆]]'};
	{'TWHK', '[[台湾|台]][[香港|港]]'};
	{'TW', '[[台湾]]'};
	{'HK', '[[香港]]'};
	{'SEA', '[[东南亚]]'};
	{'SG', '[[新加坡]]'};
	{'MY', '[[马来西亚]]'};

}

local function vgn(area, context)
	local ret

	for i = 1, table.getn(arealist) do
		if arealist[i][1] == area then 
			ret = arealist[i][2] .. ':' .. context .. '<br />'
			break
		end
	end

	if ret == nil then
		ret = area .. ':' .. context .. '<br />'
	end
		
	return ret
end

function p.vgrelease(frame)
	
	local pframe = frame:getParent()
	local args = pframe.args
	local ret = ''

	for j = 1, table.getn(arealist) do
		if args[arealist[j][1]] ~= nil then
			ret = ret .. arealist[j][2] .. ':' .. args[arealist[j][1]] .. '<br />'
		end
	end

	if args[4] ~= (nil and '') then
		for i = 1, math.huge, 2 do
			if args[i+1] ~= (nil and '') then
				ret = ret .. vgn(args[i], args[i+1])
			else
				break
			end
		end

	elseif args[3] ~= (nil and '') then
		ret = ret .. '[[' .. args[1] .. '|' .. args[2] .. ']]:' .. args[3]
		
	elseif args[2] ~= (nil and '') then
		ret = ret .. args[1] .. ':' .. args[2]
		
	end

	return ret
end

return p