İçeriğe atla

Modül:Video oyunu çıkış tarihi

Vikipedi, özgür ansiklopedi
Modül belgelemesi[gör] [değiştir] [geçmiş] [temizle]

Bu modül, {{video oyunu çıkış tarihi}} şablonunun yürütülmesini sağlamaktadır. Çıkış biçimini ayarlamak için "format" parametresi {{#invoke:liste}} modülüne iletilir. Kullanım talimatları ve izleme kategorilerine dair detaylar şablon belgelemesinde bulunmaktadır.

require('Modül:Küresel değil')

local getArgs = require('Modül:Bağımsız değişkenler').getArgs
local cd = require('Modül:ÜlkeVeri')
local list = require('Modül:Liste');
local p = {}

local knownargs = {
	['format'] = true,
	['sınıf'] = true,
	['biçim'] = true,
	['listebiçimi'] = true,
	['ögebiçimi'] = true,
	['öge1_biçimi'] = true,
	['girinti'] = true
}

local labels = {
	['NA'] = "[[Kuzey Amerika|KA]]",
	['KA'] = "[[Kuzey Amerika|KA]]",
	['EU'] = "[[Avrupa|AVR]]",
	['EUR'] = "[[Avrupa|AVR]]",
	['AVR'] = "[[Avrupa|AVR]]",
	['AV'] = "[[Avrupa|AVR]]",
	['AU'] = "[[Avustralasya|AU]]",
	['AUS'] = "[[Avustralasya|AU]]",
	['PAL'] = "[[PAL bölgesi|PAL]]",
	['SEA'] = "[[Güneydoğu Asya|GDA]]",
	['GDA'] = "[[Güneydoğu Asya|GDA]]",
	['AS'] = "[[Asya|AS]]",
	['JP'] = "[[Japonya|JP]]",
	['KR'] = "[[Güney Kore|KR]]",
	['TR'] = "[[Türkiye|TR]]",
	['SA'] = "[[Güney Amerika|GA]]",
	['GA'] = "[[Güney Amerika|GA]]",
	['OC'] = "[[Okyanusya|OK]]",
	['OK'] = "[[Okyanusya|OK]]",
	['WW'] = "<abbr title=\"Dünya çapı\">DÇ</abbr>",
	['INT'] = "<abbr title=\"Dünya çapı\">DÇ</abbr>",
	['DÇ'] = "<abbr title=\"Dünya çapı\">DÇ</abbr>",
	['?'] = "<abbr title=\"Bilinmiyor\">?</abbr>"
}

local function getLocalLabel(alias)
	local label = labels[string.upper(alias)]

	return label
end

local countryData = {}; -- Used to store country data to avoid the need of repeated calls to Modül:ÜlkeVeri. 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 (countryData[ualias] == nil) then
		local cdtable = cd.gettable(frame, alias, {})
		countryData[ualias] = cdtable['alias']
	end

	return countryData[ualias]
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 (args[3] ~= nil and args[4] == nil) then
		local item = "<span style=\"font-size:95%;\">[["
		if (args[1] ~= nil) then
			item = item .. args[1]
		end
		item = item .. "|"
		if (args[2] ~= nil) then
			item = item .. args[2]
		end
		item = item .. "]]:</span> " .. args[3] .. "[[Kategori:İki bölge parametresi kullanılan video oyunu çıkış tarihi şablonu içeren sayfalar]]"
		table.insert(items, item)
		-- Old syntax "Blank region" use case, where param 1 is empty, and param 2 is the date.
	elseif (args[1] == nil and args[2] ~= nil) then
		local item = args[2] .. "[[Kategori:Bölge parametresi kullanılmayan video oyunu çıkış tarihi şablonu içeren sayfalar]]"
		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 (args[i] and args[j]) do
			local label = getLocalLabel(args[i]);

			-- Didn't find a local label? Check for country data.
			if (label == nil) then
				label = getCountryData(frame, args[i])

				-- Found something? Build a sitelink with it.
				if (label ~= nil) then
					label = "[[" .. label .. "|" .. args[i] .. "]]"
				else
					label = args[i]
				end
			end

			local item = "<span style=\"font-size:95%;\">" .. label .. ":</span> " .. args[j]
			table.insert(items, item)

			i = i + 2
			j = j + 2
		end
	end

	-- Add known parameters of Modül:Liste to the table
	for k, v in pairs(args) do
		if (knownargs[k] == true) then
			items[k] = v
		end
	end

	local out = list.makeList(listformat, items)

	-- Set message for invalid parameters. Decide catagory based on list format chosen.
	local parameterMsg
	if (listformat == "yatay") then
		parameterMsg = "[[Kategori:Yatay listelenmiş parametreler kullanılan video oyunu çıkış tarihi şablonu içeren sayfalar|_VALUE_]]"
	else
		parameterMsg = "[[Kategori:Adlandırılmış parametreler kullanılan video oyunu çıkış tarihi şablonu içeren sayfalar|_VALUE_]]"
	end

	-- Preview message.
	if (frame:preprocess("{{REVISIONID}}") == "") then
		parameterMsg = "<div class=\"hatnote\" style=\"color:red\"><strong>Uyarı:</strong> Tanımsız \"_VALUE_\" parametresi kullanıldı (bu ileti yalnızca önizlemede gösterilir).</div>"
	end

	-- Check for invalid parameters	
	for k, v in pairs(args) do
		if (type(k) ~= 'number' and knownargs[k] ~= true) then
			local msg = parameterMsg:gsub('_VALUE_', k)
			out = out .. msg
		end
	end

	return out
end

return p