Module:Translation license
外观
模块文档[创建]
您可能想要创建本Scribunto模块的文档。 编者可以在本模块的沙盒 (创建 | 镜像)和测试样例 (创建)页面进行实验。 请在/doc子页面中添加分类。 本模块的子页面。 |
--[=[
Implements [[Template:Translation license]]
]=]
local p = {} --p stands for package
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local license_scope = require('Module:License_scope')._license_scope
local categoryHandler = require('Module:Category handler').main
local namespace = mw.title.getCurrentTitle().nsText
function p._license_collapsible_container(args)
-- license table
local license_rows = {}
for k = 1, #args, 2 do
local header = args[k] or ''
local license = args[k + 1] or ''
license_rows[(k + 1)/2] = '<tr><th scope="row">' .. header .. '</th><td>' .. license .. '</td></tr>'
end
local tag_table = '<table id="licenseTags" class="mw-collapsible-content">' .. table.concat(license_rows, '') .. '</table>'
-- license container
local frame = mw.getCurrentFrame()
local container_begin = frame:expandTemplate {
['title'] = 'License container begin',
['args'] = {
['images'] = args.images,
['message'] = args.message
}
}
local container_end = frame:expandTemplate {
['title'] = 'License container end'
}
return container_begin .. tag_table .. container_end
end
function p.license_collapsible_container(frame)
return p._license_collapsible_container(getArgs(frame))
end
function p._no_license(args)
local scope = args.scope or 'content'
local category = args.category or ''
local text = "'''''本譯文沒有提供版權許可信息,可能刪除。'''有意協助者,請參見[[Wikisource:版权信息|本文库的版权信息指南]]或者[[" .. tostring(mw.title.getCurrentTitle().talkPageTitle) .. "|討論]]。''" .. category
local frame = mw.getCurrentFrame()
return frame:expandTemplate {
['title'] = 'license',
['args'] = {
['image'] = 'Ambox_warning_pn.svg',
['class'] = 'warningLicenseContainer',
['text'] = text
}
}
end
function p.no_license(frame)
return p._no_license(getArgs(frame))
end
function p._translation_license(args)
local frame = mw.getCurrentFrame()
local original = args.original
local translation = args.translation
local trans_ns = namespace == "Translation" or namespace == "Translation talk"
if not translation and trans_ns then
translation = frame:expandTemplate {
['title'] = 'GFDL/CC-BY-SA-3.0'
}
end
-- images in title
local images
if not (original and translation) then
images = '[[File:Copyright.svg|20px|link=]][[File:Achtung.svg|20px|link=]]'
end
-- text in title
local message = args.message
if not message then
message = "本译文与其原文有分别的版权许可。译文版权状况仅适用于本版本。"
end
-- license tags
if not original then
original = p._no_license({
['scope'] = '原文',
['cateogry'] = categoryHandler{
['main'] = '[[Category:怀疑侵犯版权文章]]'
}
})
end
if not translation then
local category
local noCatNamespaces = {
['Help'] = true,
['Help talk'] = true,
['Template'] = true,
['Template talk'] = true,
['Wikisource'] = true,
['Wikisource talk'] = true,
['Category'] = true,
['Category talk'] = true,
['Module'] = true,
['Module talk'] = true
}
if not noCatNamespaces[namespace] then
category = '[[Category:怀疑侵犯版权文章]]'
end
translation = p._no_license({
['scope'] = '译文 ',
['category'] = category
})
end
return p._license_collapsible_container({
['images'] = images,
['message'] = message,
[1] = '原文',
[2] = original,
[3] = '译文',
[4] = translation
})
end
function p.translation_license(frame)
return p._translation_license(getArgs(frame))
end
return p