Mô đun:Aired episodes
| Mô đun này phụ thuộc vào các mô đun sau: |
Cách sử dụng
Tạo aired episodes statement tiêu chuẩn với
{{#invoke:Aired episodes|main}}
Với các tham số được xác định trong tài liệu của mẫu.
Danh mục theo dõi
local spellnum = require('Mô đun:Spellnum per MOS').spellnum
function oneEpisode(value, one_return, more_return)
return (tonumber(value) == 1 and one_return or more_return)
end
function parseNumber(value)
return tonumber(string.gsub(value, '^([%d]*).*', '%1'), 10)
end
function ordinalNumber(frame, value)
return frame:expandTemplate{title='Ordinal to word',args={tonumber(value)}}
end
local function formatVietnameseDate(year, month, day)
if not year or year == '' then return '' end
local d = tonumber(day)
local m = tonumber(month)
if d and m then
return "ngày " .. d .. " tháng " .. m .. " năm " .. year
elseif m then
return "tháng " .. m .. " năm " .. year
else
return "năm " .. year
end
end
local p = {}
function p.main(frame)
local args = require('Mô đun:Arguments').getArgs(frame, {
wrappers = 'Bản mẫu:Aired episodes'
})
args = args or {}
local airedEpisodes = ''
local function getInfoboxParam(tpl, prm)
local val = frame:expandTemplate{title='Template parameter value', args={args.showpage or args.title, tpl, 1, prm, 1}}
return (val ~= '') and val or nil
end
local numberEpisodes = args.num
or getInfoboxParam('Infobox television', 'num_episodes')
or getInfoboxParam('Thông tin truyền hình', 'số tập')
or getInfoboxParam('Thông tin truyền hình', 'num_episodes')
or getInfoboxParam('Infobox television', 'số tập')
or ''
numberEpisodes = parseNumber(numberEpisodes:gsub(",", ''))
local showName = (args.showpage and frame:expandTemplate{title='PAGENAMEBASE',args={args.showpage}} or args.title):gsub("''", '')
local isAllFinished = (args.finished == 'all')
if isAllFinished then
airedEpisodes = airedEpisodes .. 'Trong suốt thời gian phát sóng ' .. (args.uk and 'loạt phim' or 'loạt phim') .. ','
else
if args.date then
airedEpisodes = airedEpisodes .. 'Tính đến ' .. args.date .. ','
else
airedEpisodes = airedEpisodes .. frame:expandTemplate{title='Tính đến',args={args[1], args[2], args[3], post=','}}
end
end
airedEpisodes = airedEpisodes .. " ''" .. showName .. "''"
if args.released then
airedEpisodes = airedEpisodes .. ' ' .. (isAllFinished and 'được' or 'đã') .. ' phát hành'
else
airedEpisodes = airedEpisodes .. ' đã chiếu'
end
airedEpisodes = airedEpisodes .. ' tổng cộng ' .. spellnum{numberEpisodes, zero = 'no', forcenum = 'yes'} .. ' tập'
if args.specials then
airedEpisodes = airedEpisodes .. ', gồm ' .. spellnum{args.specials} .. ' tập đặc biệt' .. oneEpisode(args.specials, '', '')
end
if args.finished then
if isAllFinished then
if args.seasons then
airedEpisodes = airedEpisodes .. ' qua ' .. spellnum{args.seasons} .. ' ' .. (args.uk and 'loạt phim' or ((args.part and 'phần phim' or 'mùa phim') .. oneEpisode(args.seasons, '', '')))
end
if args[1] then
if args[4] then
airedEpisodes = airedEpisodes .. ', từ ' .. formatVietnameseDate(args[1], args[2], args[3]) .. ' đến ' .. formatVietnameseDate(args[4], args[5], args[6])
else
airedEpisodes = airedEpisodes .. ', khép lại ở ' .. formatVietnameseDate(args[1], args[2], args[3])
end
end
else
local concludedPart = (args.finished_half and 'nửa phần đầu của ' or (args.finished_part and 'phần thứ ' .. ordinalNumber(frame, args.finished_part) .. ' của ' or ''))
airedEpisodes = airedEpisodes .. ', khép lại ở ' .. concludedPart .. (args.part and 'phần phim' or args.uk and 'loạt phim' or 'mùa phim') .. ' thứ ' .. ordinalNumber(frame, args.finished)
end
elseif args.airing then
airedEpisodes = airedEpisodes .. ', hiện tại đang chiếu ở ' .. (args.part and 'phần phim' or args.uk and 'loạt phim' or 'mùa phim') .. ' thứ ' .. ordinalNumber(frame, args.airing)
end
airedEpisodes = airedEpisodes .. '.'
local title = mw.title.getCurrentTitle()
if title.namespace == 0 then
if args.showpage == args.title then
airedEpisodes = airedEpisodes .. ''
end
if args.showpage and args.title then
airedEpisodes = airedEpisodes .. ''
end
end
return airedEpisodes
end
return p