本站文本内容除另有声明外,转载时均必须注明出处,并遵守CC BY-NC-SA 3.0协议。(转载须知)
本站是中文Minecraft Wiki的镜像站,与Mojang Studios、Weird Gloop没有从属关系。(免责声明)
全站通知:
模块:Version links
刷
历
编
跳到导航
跳到搜索
local p = {}
local versionLink = require([[Module:Version link]]).link
local fullName = mw.loadData([[Module:Editions/FullName]])
local shortName = mw.loadData([[Module:Editions/ShortName]])
function p.versions(args)
local tbl = {}
local categories = {}
local nocat = args.nocat
local isShort = args.short
local catPlaceholder = args.cat or '$'
for _, v in ipairs(args) do
if v ~= '' then
local edition, number = mw.ustring.match(v, '^(%S+)%s+(.+)$')
edition = fullName[mw.ustring.lower(edition)] or edition .. '版'
local text
if isShort then
text = (shortName[edition] or edition) .. (number and ' ' .. number or '')
else
text = edition .. number
end
local link = versionLink(v, text)
table.insert(tbl, link)
if not nocat then
local cat = mw.ustring.gsub(catPlaceholder, '%$', edition)
if number then
cat = mw.ustring.gsub(cat, '#', '/' .. number)
else
cat = mw.ustring.gsub(cat, '#', '')
end
table.insert(categories, '[[Category:' .. cat .. ']]')
end
end
end
return mw.text.listToText(tbl) .. table.concat(categories)
end
function p.wrapper()
local args = require([[Module:ProcessArgs]]).merge(true)
return p.versions(args)
end
return p