모듈:Video game release

require('strict')
local getArgs = require('Module:Arguments').getArgs
local cd = require('Module:CountryData')
local list = require('Module:List');
local p = {}
local labels  = {
'NA' = "북미",
'EU' = "유럽",
'EUR' = "유럽",
'AU' = "호주",
'AUS' = "호주",
'PAL' = "PAL",
'SEA' = "동남아",
'AS' = "아시아",
'SA' = "남미",
'INT' = "국제",
'WW' = "전세계",
'JP' = "일본",
'KR' = "한국",
'CN' = "중국",
'TW' = "대만",
'HK' = "홍콩",
'UK' = "영국",
'US' = "미국",
'CA' = "캐나다",
'NZ' = "뉴질랜드",
'NZL' = "뉴질랜드",
'MO' = "마카오",
'SG' = "싱가포르",
'TH' = "태국",
'?' = "?"
}
local function getLocalLabel(alias)
	local label = labelsstring.upper(alias) 
	return label
end
local countryData = {}; -- Used to store country data to avoid the need of repeated calls to Module:CountryData. This saves a little time if the same abbreviation appears multiple times in the template.
local function getCountryData(frame, alias)
	local ualias = string.upper(alias)
	
	if(countryDataualias == nil) then
		local cdtable = cd.gettable(frame,alias,{})
		countryDataualias = cdtable'alias'
	end
	return countryDataualias
end
local function convert_date_format(date_str)
local year, month, day = date_str:match("^(%d%d%d%d)-?(%d?%d?)-?(%d?%d?)$")
if not year then
return date_str  -- Return the original string if it doesn't match
end
month = tonumber(month) or ""
day = tonumber(day) or ""
-- Construct the formatted date
local formatted_date = year .. "년"
if month ~= "" then
formatted_date = formatted_date .. " " .. month .. "월"
end
if day ~= "" then
formatted_date = formatted_date .. " " .. day .. "일"
end
return formatted_date
end
local function splitLabel(s)
	local islist = true
	local res = {}
	for k,v in ipairs(mw.text.split(s or , '%s*/%s*')) do
		local v1 = v:match('^%s*(A-ZA-ZA-Z?)%s*$')
		if v1 then
			table.insert(res,v1)
		else
			local v2 = v:match('^%s*(%%^%%|*|A-ZA-ZA-Z?%%)%s*$')
			if v2 then
				table.insert(res,v2)
			else
				islist = false
			end
		end
	end
	return islist and res or {s}
end
function p.main(frame)
	local args = getArgs(frame)
	local listformat = args'format'
	if(listformat == nil or listformat == "") then
		listformat = "unbulleted"
	end
	local items = {}
	
	-- Old syntax "Two parameter region" use case, where param 1 is an article, param 2 is a label, and param 3 is the date. We assume this case if argument 4 is nil.
	if(args3 ~= nil and args4 == nil) then
		local item = ""
		if(args1 ~= nil) then
			item = item .. args1
		end
		item = item .. "|"
		if(args2 ~= nil) then
			item = item .. args2
		end
		item = item .. ": " .. convert_date_format(args3) .. "분류:두 개의 변수 지역 없이 vgarelease가 쓰인 글"
		table.insert(items, item)
	-- Old syntax "Blank region" use case, where param 1 is empty, and param 2 is the date.
	elseif(args1 == nil and args2 ~= nil) then
		local item = convert_date_format(args2) .. "분류:지역 없이 vgrelease가 쓰인 글"
		table.insert(items, item)
	-- Normal use cases, region/date pairs in 1/2, 3/4, 5/6, etc.
	else
		local i = 1
		local j = 2
	    while(argsi and argsj) do
			local labels = {}
			for k,v in ipairs(splitLabel(argsi)) do
				local label = getLocalLabel(v);
	
				-- Didn't find a local label? Check for country data.
				if (label == nil) then
					if not v:match('^%s*%') then
						label = getCountryData(frame, v)
					end
		
					-- Found something? Build a sitelink with it.
					if (label ~= nil) then
						label = "" .. v .. ""
					else
						label = v
					end
				end
				table.insert(labels, label)
			end
			local item = "" .. table.concat(labels,'/') .. ": " .. convert_date_format(argsj)
			table.insert(items, item)

			i = i + 2
			j = j + 2
		end
end
	local out = list.makeList(listformat, items)
	-- Set message for invalid parameters. Decide catagory based on list format chosen.
	local parameterMsg
	if(listformat == "horizontal") then
		parameterMsg = "_VALUE_"
	else
		parameterMsg = "_VALUE_"
	end
	
	-- Preview message.
	if(frame:preprocess( "" ) == "") then
		parameterMsg = "경고: 알 수 없는 변수 \"_VALUE_\" (이 메시지는 미리 보기에서만 표시됩니다)."
	end
	
-- Check for named parameters	
	for k, v in pairs(args) do
		if(type(k) ~= 'number' and k ~= 'format') then
			local msg = parameterMsg:gsub('_VALUE_', k)
			out = out .. msg
		end
	end
return out
end
return p