模块:SoftwareInfo:修订间差异
来自陋室
更多操作
删除的内容 添加的内容
Maintenance script(留言 | 贡献) 阶段C原型:新增Module:SoftwareInfo(修复语法) |
Maintenance script(留言 | 贡献) 阶段C切换:增强Module:SoftwareInfo并支持主模板 |
||
| 第29行: | 第29行: | ||
end |
end |
||
function |
local function languageDisplay(code) |
||
code = trim(code) |
|||
if code == '' then |
|||
return '未知' |
|||
end |
|||
local ok, name = pcall(function() |
|||
return mw.language.fetchLanguageName(code, 'zh') |
|||
end) |
|||
if ok and name and trim(name) ~= '' then |
|||
return name |
|||
end |
|||
return code |
|||
end |
|||
local function renderCore(frame, toolTemplate, toolTarget) |
|||
local args = frame.args or {} |
local args = frame.args or {} |
||
local out = {} |
local out = {} |
||
| 第47行: | 第61行: | ||
addRow(out, "'''文件大小:'''", v(args, '大小', '未知')) |
addRow(out, "'''文件大小:'''", v(args, '大小', '未知')) |
||
addRow(out, "'''更新日期:'''", v(args, '更新日期', '未知')) |
addRow(out, "'''更新日期:'''", v(args, '更新日期', '未知')) |
||
addRow(out, "'''语言:'''", |
addRow(out, "'''语言:'''", languageDisplay(args['语言'])) |
||
addRow(out, "'''支持系统:'''", v(args, '系统', '未知')) |
addRow(out, "'''支持系统:'''", v(args, '系统', '未知')) |
||
addRow(out, "'''支持架构:'''", v(args, '架构', '未知')) |
addRow(out, "'''支持架构:'''", v(args, '架构', '未知')) |
||
| 第67行: | 第81行: | ||
table.insert(out, frame:expandTemplate { |
table.insert(out, frame:expandTemplate { |
||
title = |
title = toolTemplate, |
||
args = { |
args = { |
||
target = |
target = toolTarget, |
||
parent = |
parent = toolTarget, |
||
} |
} |
||
}) |
}) |
||
return table.concat(out, '\n') |
return table.concat(out, '\n') |
||
end |
|||
function p.render(frame) |
|||
return renderCore(frame, 'PageToolsLink', 'Template:SoftwareInfo') |
|||
end |
|||
function p.renderSandbox(frame) |
|||
return renderCore(frame, 'PageToolsLink/sandbox', 'Template:SoftwareInfo/sandbox') |
|||
end |
end |
||