--[=[
Implements [[Template:License scope]] and [[Template:License grammar]]
]=]
local p = {} --p stands for package
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local namespace = mw.title.getCurrentTitle().nsText
function p.plural_namespace()
local plural_namespaces = {
["Author"] = true,
["Author talk"] = true,
["Portal"] = true,
["Portal talk"] = true,
["Category"] = true,
["Category talk"] = true
}
return plural_namespaces[namespace] or false
end
--[=[
Implements [[Template:License scope]]
]=]
function p._license_scope(args)
if not args then
args = {}
end
local text
if p.plural_namespace() then
local usesome
if namespace == "Category" or namespace == "Category talk" then
usesome = yesno(args.usesome or 'no')
else
usesome = yesno(args.usesome or 'yes')
end
if usesome then
text = "Sebahagian atau semua karya "
else
text = "Karya "
end
if namespace == "Author" or namespace == "Author talk" then
text = text .. "oleh pengarang ini"
elseif namespace == "Portal" or namespace == "Portal talk" then
text = text .. "yang tersenarai pada laman portal ini"
elseif namespace == "Category" or namespace == "Category talk" then
text = text .. "dalam kategori ini"
end
elseif namespace == "File" or namespace == "File talk" then
text = "Fail ini"
elseif namespace == "Image" or namespace == "Image talk" then
text = "Imej ini"
else
text = "Karya ini"
end
local useverb = yesno(args.useverb) or args.useverb == nil
if useverb then
local past = yesno(args.past or 'no')
if past and p.plural_namespace() then
text = text .. " pernah"
elseif past then
text = text .. " pernah"
elseif p.plural_namespace() then
text = text .. " adalah"
else
text = text .. " adalah"
end
end
if yesno(args.lc or 'no') then
text = string.lower(text)
end
return text
end
function p.license_scope(frame)
return p._license_scope(getArgs(frame))
end
--[=[
Implements [[Template:License grammar]]
]=]
function p._license_grammar(args)
if not args then
args = {}
end
if p.plural_namespace() then
return args[2]
else
return args[1]
end
end
function p.license_grammar(frame)
return p._license_grammar(getArgs(frame))
end
return p