Module:Translation license/sandbox
Appearance
This is the module sandbox page for Module:Translation license (diff). |
This module depends on the following other modules: |
Implements {{translation license}}.
--[=[
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 = "<p>'''This page does not provide license information for the " .. scope .. ".'''</p><p style='font-size:83%;'>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]].</p>" .. 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 = 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