وحدة:PD-US

من ويكي مصدر، المكتبة الحرة
--[=[
Implements [[Template:PD-US]]
]=]

local p = {} --p stands for package

local getArgs = require('Module:Arguments').getArgs
local PD = require('Module:PD')
local license_scope = require('Module:License_scope')._license_scope
local license_grammar = require('Module:License_scope')._license_grammar

function p._PD_US(args)
	local deathyear = tonumber(args[1] or args.deathyear)
	local pubyear = tonumber(args[2] or args.pubyear)
	local film = args.film
	local category = args.category
	local template = "PD-US"
	
	-- Is this work after the cutoff date?
	if pubyear and pubyear >= PD.PD_US_cutoff then
		return PD.error_text(template .. " لا ينطبق على الأعمال المنشورة بعد " .. PD.PD_US_cutoff - 1 .. ".", template)
	end
	
	-- Should we use PD-old?
	if deathyear and PD.currentyear - deathyear > 100 then
		return require('Module:PD-old')._PD_old({['category'] = category})
	end
	
	local published_info
	if pubyear then
		published_info = "في " .. pubyear .. "، قبل يوم 1 كانون الثاني (يناير) ،" .. PD.PD_US_cutoff
	else
		published_info = "قبل 1 يناير " .. PD.PD_US_cutoff
	end
	local text = license_scope() .. " في '''[[w:ملكية عامة|الملكية العامة]]''' في '''الولايات االمتحدة''' " .. license_grammar({"لأنه", "لأنها"}) .. " نُشرت " .. published_info .. "." .. PD.shorter_term_text(deathyear, film)
	
	return PD.license({
		['image'] = PD.PD_image,
		['image_r'] = PD.US_flag_image,
		['text'] = text,
		['category'] = category or PD.category_with_deathyear_floor("PD", deathyear) .. "-US"
	})
end

function p.PD_US(frame)
	return p._PD_US(getArgs(frame))
end

return p