--[=[
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 tag_table = mw.html.create('table'):addClass('mw-collapsible-content wst-license-tags')
for k = 1, #args, 2 do
tag_table:tag('tr')
:tag('th'):attr('scope', 'row'):wikitext(args[k])
:tag('td'):wikitext(args[k + 1])
end
-- 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 .. tostring(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 p1 = mw.html.create('p'):tag('b'):wikitext('This page does not provide license information for the ' .. scope .. '.')
local p2 = mw.html.create('p'):css({['font-size'] = '83%'}):wikitext('Pages with no license information may be nominated for deletion. If you\'d like to help, see [[Help:Copyright tags]] or [[' .. tostring(mw.title.getCurrentTitle().talkPageTitle) .. '|comment]].')
local frame = mw.getCurrentFrame()
return frame:expandTemplate {
['title'] = 'license',
['args'] = {
['image'] = 'Ambox_warning_pn.svg',
['class'] = 'warningLicenseContainer',
['text'] = tostring(p1) .. tostring(p2) .. (args.category or '')
}
}
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-4.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 = license_scope() .. " a translation and has a separate copyright status "
if namespace == "Author" or namespace == "Author talk" then
message = message .. "to some or all of the original content attributed to this author."
elseif namespace == "File" or namespace == "File talk" then
message = message .. "to the applicable copyright protections of the originating source."
else
message = message .. "to the applicable copyright protections of the original content."
end
end
-- license tags
if not original then
original = p._no_license({
['scope'] = 'original content',
['cateogry'] = categoryHandler{
['main'] = '[[Category:Works with no license template]]',
['author'] = '[[Category:Author pages with no license template]]',
['file'] = '[[Category:Files with no license template]]',
}
})
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:Translations with no license template]]'
end
translation = p._no_license({
['scope'] = 'translation',
['category'] = category
})
end
return p._license_collapsible_container({
['images'] = images,
['message'] = message,
[1] = 'Original:',
[2] = original,
[3] = 'Translation:',
[4] = translation
})
end
function p.translation_license(frame)
return p._translation_license(getArgs(frame))
end
return p