پرش به محتوا

پودمان:National squad: تفاوت میان نسخه‌ها

از ویکی‌پدیا، دانشنامهٔ آزاد
محتوای حذف‌شده محتوای افزوده‌شده
اصلاح قالب‌بندی متن عنوان جعبه (درجا)
برچسب: برگردانده‌شده
جز ویرایش Jeeputer (بحث) به آخرین تغییری که Ladsgroup انجام داده بود واگردانده شد
برچسب‌ها: واگردانی برگردانده‌شده
خط ۱: خط ۱:
-- This module implements [[Template:National squad]] and
-- This module implements [[الگو:National squad]] and
-- [[Template:National squad no numbers]] to avoid articles being added to
-- [[الگو:National squad no numbers]] to avoid articles being added to
-- [[:Category:Pages where template include size is exceeded]]
-- [[:Category:Pages where template include size is exceeded]]
-- when the template is used many times.
-- when the template is used many times.
local p = {}
local p = {}

local setFarsiArguments = require('Module:Set Farsi argument names')
local numConv = require('Module:Numeral converter').convert

local prefixes = {
local prefixes = {
['male'] = ' مردان',
['male'] = ' men\'s',
['men'] = ' مردان',
['men'] = ' men\'s',
['mens'] = ' مردان',
['mens'] = ' men\'s',
['men\'s'] = ' مردان',
['men\'s'] = ' men\'s',
['مرد'] = 'مردان',
['زنان'] = ' زنان',
['مردان'] = 'مردان',
['زنان'] = ' زنان',
['female'] = ' زنان',
['زنان'] = ' زنان',
['women'] = ' زنان',
['زنان'] = ' زنان',
['womens'] = ' زنان',
['women\'s'] = ' زنان',
['زن'] = 'زنان',
['زنان'] = 'زنان',
[''] = ''
[''] = ''
}
}
خط ۲۶: خط ۱۸:
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame, {parentFirst = true})
local args = getArgs(frame, {parentFirst = true})
local country = args.country or '{{{country}}}'
setFarsiArguments(
args,
{
['country'] = 'کشور', ['coach_type'] = 'نوع مربی',
['comp'] = 'رقابت', ['sport'] = 'ورزش',
['gender'] = 'جنسیت', ['bg'] = 'پس‌زمینه',
['fg'] = 'روی زمینه', ['bordercolor'] = 'رنگ حاشیه',
['flagvar'] = 'گونه پرچم', ['team link'] = 'پیوند تیم',
['title'] = 'عنوان', ['comp link'] = 'پیوند رقابت',
['list'] = 'فهرست', ['name'] = 'نام',
['nonumbers'] = 'بدون عدد', ['note'] = 'یادداشت',
['coach'] = 'مربی'
}
)
local country = args.country or '{{{کشور}}}'
local coach_label = args.coach_type or 'مربی'
local coach_label = args.coach_type or 'مربی'
local comp = args.comp or '{{{رقابت}}}'
local comp = args.comp or '{{{comp}}}'
local sport = args.sport or 'فوتبال'
local sport = args.sport or 'football'
local gender = prefixes[args.gender or ''] or ''
local gender = prefixes[args.gender or ''] or ''
local titlestyle = 'background-color:' .. (args.bg or 'transparent') .. ';'
local titlestyle = 'background-color:' .. (args.bg or 'transparent') .. ';'
.. 'color:' .. (args.fg or 'inherit') .. ';'
.. 'color:' .. (args.fg or 'inherit') .. ';'
.. 'border:1px solid ' .. (args.bordercolor or '#aaa')
.. 'border: 1px solid ' .. (args.bordercolor or '#aaa') .. ';'
local image = (args.country ~= 'Unified Team' and args.country ~= 'تیم متحد') and require('Module:Flagg').luaMain(frame, {
local image = args.country ~= 'Unified Team' and frame:expandTemplate{
'cxxl',
title = 'flagicon',
args.country or 'none',
args = {args.country or 'none', args.flagvar or '', size = '50px'}
} or frame:expandTemplate{
args.flagvar,
size = '50px'
}) or frame:expandTemplate{
title = 'flagicon image',
title = 'flagicon image',
args = {'Olympic flag.svg', size = '50px'}
args = {'Olympic flag.svg', size = '50px'}
خط ۶۳: خط ۳۶:
local ospan = '<span style="color:' .. (args.fg or 'inherit') .. '">'
local ospan = '<span style="color:' .. (args.fg or 'inherit') .. '">'
local cspan = '</span>'
local cspan = '</span>'
local title = mw.ustring.format('[[%s|%s%s%s]] – [[%s|%s%s%s]]',
local title = string.format('[[%s|%s%s%s]] – [[%s|%s%s%s]]',
args['team link'] or ('تیم ملی ' .. sport .. ' ' .. gender .. ' ' .. country),
args['team link'] or ('تیم ملی ' .. sport .. gender .. ' ' .. country),
ospan, args.title or 'ترکیب تیم ' .. country, cspan,
ospan, args.title or 'تیم ' .. country, cspan,
args['comp link'] or comp, ospan, comp, cspan)
args['comp link'] or comp, ospan, comp, cspan)
خط ۷۳: خط ۴۶:
local knownargs = {['bg']=1, ['fg']=1, ['bordercolor']=1, ['coach']=1, ['coach_type']=1,
local knownargs = {['bg']=1, ['fg']=1, ['bordercolor']=1, ['coach']=1, ['coach_type']=1,
['comp']=1, ['comp link']=1, ['country']=1, ['flagvar']=1, ['gender']=1,
['comp']=1, ['comp link']=1, ['country']=1, ['flagvar']=1, ['gender']=1,
['list']=1, ['name']=1, ['nonumbers'] = 1, ['note']=1, ['sport']=1, ['team link']=1, ['title']=1,
['list']=1, ['name']=1, ['nonumbers'] = 1, ['note']=1, ['sport']=1, ['team link']=1, ['title']=1}
['پس‌زمینه']=1, ['روی زمینه']=1, ['مربی']=1, ['نوع مربی']=1, ['پیوند رقابت']=1, ['کشور']=1,
['گونه پرچم']=1, ['جنسیت']=1, ['رقابت']=1, ['نام']=1, ['بدون عدد']=1, ['یادداشت']=1,
['ورزش']=1, ['پیوند تیم']=1, ['عنوان']=1, ['فهرست']=1, ['رنگ حاشیه']=1
}
local badargs = {}
local badargs = {}
local numlist = {}
local numlist = {}
خط ۸۳: خط ۵۲:
if knownargs[k] then
if knownargs[k] then
elseif type(k) == 'string' then
elseif type(k) == 'string' then
local n = tonumber(mw.ustring.match(k, '^p(%d+)$') or
local n = tonumber(k:match('^p(%d+)$') or k:match('pos(%d+)') or '-1')
mw.ustring.match(k, 'pos(%d+)') or
if k:match('^p%d+$') and n >= 0 and n <= 99 then
numConv('en', mw.ustring.match(k, '^ب(%d+)$') or mw.ustring.match(k, 'پ(%d+)')) or
table.insert(numlist, k:match('^p(%d+)$'))
elseif args.nonumbers and (k:match('^pos%d+$') and n >= 0 and n <= 99) then
'-1'
)
if (mw.ustring.match(k, '^p%d+$') or mw.ustring.match(k, '^ب%d+$')) and n >= 0 and n <= 99 then
table.insert(numlist, (mw.ustring.match(k, '^p(%d+)$') or numConv('en', mw.ustring.match(k, '^ب(%d+)$'))))
elseif args.nonumbers and ((mw.ustring.match(k, '^pos%d+$') or mw.ustring.match(k, '^پ%d+$')) and n >= 0 and n <= 99) then
if v and v ~= '' then haspos = true end
if v and v ~= '' then haspos = true end
elseif v and v ~= '' then
elseif v and v ~= '' then
خط ۱۱۰: خط ۷۵:
for k, v in pairs(badargs) do
for k, v in pairs(badargs) do
if v == '' then v = ' ' end
if v == '' then v = ' ' end
v = mw.ustring.gsub(v, '[^%w\\-_ ]', '؟')
v = mw.ustring.gsub(v, '[^%w\-_ ]', '?')
preview = preview .. pv._warning({
preview = preview .. pv._warning({
'Page using national squad with unknown parameter "' .. v .. '".'
'این صفحه از [[الگو:تیم ملی]] با پارامتر نامعلوم «' .. v .. '» استفاده می‌کند.'
})
})
tracking = tracking .. '[[رده:صفحه‌هایی که از تیم ملی با پارامترهای نامعلوم استفاده می‌کنند|' .. v .. ']]'
tracking = tracking .. '[[Category:Pages using national squad with unknown parameters|' .. v .. ']]'
end
end
end
end
if (args['title'] == nil and args['team link'] == nil and args.country == nil) or args.comp == nil then
if (args['title'] == nil and args['team link'] == nil and args.country == nil) or args.comp == nil then
tracking = tracking .. '[[رده:صفحه‌هایی که از تیم ملی با پارامترهای نامعلوم استفاده می‌کنند|!]]'
tracking = tracking .. '[[Category:Pages using national squad with unknown parameters|!]]'
end
end
if not args['comp link'] then
if not args['comp link'] then
tracking = tracking .. '[[رده:صفحه‌هایی که از تیم ملی بدون پیوند رقابت استفاده می‌کنند]]'
tracking = tracking .. '[[Category:Pages using national squad without comp link]]'
end
end
if not args['sport'] then
if not args['sport'] then
if not args['team link'] then
if not args['team link'] then
tracking = tracking .. '[[رده:صفحه‌هایی که از تیم ملی بدون ورزش یا پیوند تیم استفاده می‌کنند]]'
tracking = tracking .. '[[Category:Pages using national squad without sport or team link]]'
end
end
end
end
if sport ~= 'football' and sport ~= 'futsal' and sport ~= 'basketball' and
if sport ~= 'football' and sport ~= 'futsal' and sport ~= 'basketball' then
sport ~= 'فوتبال' and sport ~= 'فوتسال' and sport ~= 'بسکتبال' then
if not args['team link'] then
if not args['team link'] then
local sortkey = mw.ustring.gsub(sport, '[^A-Za-zا-ی]', ' ')
local sortkey = mw.ustring.gsub(sport, '[^A-Za-z]', ' ')
tracking = tracking .. '[[رده:صفحه‌هایی که از تیم ملی بدون پیوند تیم و با یک ورزش غیر معمول استفاده می‌کنند|' .. sortkey .. ' ]]'
tracking = tracking .. '[[Category:Pages using national squad without team link and with an atypical sport|' .. sortkey .. ' ]]'
end
end
end
end
if prefixes[args.gender or ''] == nil then
if prefixes[args.gender or ''] == nil then
tracking = tracking .. '[[رده:صفحه‌هایی که از تیم ملی با جنسیت پشتیبانی‌نشده استفاده می‌کنند]]'
tracking = tracking .. '[[Category:Pages using national squad with unsupported gender]]'
end
end
if args.name == nil then
if args.name == nil then
tracking = tracking .. '[[رده:صفحه‌هایی که از تیم ملی بدون نام استفاده می‌کنند]]'
tracking = tracking .. '[[Category:Pages using national squad without name]]'
end
end
-- if tracking ~= '' and mw.title.getCurrentTitle().namespace > 0 then tracking = '' end
-- if tracking ~= '' and mw.title.getCurrentTitle().namespace > 0 then tracking = '' end
خط ۱۴۶: خط ۱۱۰:
if list1 == '' then
if list1 == '' then
for i,k in ipairs(numlist) do
for i,k in ipairs(numlist) do
if args['p' .. k] or args['ب' .. numConv('fa', k)] then
if args['p' .. k] then
local n = args.nonumbers and (args['pos' .. k] or args['پ' .. numConv('fa', k)] or '') or tostring(k)
local n = args.nonumbers and (args['pos' .. k] or '') or tostring(k)
if n ~= '' or haspos == true then
if n ~= '' or haspos == true then
list1 = list1 .. mw.ustring.format(
list1 = list1 .. string.format(
'*%s&nbsp;<span class="vcard agent"><span class="fn">%s</span></span>\n',
'*%s&nbsp;<span class="vcard agent"><span class="fn">%s</span></span>\n',
numConv('fa', n), args['p' .. k] or args['ب' .. numConv('fa', k)])
n, args['p' .. k])
else
else
list1 = list1 .. mw.ustring.format(
list1 = list1 .. string.format(
'*<span class="vcard agent"><span class="fn">%s</span></span>\n', args['p' .. k])
'*<span class="vcard agent"><span class="fn">%s</span></span>\n', args['p' .. k])
end
end
خط ۱۵۹: خط ۱۲۳:
end
end
if args.coach then
if args.coach then
list1 = list1 .. mw.ustring.format(
list1 = list1 .. string.format(
'*<span class="vcard agent">%s:&nbsp;<span class="fn">%s</span></span>',
'*<span class="vcard agent">%s:&nbsp;<span class="fn">%s</span></span>',
coach_label, args.coach)
coach_label, args.coach)

نسخهٔ ‏۱۶ ژوئن ۲۰۲۴، ساعت ۱۵:۱۰

توضیحات پودمان[ایجاد] [پاکسازی]
-- This module implements [[الگو:National squad]] and 
-- [[الگو:National squad no numbers]] to avoid articles being added to 
-- [[:Category:Pages where template include size is exceeded]]
-- when the template is used many times.
local p = {}
local prefixes = {
	['male'] = ' men\'s',
	['men'] = ' men\'s',
	['mens'] = ' men\'s',
	['men\'s'] = ' men\'s',
	['زنان'] = ' زنان',
	['زنان'] = ' زنان',
	['زنان'] = ' زنان',
	['زنان'] = ' زنان',
	[''] = ''
}
function p.main(frame)
	local getArgs = require('Module:Arguments').getArgs
	local args = getArgs(frame, {parentFirst = true})
	local country = args.country or '{{{country}}}'
	local coach_label = args.coach_type or 'مربی'
	local comp = args.comp or '{{{comp}}}'
	local sport = args.sport or 'football'
	local gender = prefixes[args.gender or ''] or ''
	local titlestyle = 'background-color:' .. (args.bg or 'transparent') .. ';'
		.. 'color:' .. (args.fg or 'inherit') .. ';' 
		.. 'border: 1px solid ' .. (args.bordercolor or '#aaa') .. ';'
	local image = args.country ~= 'Unified Team' and frame:expandTemplate{
		title = 'flagicon', 
		args = {args.country or 'none', args.flagvar or '', size = '50px'}
	} or frame:expandTemplate{
		title = 'flagicon image', 
		args = {'Olympic flag.svg', size = '50px'}
	}

	local ospan = '<span style="color:' .. (args.fg or 'inherit') .. '">'
	local cspan = '</span>'	
	local title = string.format('[[%s|%s%s%s]] – [[%s|%s%s%s]]', 
		args['team link'] or ('تیم ملی ' .. sport .. gender .. ' ' .. country), 
		ospan, args.title or 'تیم ' .. country, cspan, 
		args['comp link'] or comp, ospan, comp, cspan)
	
	local haspos = false
	
	-- Tracking and preview warnings
	local knownargs = {['bg']=1, ['fg']=1, ['bordercolor']=1, ['coach']=1, ['coach_type']=1,
		['comp']=1, ['comp link']=1, ['country']=1, ['flagvar']=1, ['gender']=1, 
		['list']=1, ['name']=1, ['nonumbers'] = 1, ['note']=1, ['sport']=1, ['team link']=1, ['title']=1}
	local badargs = {}
	local numlist = {}
	for k, v in pairs(args) do
		if knownargs[k] then
		elseif type(k) == 'string' then
			local n = tonumber(k:match('^p(%d+)$') or k:match('pos(%d+)') or '-1')
			if k:match('^p%d+$') and n >= 0 and n <= 99 then
				table.insert(numlist, k:match('^p(%d+)$'))
			elseif args.nonumbers and (k:match('^pos%d+$') and n >= 0 and n <= 99) then
				if v and v ~= '' then haspos = true end
			elseif v and v ~= '' then
				table.insert(badargs, k)
			end
		elseif v and v ~= '' then
			table.insert(badargs, k)
		end
	end
	table.sort(
		numlist,
		function (a, b) 
			return tonumber(a) < tonumber(b) or (tonumber(a) == tonumber(b) and #a > #b)
		end
	)
	local pv = require('Module:If preview')
	local preview, tracking = '', ''
	if #badargs > 0 then
		for k, v in pairs(badargs) do
			if v == '' then	v = ' '	end
			v = mw.ustring.gsub(v, '[^%w\-_ ]', '?')
			preview = preview .. pv._warning({
				'Page using national squad with unknown parameter "' .. v .. '".'
			})
			tracking = tracking .. '[[Category:Pages using national squad with unknown parameters|' .. v .. ']]'
		end
	end
	if (args['title'] == nil and args['team link'] == nil and args.country == nil) or args.comp == nil then
		tracking = tracking .. '[[Category:Pages using national squad with unknown parameters|!]]'
	end
	if not args['comp link'] then
		tracking = tracking .. '[[Category:Pages using national squad without comp link]]'
	end
	if not args['sport'] then
		if not args['team link'] then
			tracking = tracking .. '[[Category:Pages using national squad without sport or team link]]'
		end
	end
	if sport ~= 'football' and sport ~= 'futsal' and sport ~= 'basketball' then
		if not args['team link'] then
			local sortkey = mw.ustring.gsub(sport, '[^A-Za-z]', ' ')
			tracking = tracking .. '[[Category:Pages using national squad without team link and with an atypical sport|' .. sortkey .. ' ]]'
		end
	end
	if prefixes[args.gender or ''] == nil then
		tracking = tracking .. '[[Category:Pages using national squad with unsupported gender]]'
	end
	if args.name == nil then
		tracking = tracking .. '[[Category:Pages using national squad without name]]'
	end
	-- if tracking ~= '' and mw.title.getCurrentTitle().namespace > 0 then tracking = '' end
	
	local list1 = args.list or ''
	if list1 == '' then
		for i,k in ipairs(numlist) do
			if args['p' .. k] then
				local n = args.nonumbers and (args['pos' .. k] or '') or tostring(k)
				if n ~= '' or haspos == true then
					list1 = list1 .. string.format(
						'*%s&nbsp;<span class="vcard agent"><span class="fn">%s</span></span>\n',
						n, args['p' .. k])
				else
					list1 = list1 .. string.format(
						'*<span class="vcard agent"><span class="fn">%s</span></span>\n', args['p' .. k])
				end
			end
		end
		if args.coach then
			list1 = list1 .. string.format(
				'*<span class="vcard agent">%s:&nbsp;<span class="fn">%s</span></span>',
				coach_label, args.coach)
		end
	end
	local list3 = args.note and ('' .. args.note .. '') or nil
	
	return require('Module:Navbox')._navbox({
		name = args.name,
		titlestyle = titlestyle, 
		listclass = 'hlist', bodyclass = 'vcard', titleclass = 'fn org',
		image = image, title = title, list1 = list1, list3 = list3
	}) .. tracking .. preview
end

return p