模組:InfoboxImageVariant
閱讀設定
模組解[開]
你可能想去為呢個Scribunto module開一個解版。 編者可以響呢個模組嘅沙盤 (開 | 鏡)同埋試例 (開)版度試驗佢。 請加個類到個/doc嘅細版度。 呢個模組嘅細版。 |
require('strict')
local infoboxImage = require('Module:InfoboxImage').InfoboxImage
local lc = require('Module:WikitextLC').selective
local getArgs = require('Module:Arguments').getArgs
local p = {}
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p._main(args)
local variety = {'', '-hans', '-hant', '-cn', '-hk', '-mo', '-sg', '-tw'}
local varietyHans = {'-hans', '-cn', '-sg'}
local varietyHant = {'-hant', '-hk', '-mo', '-tw'}
local hansIndicator, hantIndicator = false, false
for i, v in ipairs(varietyHans) do
if args['image' .. v] then
hansIndicator = true
break
end
end
for i, v in ipairs(varietyHant) do
if args['image' .. v] then
hantIndicator = true
break
end
end
if hansIndicator and hantIndicator then
local content = {}
for i, v in ipairs(variety) do
if args['image' .. v] then
content['zh' .. v] = infoboxImage{args = {
image = args['image' .. v],
size = args['size' .. v] or args.size,
maxsize = args['maxsize' .. v] or args.maxsize,
sizedefault = args['sizedefault' .. v] or args.sizedefault,
link = args['link' .. v] or args.link,
title = args['title' .. v] or args.title,
border = args['border' .. v] or args.border,
upright = args['upright' .. v] or args.upright,
thumbtime = args['thumbtime' .. v] or args.thumbtime,
center = args['center' .. v] or args.center,
} }
end
end
return lc(content)
end
for i, v in ipairs(variety) do
if args['image' .. v] then
return infoboxImage{args = {
image = args['image' .. v],
size = args['size' .. v] or args.size,
maxsize = args['maxsize' .. v] or args.maxsize,
sizedefault = args['sizedefault' .. v] or args.sizedefault,
link = args['link' .. v] or args.link,
title = args['title' .. v] or args.title,
border = args['border' .. v] or args.border,
upright = args['upright' .. v] or args.upright,
thumbtime = args['thumbtime' .. v] or args.thumbtime,
center = args['center' .. v] or args.center,
} }
end
end
end
return p