پودمان:Sports career/تمرین
ظاهر
اینجا صفحهٔ تمرین پودمان برای پودمان:Sports career (تفاوت) است. |
بخش "پیشینهٔ کاری" در الگو:Infobox baseball biography را ارائه میدهد.
-- این پودمان برای استفاده از پارامترهای فارسی بومیسازی شدهاست. در زمان بهروزرسانی دقت کنید
local p = {}
local numCon = require('Module:Numeral converter').convert
local function isnotempty(s)
return s and mw.ustring.match(s, '%S')
end
function p.main(frame)
local player = {}
local coach = {}
local pargs = frame:getParent().args
local tracking = ''
local iargs = {}
local lang = mw.language
local pmax = tonumber(frame.args['pmax'] or (frame.args['بیشینه بازیکن'] and numCon('fa', frame.args['بیشینه بازیکن']) or false) or '40') or 40
local cmax = tonumber(frame.args['cmax'] or (frame.args['بیشینه مربیگری'] and numCon('fa', frame.args['بیشینه مربیگری']) or false) or '30') or 30
for k,v in pairs(pargs) do
if type(k) == 'string' and isnotempty(v) then
if string.match(k, '^team%d%d*$') then
local num = string.gsub(k,'^team(%d%d*)$','%1')
table.insert(player, {num or 0, pargs['years' .. num] or '', v})
elseif mw.ustring.match(k, '^تیم%d%d*$') then -- We are using Persian parameters
local num = mw.ustring.gsub(k,'^تیم(%d%d*)$','%1')
table.insert(player, {numCon('en', num) or 0, pargs['سالها' .. num] or '', v})
elseif string.match(k, '^cteam%d%d*$') then
local num = string.gsub(k,'^cteam(%d%d*)$','%1')
table.insert(coach, {num or 0, pargs['cyears' .. num] or '', v})
elseif mw.ustring.match(k, '^تیم مربیگری%d%d*$') then -- We are using Persian parameters
local num = mw.ustring.gsub(k,'^تیم مربیگری(%d%d*)$','%1')
table.insert(coach, {numCon('en', num) or 0, pargs['سالهای مربیگری' .. num] or '', v})
end
end
end
table.sort(player, function (a, b) return a[1] < b[1] end)
table.sort(coach, function (a, b) return a[1] < b[1] end)
local i = 1
if #player > 0 then
iargs['header' .. i] = frame.args['pheader'] or frame.args['سرآیند بازیکن'] or 'بهعنوان بازیکن:'
i = i + 1
for k,v in ipairs(player) do
if v[2] ~= '' then iargs['label' .. i] = v[2] end
if v[3] ~= '' then iargs['data' .. i] = v[3] end
i = i + 1
end
end
if #coach > 0 then
iargs['header' .. i] = frame.args['cheader'] or frame.args['سرآیند مربیگری'] or 'بهعنوان مربی:'
i = i + 1
for k,v in ipairs(coach) do
if v[2] ~= '' then iargs['label' .. i] = v[2] end
if v[3] ~= '' then iargs['data' .. i] = v[3] end
i = i + 1
end
end
if i > 1 then
iargs['child'] = 'yes'
iargs['labelstyle'] = 'font-weight: normal;' .. (frame.args['yearstyle'] or frame.args['سبک سال'] or '')
iargs['headerstyle'] = 'line-height: 1.2em;text-align: right;' .. (frame.args['headerstyle'] or frame.args['سبک سرآیند'] or '')
iargs['datastyle'] = 'line-height: 1.2em;text-align: right;' .. (frame.args['teamstyle'] or frame.args['سبک تیم'] or '')
if #player > pmax then
tracking = tracking .. (frame.args['pmaxcat'] or '')
end
if #coach > cmax then
tracking = tracking .. (frame.args['cmaxcat'] or '')
end
return (frame.args['title'] or frame.args['عنوان'] or 'تاریخچهٔ حرفه') .. require('Module:Infobox').infobox(iargs) .. tracking
end
return tracking
end
return p