Module:Sandbox/CAS222222221

This is an old revision of this page, as edited by 風中的刀劍 (talk | contribs) at 05:50, 11 December 2014. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
 
local p = {}

local langlist = {
 
	-- 请在下方区域更新语言代码
 
	{'de', '德语', '德版名'},
	{'fi', '芬兰语', '芬兰版名'},
	{'ja', '日语', '日版名'},
	{'ko', '韩语', '韩版名'},
	{'ru', '俄语', '俄版名'},
	
	-- 请在上方区域更新语言代码

}

local langlist2 = { 

	en = {'en', '英语', '英文版名'},
	na = {'en', '英语', '美版名'},
	eu = {'en', '英语', '欧版名'},
 
}

local function bold( inp )
	
	if yesno(args.bold) then
		inp = '<b>' .. inp .. '</b>'
	end
	
	return inp
end

local function italic( inp )
	inp = '<i>' .. inp .. '</i>'
	
	return inp
end

local function label( langIndex )
	local ret
	
	if yesno( args.diff ) or na ~= '' or eu ~= '' then
		ret = langlist[langIndex][3]
	else
		ret = langlist[langIndex][2]
	end
	
	return ret
end

local function spanlang( langIndex )
	local code = langlist[langIndex][1]
	local ret = mw.html.create( 'span' )
		span
			:css( 'lang', code )
			:wikitext( '-{' .. agrs[code] .. '}-' )
			:tag( 'span' )
			
	return tostring( span )
end

local function lead()
	local ret
	
	if yesno(args.bracket) then
		ret = '《' .. bold( args[1] ) .. '》'
	else
		ret = bold( args[1] )
	end
	
	return ret
end

local function orig()
	local ret = ''
	
	for i, v in ipairs( langlist ) do
		if args[v[1]] ~= '' then
			ret = label( v ) .. ':' spanlang( v )
			break
		end
	end

	return ret
end

local function eng( ... )
end

local function trans( ... )
end

local function note( ... )
end

function p.vgname(frame)
	local args = getArgs(frame, {
		valueFunc = function (key, value)
			if key == nil then
				value = ''
			end
			return value
		end
		})
	
	-- Main module code goes here

	return lead() .. orig()

end

return p