Module:License scope

विकिस्रोत से

"इस मॉड्यूल हेतु प्रलेख Module:License scope/doc पर बनाया जा सकता है"

--[=[
Implements [[साँचा:License scope]] and [[साँचा: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 = {
		["लेखक"] = true,
		["लेखक वार्ता"] = true,
		["Portal"] = true,
		["Portal talk"] = true,
		["श्रेणी"] = true,
		["श्रेणी वार्ता"] = 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 == "श्रेणी" or namespace == "श्रेणी वार्ता" then
			usesome = yesno(args.usesome or 'no')
		else
			usesome = yesno(args.usesome or 'yes')
		end
		if usesome then
			text = "कुछ अथवा सभी कार्य "
		else
			text = "कार्य "
		end
		if namespace == "लेखक" or namespace == "लेखक वार्ता" then
			text = text .. "जो इस लेखक द्वारा लिखित हैं"
		elseif namespace == "Portal" or namespace == "Portal talk" then
			text = text .. "listed in this portal"
		elseif namespace == "श्रेणी" or namespace == "श्रेणी वार्ता" then
			text = text .. "जो इस श्रेणी में रखे गए हैं"
		end
	elseif namespace == "File" or namespace == "File talk" then
		text = "यह फ़ाइल"
	elseif namespace == "Image" or namespace == "Image talk" then
		text = "यह चित्र"
	else
		text = "यह कार्य"
	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 .. " "
		elseif past then
			text = text .. " "
		elseif p.plural_namespace() then
			text = text .. " "
		else
			text = text .. " "
		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 [[साँचा: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