◆42Lab是非盈利性、非官方的云图计划维基百科。 ◆诚邀指挥官们加入编辑部共同建设wiki。点这里加入42Lab ◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易! ◆有任何意见、建议、纠错,欢迎在任意评论区评论 ◆编辑讨论QQ群741423564 微博@GFwiki少前百科 欢迎您 |
模块:VoiceTable
来自42LAB
- 该模块引用自mooncell 赞美R先生和友站的编辑
备注
实际使用需要参考已使用该模板的页面:分类:人形语音
该模板会生成以下三种分类: 分类:文本不全的人形语音 需要收集或听写日文语音文本 分类:语音不全的人形语音 需要上传语音文件
有信息缺失时,标题会显示为红色。
模板内每个条目:
|标题X= |日文X= |中文X= |条件X= |语音X=
- 条件X可选,放语音的开放条件,不需要加括号。其他的就算没有最好也留空。
- 换行请使用<br />
local p = {}
function p.table(frame)
local max_pieces = 50
local args = (frame == mw.getCurrentFrame() and frame.args) or frame
res_table = {}
table.insert(res_table, frame:callParserFunction{name = '#Widget:MiniAudioPlayerJS'})
local playable = ((args["可播放"] or "") ~= "")
local title = mw.text.trim(args["表格标题"] or "")
local path = mw.text.trim(args["目录"] or "")
local lack_file = false
local lack_text = false
local lack_tran = false
local table_class = playable and "wikitable" or "wikitable mw-collapsible mw-collapsed"
-- Desktop Table
table.insert(res_table, string.format("\n{|class=\"%s %s\" ", table_class, "nomobile"))
table.insert(res_table, "style=\"width:100%;line-height:18px;text-align:center;display:table;white-space:normal;\"\n")
if not playable then table.insert(res_table, string.format("|-\n! colspan=\"3\" |'''%s'''", title)) end
for i = 1, max_pieces do
local piece_title = mw.text.trim(args["标题" .. i] or "")
if piece_title ~= "" then
local piece_jp = mw.text.trim(args["日文" .. i] or "")
local piece_cn = mw.text.trim(args["中文" .. i] or "")
local piece_cond = mw.text.trim(args["条件" .. i] or "")
local piece_file = mw.text.trim(args["语音" .. i] or "")
local piece_lack_file = (piece_file == "")
local piece_lack_text = (piece_jp == "" and piece_cn == "")
local piece_lack_tran = (piece_jp ~= "" and piece_cn == "")
local piece_lack_info = piece_lack_file or piece_lack_text or piece_lack_tran
table.insert(res_table, string.format("\n|-\n!style=\"width:120px;%s\"|'''%s'''\n", (piece_lack_info and "color:#eee;" or ""), piece_title))
table.insert(res_table, "|style=\"text-align:left;\"|")
if playable and piece_jp ~= "" and piece_cn ~= "" then
table.insert(res_table, "<p lang=\"ja\" style=\"margin:5px;margin-bottom:10px\">" .. piece_jp .. "</p><p style=\"margin:5px;\">" .. piece_cn)
elseif piece_cn ~= "" then
table.insert(res_table, "<p style=\"margin:5px;\">" .. piece_cn)
else
table.insert(res_table, "<p lang=\"ja\" style=\"margin:5px;\">" .. piece_jp)
end
table.insert(res_table, ((piece_cond ~= "") and string.format("'''(%s)'''</p>", piece_cond) or "</p>"))
table.insert(res_table, string.format("\n|style=\"width:%dpx;\"|", playable and 80 or 40))
if piece_file ~= "" then
if piece_file == "-" then
table.insert(res_table, "—")
else
local piece_file_url = (path == "") and frame:callParserFunction{name = 'filepath:' .. piece_file} or (path .. piece_file)
local player_args = {icon_width = '36px', src = piece_file_url}
if piece_file_url == "" then
player_args["download_style"] = "display:none;"
player_args["play_style"] = "display:none;"
end
if not playable then player_args["download_style"] = "display:none;" end
table.insert(res_table, frame:callParserFunction{name = '#Widget:MiniAudioPlayer', args = player_args})
end
end
lack_file = lack_file or piece_lack_file
lack_text = lack_text or piece_lack_text
lack_tran = lack_tran or piece_lack_tran
end
end
table.insert(res_table, "\n|}")
-- Mobile Table
table.insert(res_table, string.format("\n{|class=\"%s %s\" ", table_class, "nodesktop"))
table.insert(res_table, "style=\"width:100%;line-height:18px;text-align:center;display:table;white-space:normal;font-size:unset;\"\n")
if not playable then table.insert(res_table, string.format("|-\n! colspan=\"2\" |'''%s'''", title)) end
for i = 1, max_pieces do
local piece_title = mw.text.trim(args["标题" .. i] or "")
if piece_title ~= "" then
local piece_jp = mw.text.trim(args["日文" .. i] or "")
local piece_cn = mw.text.trim(args["中文" .. i] or "")
local piece_cond = mw.text.trim(args["条件" .. i] or "")
local piece_file = mw.text.trim(args["语音" .. i] or "")
table.insert(res_table, string.format("\n|-\n!'''%s'''\n", piece_title))
table.insert(res_table, string.format("\n!style=\"width:%dpx;\"|", playable and 60 or 30))
if piece_file ~= "" then
local piece_file_url = frame:callParserFunction{name = 'filepath:' .. piece_file}
local player_args = {icon_width = '27px', src = piece_file_url}
if piece_file_url == "" then
player_args["download_style"] = "display:none;"
player_args["play_style"] = "display:none;"
end
if not playable then player_args["download_style"] = "display:none;" end
table.insert(res_table, frame:callParserFunction{name = '#Widget:MiniAudioPlayer', args = player_args})
end
table.insert(res_table, string.format("\n|-\n|colspan=\"%d\" style=\"text-align:left;\"|", (playable and 3 or 2)))
if playable and piece_jp ~= "" and piece_cn ~= "" then
table.insert(res_table, "<p lang=\"ja\" style=\"margin:5px;margin-bottom:10px\">" .. piece_jp .. "</p><p style=\"margin:5px;\">" .. piece_cn)
elseif piece_cn ~= "" then
table.insert(res_table, "<p style=\"margin:5px;\">" .. piece_cn)
else
table.insert(res_table, "<p lang=\"ja\" style=\"margin:5px;\">" .. piece_jp)
end
table.insert(res_table, ((piece_cond ~= "") and string.format("'''(%s)'''</p>", piece_cond) or "</p>"))
end
end
table.insert(res_table, "\n|}")
if playable then
local category = (string.find(frame:getParent():getTitle(), "用户:") == 1) and "用户自定义语音" or "人形语音"
category = mw.text.trim(args["类别"] or category)
table.insert(res_table, string.format("[[分类:%s]]", category))
if lack_file then table.insert(res_table, string.format("[[分类:语音不全的%s]]", category)) end
if lack_text then table.insert(res_table, string.format("[[分类:文本不全的%s]]", category)) end
end
return table.concat(res_table)
end
return p