Module:Nihongo:修订间差异
无编辑摘要 |
小 (已从w:Module:Nihongo导入1个版本) |
||
| (未显示同一用户的1个中间版本) | |||
| 第62行: | 第62行: | ||
if args[4] then temp = '(' .. args[4] .. ')' end | if args[4] then temp = '(' .. args[4] .. ')' end | ||
if args[5] then temp = temp and (temp .. ' ' .. args[5]) or (' ' .. args[5]) end | if args[5] then temp = temp and (temp .. ' ' .. args[5]) or (' ' .. args[5]) end | ||
if temp then return string.format('%s<span style="font-weight: normal;">%s</ | if temp then return string.format('%s<span style="font-weight: normal;">%s</s>', ja(args[2]), temp) end | ||
return ja(args[2]) | return ja(args[2]) | ||
end | end | ||
2023年6月5日 (一) 08:22的最新版本
require('Module:No globals')
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local function ja(text)
return '<span lang="ja" xml:lang="ja">-{' .. text ..'}-</span>'
end
local function romaji(text)
return '<span lang="ja-Latn" xml:lang="ja-Latn" title="平文式罗马字">-{' .. text .. '}-</span>'
end
local function label(args, label, content)
if yesno(args.lead) then
return label .. ':' .. content
end
return content
end
local p = {}
function p.main(frame)
local args = getArgs(frame, {frameOnly = true})
return p._main(args)
end
function p._main(args)
local bracketArr, temp = {}
if args[1] then
if args[2] then table.insert(bracketArr, label(args, '[[日语]]', ja(args[2]))) end
if args['romaji'] then table.insert(bracketArr, label(args, '[[平文式罗马字|罗马字]]', romaji(args['romaji']))) end
if args[3] then table.insert(bracketArr, args[3]) end
if args[4] then table.insert(bracketArr, args[4]) end
if #bracketArr > 0 then temp = '(' .. table.concat(bracketArr, ',') .. ')' end
if args[5] then temp = temp and (temp .. ' ' .. args[5]) or (' ' .. args[5]) end
if temp then return string.format('%s<span style="font-weight: normal;">%s</span>', args[1], temp) end
return args[1]
end
if args['romaji'] then
if args[2] then table.insert(bracketArr, label(args, '[[日语]]', ja(args[2]))) end
if args[3] then table.insert(bracketArr, args[3]) end
if args[4] then table.insert(bracketArr, args[4]) end
if #bracketArr > 0 then temp = '(' .. table.concat(bracketArr, ',') .. ')' end
if args[5] then temp = temp and (temp .. ' ' .. args[5]) or (' ' .. args[5]) end
if temp then return string.format('%s<span style="font-weight: normal;">%s</span>', romaji(args.romaji), temp) end
return romaji(args.romaji)
end
if args[3] then
if args[2] then table.insert(bracketArr, label(args, '[[日语]]', ja(args[2]))) end
if args[4] then table.insert(bracketArr, args[4]) end
if #bracketArr > 0 then temp = '(' .. table.concat(bracketArr, ',') .. ')' end
if args[5] then temp = temp and (temp .. ' ' .. args[5]) or (' ' .. args[5]) end
if temp then return string.format('%s<span style="font-weight: normal;">%s</span>', args[3], temp) end
return args[3]
end
if args[2] then
if args[4] then temp = '(' .. args[4] .. ')' end
if args[5] then temp = temp and (temp .. ' ' .. args[5]) or (' ' .. args[5]) end
if temp then return string.format('%s<span style="font-weight: normal;">%s</s>', ja(args[2]), temp) end
return ja(args[2])
end
if args[4] then
if args[5] then return args[4] .. '<span style="font-weight: normal;"> ' .. args[5] .. '</span>' end
return args[4]
end
if args[5] then
return args[5]
end
return ''
end
return p