local p = {}
local fallback_string = '<span></span>'
function p.call( rawargs )
local args = {}
for k, v in pairs(rawargs) do
local tmp = mw.text.trim(v or '')
if tmp == '' then
tmp = nil
end
args[k] = tmp
end
local mode = mw.text.trim(args.mode or '')
local strings = {
['zh-cn'] = args['zh-cn'] or args[1] or fallback_string,
['zh-tw'] = args['zh-tw'] or args[2] or fallback_string,
['zh-hk'] = args['zh-hk'] or args[3] or args[2] or fallback_string,
['zh-hans'] = args['zh-hans'] or args['zh-cn'] or args[1] or fallback_string,
['zh-hant'] = args['zh-hant'] or args['zh-tw'] or args[2] or fallback_string,
}
if args.closehkinherit then
strings['zh-hk'] = args['zh-hk'] or args[3] or fallback_string
end
if mode ~= '' then
return table.concat(
{
'-{',
mode, '|',
'zh-cn:', strings['zh-cn'],
';zh-tw:', strings['zh-tw'],
';zh-hk:', strings['zh-hk'],
';zh-hans', strings['zh-hans'],
';zh-hant', strings['zh-hant'],
'}-'
}
)
else
return table.concat(
{
'-{',
'zh-cn:', strings['zh-cn'],
';zh-tw:', strings['zh-tw'],
';zh-hk:', strings['zh-hk'],
';zh-hans', strings['zh-hans'],
';zh-hant', strings['zh-hant'],
'}-'
}
)
end
end
function p.main()
return p.call(mw.getCurrentFrame():getParent().args)
end
return p
Advertisement
Advertisement