تضامنًا مع حق الشعب الفلسطيني |
وحدة:National squad
توثيق الوحدة[أنشئ] [محو الاختزان][استخدامات] [قوالب]
-- This module implements [[Template:National squad]] and
-- [[Template: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'] = ' رجال',
['mens'] = ' رجال',
['men\'s'] = ' رجال',
['رجال'] = ' رجال',
['سادة'] = ' رجال',
['سيدات'] = ' سيدات',
['female'] = ' سيدات',
['women'] = ' سيدات',
['womens'] = ' سيدات',
['women\'s'] = ' سيدات',
[''] = ''
}
local i18nCat = {
['unknown parameters'] = 'Category:Pages using national squad with unknown parameters',
['without comp link'] = 'Category:Pages using national squad without comp link',
['without sport or team link'] = 'Category:Pages using national squad without sport or team link',
['without team link and with an atypical sport'] = 'Category:Pages using national squad without team link and with an atypical sport',
['unsupported gender'] = 'Category:Pages using national squad with unsupported gender',
['without name'] = 'Category:Pages using national squad without name',
}
function p._main(args)
local frame = mw.getCurrentFrame()
local country = args.country or '{{{الدولة}}}'
local coach_label = args.coach_type or 'المدرب'
local comp = args.comp or '{{{المنافسة}}}'
local sport = args.sport or 'كرة القدم'
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 (country .. gender .. ' national ' .. sport .. ' team'),
ospan, args.title or country .. ' squad', 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 .. '[['..i18nCat['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 .. '[['..i18nCat['unknown parameters']..'|!]]'
end
if not args['comp link'] then
tracking = tracking .. '[['..i18nCat['without comp link']..']]'
end
if not args['sport'] then
if not args['team link'] then
tracking = tracking .. '[['..i18nCat['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 .. '[['..i18nCat['without team link and with an atypical sport']..'|' .. sortkey .. ' ]]'
end
end
if prefixes[args.gender or ''] == nil then
tracking = tracking .. '[['..i18nCat['unsupported gender']..']]'
end
if args.name == nil then
tracking = tracking .. '[['..i18nCat['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 <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: <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
function p.main(frame)
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame, {parentFirst = true})
local args1 = {
["name"] = args["name"] or args["الاسم"]
, ["bg"] = args["bg"] or args["لون الخلفية"]
, ["fg"] = args["fg"] or args["لون النص"]
, ["bordercolor"] = args["bordercolor"] or args["لون الحد"]
, ["sport"] = args["sport"] or args["الرياضة"]
, ["country"] = args["country"] or args["الدولة"]
, ["flagvar"] = args["flagvar"] or args["نوع العلم"]
, ["team link"] = args["team link"] or args["رابط الفريق"] or args["وصلة الفريق"]
, ["title"] = args["title"] or args["العنوان"]
, ["comp"] = args["comp"] or args["المنافسة"]
, ["comp link"] = args["comp link"] or args["رابط المنافسة"] or args["وصلة المنافسة"]
, ["gender"] = args["gender"] or args["الجنس"]
, ["p1"] = args["p1"] or args["player 1"] or args["اللاعب 1"] or args["اللاعب رقم 1"]
, ["p2"] = args["p2"] or args["player 2"] or args["اللاعب 2"] or args["اللاعب رقم 2"]
, ["p3"] = args["p3"] or args["player 3"] or args["اللاعب 3"] or args["اللاعب رقم 3"]
, ["p4"] = args["p4"] or args["player 4"] or args["اللاعب 4"] or args["اللاعب رقم 4"]
, ["p5"] = args["p5"] or args["player 5"] or args["اللاعب 5"] or args["اللاعب رقم 5"]
, ["p6"] = args["p6"] or args["player 6"] or args["اللاعب 6"] or args["اللاعب رقم 6"]
, ["p7"] = args["p7"] or args["player 7"] or args["اللاعب 7"] or args["اللاعب رقم 7"]
, ["p8"] = args["p8"] or args["player 8"] or args["اللاعب 8"] or args["اللاعب رقم 8"]
, ["p9"] = args["p9"] or args["player 9"] or args["اللاعب 9"] or args["اللاعب رقم 9"]
, ["p10"] = args["p10"] or args["player 10"] or args["اللاعب 10"] or args["اللاعب رقم 10"]
, ["p11"] = args["p11"] or args["player 11"] or args["اللاعب 11"] or args["اللاعب رقم 11"]
, ["p12"] = args["p12"] or args["player 12"] or args["اللاعب 12"] or args["اللاعب رقم 12"]
, ["p13"] = args["p13"] or args["player 13"] or args["اللاعب 13"] or args["اللاعب رقم 13"]
, ["p14"] = args["p14"] or args["player 14"] or args["اللاعب 14"] or args["اللاعب رقم 14"]
, ["p15"] = args["p15"] or args["player 15"] or args["اللاعب 15"] or args["اللاعب رقم 15"]
, ["p16"] = args["p16"] or args["player 16"] or args["اللاعب 16"] or args["اللاعب رقم 16"]
, ["p17"] = args["p17"] or args["player 17"] or args["اللاعب 17"] or args["اللاعب رقم 17"]
, ["p18"] = args["p18"] or args["player 18"] or args["اللاعب 18"] or args["اللاعب رقم 18"]
, ["p19"] = args["p19"] or args["player 19"] or args["اللاعب 19"] or args["اللاعب رقم 19"]
, ["p20"] = args["p20"] or args["player 20"] or args["اللاعب 20"] or args["اللاعب رقم 20"]
, ["p21"] = args["p21"] or args["player 21"] or args["اللاعب 21"] or args["اللاعب رقم 21"]
, ["p22"] = args["p22"] or args["player 22"] or args["اللاعب 22"] or args["اللاعب رقم 22"]
, ["p23"] = args["p23"] or args["player 23"] or args["اللاعب 23"] or args["اللاعب رقم 23"]
, ["coach"] = args["coach"] or args["المدرب"]
, ["note"] = args["note"] or args["ملاحظة"]
}
return p._main(args1)
end
return p